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 Hellesøy    *
009     *****************************************************************************/
010    
011    package org.picocontainer.monitors;
012    
013    import java.io.Serializable;
014    import java.lang.reflect.Constructor;
015    import java.lang.reflect.Method;
016    import java.lang.reflect.Member;
017    
018    import org.picocontainer.ComponentMonitor;
019    import org.picocontainer.PicoLifecycleException;
020    import org.picocontainer.ComponentAdapter;
021    import org.picocontainer.MutablePicoContainer;
022    import org.picocontainer.PicoContainer;
023    
024    /**
025     * A {@link ComponentMonitor} which does nothing. 
026     * 
027     * @author Paul Hammant
028     * @author Obie Fernandez
029     */
030    public class NullComponentMonitor implements ComponentMonitor, Serializable {
031    
032        public Constructor instantiating(PicoContainer container, ComponentAdapter componentAdapter,
033                                         Constructor constructor) {
034            return constructor;
035        }
036    
037        public void instantiationFailed(PicoContainer container,
038                                        ComponentAdapter componentAdapter,
039                                        Constructor constructor,
040                                        Exception e) {
041        }
042    
043        public void instantiated(PicoContainer container, ComponentAdapter componentAdapter,
044                                 Constructor constructor,
045                                 Object instantiated,
046                                 Object[] injected,
047                                 long duration) {
048        }
049    
050        public void invoking(PicoContainer container,
051                             ComponentAdapter componentAdapter,
052                             Member member,
053                             Object instance) {
054        }
055    
056        public void invoked(PicoContainer container,
057                            ComponentAdapter componentAdapter,
058                            Method method,
059                            Object instance,
060                            long duration) {
061        }
062    
063        public void invocationFailed(Member member, Object instance, Exception e) {
064        }
065    
066        public void lifecycleInvocationFailed(MutablePicoContainer container,
067                                              ComponentAdapter componentAdapter, Method method,
068                                              Object instance,
069                                              RuntimeException cause) {
070            throw new PicoLifecycleException(method, instance, cause);
071        }
072    
073        public Object noComponentFound(MutablePicoContainer container, Object componentKey) {
074            return null;
075        }
076    
077    }