org.picocontainer.defaults
Class MethodCallingVisitor
java.lang.Object
org.picocontainer.defaults.AbstractPicoVisitor
org.picocontainer.defaults.TraversalCheckingVisitor
org.picocontainer.defaults.MethodCallingVisitor
- All Implemented Interfaces:
- java.io.Serializable, PicoVisitor
- Direct Known Subclasses:
- LifecycleVisitor
public class MethodCallingVisitor
- extends TraversalCheckingVisitor
- implements java.io.Serializable
A PicoVisitor implementation, that calls methods on the components of a specific type.
- Since:
- 1.2
- Author:
- Aslak Hellesøy, Jörg Schaible
- See Also:
- Serialized Form
|
Constructor Summary |
MethodCallingVisitor(java.lang.reflect.Method method,
java.lang.Class ofType,
java.lang.Object[] arguments)
Construct a MethodCallingVisitor for standard methods visiting the component in instantiation order. |
MethodCallingVisitor(java.lang.reflect.Method method,
java.lang.Class ofType,
java.lang.Object[] arguments,
boolean visitInInstantiationOrder)
Construct a MethodCallingVisitor for a method with arguments. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
method
private transient java.lang.reflect.Method method
arguments
private final java.lang.Object[] arguments
type
private final java.lang.Class type
visitInInstantiationOrder
private final boolean visitInInstantiationOrder
componentInstances
private final java.util.List componentInstances
MethodCallingVisitor
public MethodCallingVisitor(java.lang.reflect.Method method,
java.lang.Class ofType,
java.lang.Object[] arguments,
boolean visitInInstantiationOrder)
- Construct a MethodCallingVisitor for a method with arguments.
- Parameters:
method - the Method to invokeofType - the type of the components, that will be invokedvisitInInstantiationOrder - true if components are visited in instantiation orderarguments - the arguments for the method invocation (may be null)
- Throws:
java.lang.NullPointerException - if method, or ofType is null- Since:
- 1.2
MethodCallingVisitor
public MethodCallingVisitor(java.lang.reflect.Method method,
java.lang.Class ofType,
java.lang.Object[] arguments)
- Construct a MethodCallingVisitor for standard methods visiting the component in instantiation order.
- Parameters:
method - the method to invokeofType - the type of the components, that will be invokedarguments - the arguments for the method invocation (may be null)
- Throws:
java.lang.NullPointerException - if method, or ofType is null- Since:
- 1.2
traverse
public java.lang.Object traverse(java.lang.Object node)
- Description copied from interface:
PicoVisitor
- Entry point for the PicoVisitor traversal. The given node is the first object, that is
asked for acceptance. Only objects of type
PicoContainer, ComponentAdapter,
or Parameter are valid.
- Specified by:
traverse in interface PicoVisitor- Overrides:
traverse in class AbstractPicoVisitor
- Parameters:
node - the start node of the traversal.
- Returns:
- a visitor-specific value.
visitContainer
public void visitContainer(PicoContainer pico)
- Description copied from interface:
PicoVisitor
- Visit a
PicoContainer that has to accept the visitor.
- Specified by:
visitContainer in interface PicoVisitor- Overrides:
visitContainer in class TraversalCheckingVisitor
- Parameters:
pico - the visited container.
getMethod
protected java.lang.reflect.Method getMethod()
getArguments
protected java.lang.Object[] getArguments()
invoke
protected void invoke(java.lang.Object[] targets)
invoke
protected java.lang.Object invoke(java.lang.Object target)