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