Home

Castle Stronghold

ComponentActivator

A ComponentActivator is a class that implements the IComponentActivator interface. It must have a specific constructor that receives delegates and should run the delegates to notify the MicroKernel of creation and destruction of component instances.

The constructor takes the following form:


Constructor(ComponentModel model, IKernel kernel, 
            ComponentInstanceDelegate onCreation, 
            ComponentInstanceDelegate onDestruction)

If you want to create your own activator it is best to extend from AbstractComponentActivator or from DefaultComponentActivator.

The creation of a component is also related to the process of supplying dependencies, as dependencies can be supplied through the constructor and through properties. The DefaultComponentActivator for example, chooses the best constructor a component, which is the constructor it can satisfy most dependencies.

If there are interceptors associated with a component, the ComponentActivator is also in charge of creating a proxy. It should use the ProxyFactory exposed by the kernel in order to do so.

You can create a custom ComponentActivator if one of your components can not be simply instantiated. For example, if you want to expose components that comes from a factory exposed by a different system.

You should also consult the IComponentActivator API document.

Google
Search WWW Search castleproject.org