org.picocontainer.defaults
Class MethodCallingVisitor

java.lang.Object
  extended by org.picocontainer.defaults.AbstractPicoVisitor
      extended by org.picocontainer.defaults.TraversalCheckingVisitor
          extended by org.picocontainer.defaults.MethodCallingVisitor
All Implemented Interfaces:
Serializable, PicoVisitor
Direct Known Subclasses:
LifecycleVisitor

public class MethodCallingVisitor
extends TraversalCheckingVisitor
implements 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(Method method, Class ofType, Object[] arguments)
          Construct a MethodCallingVisitor for standard methods visiting the component in instantiation order.
MethodCallingVisitor(Method method, Class ofType, Object[] arguments, boolean visitInInstantiationOrder)
          Construct a MethodCallingVisitor for a method with arguments.
 
Method Summary
protected  Object[] getArguments()
           
protected  Method getMethod()
           
protected  Object invoke(Object target)
           
protected  void invoke(Object[] targets)
           
 Object traverse(Object node)
          Entry point for the PicoVisitor traversal.
 void visitContainer(PicoContainer pico)
          Visit a PicoContainer that has to accept the visitor.
 
Methods inherited from class org.picocontainer.defaults.TraversalCheckingVisitor
visitComponentAdapter, visitParameter
 
Methods inherited from class org.picocontainer.defaults.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
Since:
1.2

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
Since:
1.2
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 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 Method getMethod()

getArguments

protected Object[] getArguments()

invoke

protected void invoke(Object[] targets)

invoke

protected Object invoke(Object target)


Copyright © 2003-2007 Codehaus. All Rights Reserved.