Package org.picocontainer.visitors
Class MethodCallingVisitor
- java.lang.Object
-
- org.picocontainer.visitors.AbstractPicoVisitor
-
- org.picocontainer.visitors.TraversalCheckingVisitor
-
- org.picocontainer.visitors.MethodCallingVisitor
-
- All Implemented Interfaces:
java.io.Serializable
,PicoVisitor
public class MethodCallingVisitor extends TraversalCheckingVisitor implements java.io.Serializable
A PicoVisitor implementation, that calls methods on the components of a specific type.- Author:
- Aslak Hellesøy, Jörg Schaible
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.picocontainer.visitors.AbstractPicoVisitor
AbstractPicoVisitor.PicoVisitorTraversalException
-
-
Field Summary
-
Fields inherited from interface org.picocontainer.PicoVisitor
ABORT_TRAVERSAL, CONTINUE_TRAVERSAL
-
-
Constructor Summary
Constructors Constructor Description MethodCallingVisitor(java.lang.reflect.Method method, java.lang.Class<?> ofType, java.lang.Object[] arguments, boolean visitInInstantiationOrder)
Construct a MethodCallingVisitor for a method with arguments.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object[]
getArguments()
protected java.lang.reflect.Method
getMethod()
protected java.lang.Class<java.lang.Void>
invoke(java.lang.Object target)
protected void
invoke(java.lang.Object[] targets)
java.lang.Object
traverse(java.lang.Object node)
Entry point for the PicoVisitor traversal.boolean
visitContainer(PicoContainer pico)
Visit aPicoContainer
that has to accept the visitor.-
Methods inherited from class org.picocontainer.visitors.TraversalCheckingVisitor
visitComponentAdapter, visitComponentFactory, visitParameter
-
Methods inherited from class org.picocontainer.visitors.AbstractPicoVisitor
checkTraversal
-
-
-
-
Constructor Detail
-
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
- theMethod
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 benull
)- Throws:
java.lang.NullPointerException
- if method, or ofType isnull
-
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 benull
)- Throws:
java.lang.NullPointerException
- if method, or ofType isnull
-
-
Method Detail
-
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 typePicoContainer
,ComponentAdapter
, orParameter
are valid.- Specified by:
traverse
in interfacePicoVisitor
- Overrides:
traverse
in classAbstractPicoVisitor
- Parameters:
node
- the start node of the traversal.- Returns:
- a visitor-specific value.
-
visitContainer
public boolean visitContainer(PicoContainer pico)
Description copied from class:TraversalCheckingVisitor
Visit aPicoContainer
that has to accept the visitor.- Specified by:
visitContainer
in interfacePicoVisitor
- Overrides:
visitContainer
in classTraversalCheckingVisitor
- Parameters:
pico
- the visited container.- Returns:
- CONTINUE_TRAVERSAL if the traversal should continue. Any visitor callback that returns ABORT_TRAVERSAL indicates the desire to abort any further traversal.
-
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.Class<java.lang.Void> invoke(java.lang.Object target)
-
-