org.picocontainer.visitors
Class MethodCallingVisitor

java.lang.Object
  extended by org.picocontainer.visitors.AbstractPicoVisitor
      extended by org.picocontainer.visitors.TraversalCheckingVisitor
          extended by org.picocontainer.visitors.MethodCallingVisitor
All Implemented Interfaces:
Serializable, PicoVisitor

public class MethodCallingVisitor
extends TraversalCheckingVisitor
implements 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
MethodCallingVisitor(Method method, Class<?> ofType, Object[] arguments, boolean visitInInstantiationOrder)
          Construct a MethodCallingVisitor for a method with arguments.
MethodCallingVisitor(Method method, Class ofType, Object[] arguments)
          Construct a MethodCallingVisitor for standard methods visiting the component in instantiation order.
 
Method Summary
protected  Object[] getArguments()
           
protected  Method getMethod()
           
protected  Class<Void> invoke(Object target)
           
protected  void invoke(Object[] targets)
           
 Object traverse(Object node)
          Entry point for the PicoVisitor traversal.
 boolean visitContainer(PicoContainer pico)
          Visit a PicoContainer 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodCallingVisitor

public MethodCallingVisitor(Method method,
                            Class<?> ofType,
                            Object[] arguments,
                            boolean visitInInstantiationOrder)
Construct a MethodCallingVisitor for a method with arguments.

Parameters:
method - the Method to invoke
ofType - the type of the components, that will be invoked
visitInInstantiationOrder - true if components are visited in instantiation order
arguments - the arguments for the method invocation (may be null)
Throws:
NullPointerException - if method, or ofType is null

MethodCallingVisitor

public MethodCallingVisitor(Method method,
                            Class ofType,
                            Object[] arguments)
Construct a MethodCallingVisitor for standard methods visiting the component in instantiation order.

Parameters:
method - the method to invoke
ofType - the type of the components, that will be invoked
arguments - the arguments for the method invocation (may be null)
Throws:
NullPointerException - if method, or ofType is null
Method Detail

traverse

public Object traverse(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 boolean visitContainer(PicoContainer pico)
Description copied from class: TraversalCheckingVisitor
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.
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 Method getMethod()

getArguments

protected Object[] getArguments()

invoke

protected void invoke(Object[] targets)

invoke

protected Class<Void> invoke(Object target)


Copyright © 2003-2010 Codehaus. All Rights Reserved.