001    /*****************************************************************************
002     * Copyright (C) PicoContainer Organization. All rights reserved.            *
003     * ------------------------------------------------------------------------- *
004     * The software in this package is published under the terms of the BSD      *
005     * style license a copy of which has been included with this distribution in *
006     * the LICENSE.txt file.                                                     *
007     *                                                                           *
008     * Original code by Paul Hammant & Obie Fernandez & Aslak                    *
009     *****************************************************************************/
010    
011    package org.picocontainer;
012    
013    import java.lang.reflect.Constructor;
014    import java.lang.reflect.Method;
015    
016    /**
017     * A component monitor is responsible for monitoring the component instantiation 
018     * and method invocation.
019     * 
020     * @author Paul Hammant
021     * @author Obie Fernandez
022     * @author Aslak Hellesøy
023     * @author Mauro Talevi
024     * @version $Revision: 2971 $
025     * @since 1.2
026     */
027    public interface ComponentMonitor {
028    
029        /**
030         * Event thrown as the component is being instantiated using the given constructor
031         * 
032         * @param constructor the Constructor used to instantiate the component
033         */
034        void instantiating(Constructor constructor);
035    
036        /**
037         * Event thrown after the component has been instantiated using the given constructor
038         * 
039         * @param constructor the Constructor used to instantiate the component
040         * @param duration the duration in millis of the instantiation
041         * @deprecated since 1.3
042         */
043        void instantiated(Constructor constructor, long duration);
044    
045        /**
046         * Event thrown after the component has been instantiated using the given constructor.
047         * This should be called for both Constructor and Setter DI.
048         *
049         * @param constructor the Constructor used to instantiate the component
050         * @param instantiated the component that was instantiated by PicoContainer
051         * @param injected the components during instantiation.
052         * @param duration the duration in millis of the instantiation
053         * @since 1.3
054         */
055    
056        void instantiated(Constructor constructor, Object instantiated, Object[] injected, long duration);
057    
058        /**
059         * Event thrown if the component instantiation failed using the given constructor
060         * 
061         * @param constructor the Constructor used to instantiate the component
062         * @param cause the Exception detailing the cause of the failure
063         */
064        void instantiationFailed(Constructor constructor, Exception cause);
065    
066        /**
067         * Event thrown as the component method is being invoked on the given instance
068         * 
069         * @param method the Method invoked on the component instance
070         * @param instance the component instance
071         */
072        void invoking(Method method, Object instance);
073    
074        /**
075         * Event thrown after the component method has been invoked on the given instance
076         * 
077         * @param method the Method invoked on the component instance
078         * @param instance the component instance
079         * @param duration the duration in millis of the invocation
080         */
081        void invoked(Method method, Object instance, long duration);
082    
083        /**
084         * Event thrown if the component method invocation failed on the given instance
085         * 
086         * @param method the Method invoked on the component instance
087         * @param instance the component instance
088         * @param cause the Exception detailing the cause of the failure
089         */
090        void invocationFailed(Method method, Object instance, Exception cause);
091    
092        /**
093         * Event thrown if a lifecycle method invocation - start, stop or dispose - 
094         * failed on the given instance
095         *
096         * @param method the lifecycle Method invoked on the component instance
097         * @param instance the component instance
098         * @param cause the RuntimeException detailing the cause of the failure
099         */
100        void lifecycleInvocationFailed(Method method, Object instance, RuntimeException cause);
101    
102    
103    }