// Copyright 2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. namespace Apache.Avalon.Castle.MicroKernel { using System; using Apache.Avalon.Castle.MicroKernel.Model; using Apache.Avalon.Castle.MicroKernel.Interceptor; /// /// Represents a delegate which holds basic information about a component. /// /// Component information /// Key which identifies the component /// handler that holds this component and is capable of /// creating an instance of it. /// public delegate void ComponentDataDelegate( IComponentModel model, String key, IHandler handler ); /// /// Represents a delegate which holds basic information about a component /// and allows listeners to intercept (and proxy) the component instance. /// /// Component information /// Key which identifies the component /// handler that holds this component and is capable of /// creating an instance of it. /// /// /// Holds the component instance and its proxied version. If no interception is added /// to the component, the proxied version is discarded and the kernel will work with /// the component instance instead. /// public delegate void WrapDelegate( IComponentModel model, String key, IHandler handler, IInterceptedComponent interceptedComponent ); /// /// Represents a delegate which holds basic information about a component /// and its instance. /// /// Component information /// Key which identifies the component /// handler that holds this component and is capable of /// creating an instance of it. /// /// Component instance public delegate void ComponentInstanceDelegate( IComponentModel model, String key, IHandler handler, object instance ); /// /// Delegate which holds a group of component information. /// /// Component information /// Key which identifies the component public delegate void ComponentModelDelegate( IComponentModel model, String key ); /// /// Kernel events contract. /// public interface IKernelEvents { /// /// Event fired when a new component is registered /// on the kernel. /// event ComponentDataDelegate ComponentRegistered; /// /// Event fired when a component is removed from the kernel. /// event ComponentDataDelegate ComponentUnregistered; /// /// Event fired when a component was instantiated /// and its lifecycle phases was already performed. /// Extensions can be applied by listening to this event /// and proxying the component instance /// event WrapDelegate ComponentWrap; /// /// When the component is given back to the kernel /// this event is fired. At the end, if a proxied instance was create /// previously it will be discarded and the real component instance /// will be available to the kernel, allowing it to performe /// the final lifecycle phases. /// event WrapDelegate ComponentUnWrap; /// /// Event fired before the component is returned to the outside /// world. /// event ComponentInstanceDelegate ComponentReady; /// /// Event fired when a component instance is given back to the /// kernel. /// event ComponentInstanceDelegate ComponentReleased; /// /// Event fired when all information about a component was /// successfully collected. /// event ComponentModelDelegate ComponentModelConstructed; /// /// Fires the ComponentWrap event. It should be called /// only by the implementations. /// /// The component instance /// The handler which owns the instance /// Returns the component instance or a proxy object RaiseWrapEvent( IHandler handler, object instance ); /// /// Fires the ComponentUnWrap event. It should be called /// only by the implementations. /// /// The component instance (or a proxy) /// The handler which owns the instance /// Should return the component instance, not the proxy object RaiseUnWrapEvent( IHandler handler, object instance ); /// /// Fires the ComponentReady event. It should be called /// only by the implementation. /// /// The component instance /// The handler which owns the instance void RaiseComponentReadyEvent(IHandler handler, object instance); /// /// Fires the ComponentReleased event. It should be called /// only by the implementation. /// /// The component instance /// The handler which owns the instance void RaiseComponentReleasedEvent( IHandler handler, object instance ); } }