01: /*****************************************************************************
02: * Copyright (C) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: *****************************************************************************/package org.picocontainer.visitors;
08:
09: import org.picocontainer.ComponentAdapter;
10: import org.picocontainer.Parameter;
11: import org.picocontainer.PicoContainer;
12: import org.picocontainer.visitors.AbstractPicoVisitor;
13:
14: /**
15: * Concrete implementation of Visitor which simply checks traversals.
16: * This can be a useful class for other Visitor implementations to extend,
17: * as it provides a default implementation in case you one is only interested
18: * in one PicoVisitor type. Example:
19: *
20: *<pre>
21: * PicoContainer container = new DefaultPicoContainer();
22: * PicoContainer child = container.makeChildContainer();
23: *
24: * final List allContainers = new ArrayList();
25: *
26: * PicoVisitor visitor = new TraversalCheckingVisitor() {
27: * public void visitContainer(PicoContainer pico) {
28: * super.visitContainer(pico); //Calls checkTraversal for us.
29: * allContainers.add(pico);
30: * }
31: * }
32: * </pre>
33: *
34: * @author Micheal Rimov
35: */
36: public class TraversalCheckingVisitor extends AbstractPicoVisitor {
37:
38: public void visitContainer(PicoContainer pico) {
39: checkTraversal();
40: }
41:
42: public void visitComponentAdapter(ComponentAdapter componentAdapter) {
43: checkTraversal();
44: }
45:
46: public void visitParameter(Parameter parameter) {
47: checkTraversal();
48: }
49:
50: }
|