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: *****************************************************************************/package org.picocontainer;
010:
011: import java.lang.reflect.Constructor;
012: import java.lang.reflect.Member;
013: import java.lang.reflect.Method;
014:
015: /**
016: * A component monitor is responsible for monitoring the component instantiation
017: * and method invocation.
018: *
019: * @author Paul Hammant
020: * @author Obie Fernandez
021: * @author Aslak Hellesøy
022: * @author Mauro Talevi
023: */
024: public interface ComponentMonitor {
025:
026: /**
027: * Event thrown as the component is being instantiated using the given constructor
028: *
029: * @param container
030: * @param componentAdapter
031: * @param constructor the Constructor used to instantiate the addComponent @return the constructor to use in instantiation (nearly always the same one as passed in)
032: */
033: <T> Constructor<T> instantiating(PicoContainer container,
034: ComponentAdapter<T> componentAdapter,
035: Constructor<T> constructor);
036:
037: /**
038: * Event thrown after the component has been instantiated using the given constructor.
039: * This should be called for both Constructor and Setter DI.
040: *
041: * @param container
042: * @param componentAdapter
043: * @param constructor the Constructor used to instantiate the addComponent
044: * @param instantiated the component that was instantiated by PicoContainer
045: * @param injected the components during instantiation.
046: * @param duration the duration in milliseconds of the instantiation
047: */
048:
049: <T> void instantiated(PicoContainer container,
050: ComponentAdapter<T> componentAdapter,
051: Constructor<T> constructor, Object instantiated,
052: Object[] injected, long duration);
053:
054: /**
055: * Event thrown if the component instantiation failed using the given constructor
056: *
057: * @param container
058: * @param componentAdapter
059: * @param constructor the Constructor used to instantiate the addComponent
060: * @param cause the Exception detailing the cause of the failure
061: */
062: <T> void instantiationFailed(PicoContainer container,
063: ComponentAdapter<T> componentAdapter,
064: Constructor<T> constructor, Exception cause);
065:
066: /**
067: * Event thrown as the component method is being invoked on the given instance
068: *
069: * @param container
070: * @param componentAdapter
071: * @param member
072: * @param instance the component instance
073: */
074: void invoking(PicoContainer container,
075: ComponentAdapter<?> componentAdapter, Member member,
076: Object instance);
077:
078: /**
079: * Event thrown after the component method has been invoked on the given instance
080: *
081: * @param container
082: * @param componentAdapter
083: * @param method the Method invoked on the component instance
084: * @param instance the component instance
085: * @param duration the duration in millis of the invocation
086: */
087: void invoked(PicoContainer container,
088: ComponentAdapter<?> componentAdapter, Method method,
089: Object instance, long duration);
090:
091: /**
092: * Event thrown if the component method invocation failed on the given instance
093: *
094: * @param member
095: * @param instance the component instance
096: * @param cause the Exception detailing the cause of the failure
097: */
098: void invocationFailed(Member member, Object instance,
099: Exception cause);
100:
101: /**
102: * Event thrown if a lifecycle method invocation - start, stop or dispose -
103: * failed on the given instance
104: *
105: * @param container
106: * @param componentAdapter
107: * @param method the lifecycle Method invoked on the component instance
108: * @param instance the component instance
109: * @param cause the RuntimeException detailing the cause of the failure
110: */
111: void lifecycleInvocationFailed(MutablePicoContainer container,
112: ComponentAdapter<?> componentAdapter, Method method,
113: Object instance, RuntimeException cause);
114:
115: /**
116: *
117: * @param container
118: * @param componentKey
119: */
120: Object noComponentFound(MutablePicoContainer container,
121: Object componentKey);
122: }
|