KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > defaults > TraversalCheckingVisitor


1 /*****************************************************************************
2  * Copyright (C) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 package org.picocontainer.defaults;
9
10 import org.picocontainer.ComponentAdapter;
11 import org.picocontainer.Parameter;
12 import org.picocontainer.PicoContainer;
13
14
15 /**
16  * Concrete implementation of Visitor which simply checks traversals.
17  * This can be a useful class for other Visitor implementations to extend,
18  * as it provides a default implementation in case you one is only interested
19  * in one PicoVisitor type. Example:
20  *
21  *<pre>
22  * PicoContainer container = new DefaultPicoContainer();
23  * PicoContainer child = container.makeChildContainer();
24  *
25  * final List allContainers = new ArrayList();
26  *
27  * PicoVisitor visitor = new TraversalCheckingVisitor() {
28  * public void visitContainer(PicoContainer pico) {
29  * super.visitContainer(pico); //Calls checkTraversal for us.
30  * allContainers.add(pico);
31  * }
32  * }
33  * </pre>
34  *
35  * @author Micheal Rimov
36  * @since 1.2
37  */

38 public class TraversalCheckingVisitor
39         extends AbstractPicoVisitor {
40
41     public void visitContainer(PicoContainer pico) {
42         checkTraversal();
43     }
44
45     public void visitComponentAdapter(ComponentAdapter componentAdapter) {
46         checkTraversal();
47     }
48
49     public void visitParameter(Parameter parameter) {
50         checkTraversal();
51     }
52
53 }
54
Popular Tags