org.picocontainer.visitors
Class TraversalCheckingVisitor

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

public class TraversalCheckingVisitor
extends AbstractPicoVisitor

Concrete implementation of Visitor which simply checks traversals. This can be a useful class for other Visitor implementations to extend, as it provides a default implementation in case you one is only interested in one PicoVisitor type. Example:

 PicoContainer container = new DefaultPicoContainer();
 PicoContainer child = container.makeChildContainer();

 final List allContainers = new ArrayList();

 PicoVisitor visitor = new TraversalCheckingVisitor() {
     public boolean visitContainer(PicoContainer pico) {
         super.visitContainer(pico);  //Calls checkTraversal for us.
         allContainers.add(pico);
         return true;
     }
 }
 

Author:
Michael Rimov

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
TraversalCheckingVisitor()
           
 
Method Summary
 void visitComponentAdapter(ComponentAdapter<?> componentAdapter)
          Visit a ComponentAdapter that has to accept the visitor.
 void visitComponentFactory(ComponentFactory componentFactory)
          Visit a ComponentAdapter that has to accept the visitor.
 boolean visitContainer(PicoContainer pico)
          Visit a PicoContainer that has to accept the visitor.
 void visitParameter(Parameter parameter)
          Visit a Parameter that has to accept the visitor.
 
Methods inherited from class org.picocontainer.visitors.AbstractPicoVisitor
checkTraversal, traverse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TraversalCheckingVisitor

public TraversalCheckingVisitor()
Method Detail

visitContainer

public boolean visitContainer(PicoContainer pico)
Visit a PicoContainer that has to accept the visitor.

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.

visitComponentAdapter

public void visitComponentAdapter(ComponentAdapter<?> componentAdapter)
Visit a ComponentAdapter that has to accept the visitor.

Parameters:
componentAdapter - the visited ComponentAdapter.

visitComponentFactory

public void visitComponentFactory(ComponentFactory componentFactory)
Visit a ComponentAdapter that has to accept the visitor.


visitParameter

public void visitParameter(Parameter parameter)
Visit a Parameter that has to accept the visitor.

Parameters:
parameter - the visited Parameter.


Copyright © 2003-2010 Codehaus. All Rights Reserved.