Home

Castle Stronghold

Handlers

Each component registered on the MicroKernel has a respective handler instance (which is a class that implements IHandler). The handle is a kind of gate keeper for the component. The handle's roles are:

The last bullet is the more complex one. The MicroKernel was designed to be dynamic which means that components can be registered and removed at any time. Others IoC containers are static, which greatly simplify their implementation but are not as powerful as dynamic ones.

The the MicroKernel uses a dynamic approach, the handler check if the current state of the container have all others components/services and configuration required by the component it is keeping. If not, the handler subscribes to a container event so it will know when a new component is registered. Each component later registered will trigger a check and the handler will re-evaluate its state.

While the minimal set of dependencies cannot be reached, the handle is said to be in a WaitingDependency state. If you try to request a component whose handler is in this state, an exception will be thrown. The exception message will list what the handler is waiting for.

The most complex situation is when the component dependencies are registered but the dependencies themselves are in the WaitingDependency state. Trying to request this component will also throw an exception. The exception message will tell you that a component the handler waits for was registered, but is not in a valid state.

You should also consult the IHandler API document.

Google
Search WWW Search castleproject.org