Class 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
    • 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 - 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:
        java.lang.NullPointerException - if method, or ofType is null
      • 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 invoke
        ofType - the type of the components, that will be invoked
        arguments - the arguments for the method invocation (may be null)
        Throws:
        java.lang.NullPointerException - if method, or ofType is null
    • 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 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.
      • 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)