001    /*****************************************************************************
002     * Copyright (C) PicoContainer Organization. All rights reserved.            *
003     * ------------------------------------------------------------------------- *
004     * The software in this package is published under the terms of the BSD      *
005     * style license a copy of which has been included with this distribution in *
006     * the LICENSE.txt file.                                                     *
007     *****************************************************************************/
008    package org.picocontainer.visitors;
009    
010    import org.picocontainer.ComponentAdapter;
011    import org.picocontainer.Parameter;
012    import org.picocontainer.PicoContainer;
013    import org.picocontainer.visitors.AbstractPicoVisitor;
014    
015    
016    /**
017     * Concrete implementation of Visitor which simply checks traversals.
018     * This can be a useful class for other Visitor implementations to extend, 
019     * as it provides a default implementation in case you one is only interested
020     * in one PicoVisitor type.  Example:
021     *
022     *<pre>
023     * PicoContainer container = new DefaultPicoContainer();
024     * PicoContainer child = container.makeChildContainer();
025     *
026     * final List allContainers = new ArrayList();
027     *
028     * PicoVisitor visitor = new TraversalCheckingVisitor() {
029     *     public void visitContainer(PicoContainer pico) {
030     *         super.visitContainer(pico);  //Calls checkTraversal for us.
031     *         allContainers.add(pico);
032     *     }
033     * }
034     * </pre>
035     *
036     * @author Micheal Rimov
037     */
038    public class TraversalCheckingVisitor
039            extends AbstractPicoVisitor {
040    
041        public void visitContainer(PicoContainer pico) {
042            checkTraversal();
043        }
044    
045        public void visitComponentAdapter(ComponentAdapter componentAdapter) {
046            checkTraversal();
047        }
048    
049        public void visitParameter(Parameter parameter) {
050            checkTraversal();
051        }
052    
053    }