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.defaults; 009 010 import org.picocontainer.ComponentAdapter; 011 import org.picocontainer.Parameter; 012 import org.picocontainer.PicoContainer; 013 014 015 /** 016 * Concrete implementation of Visitor which simply checks traversals. 017 * This can be a useful class for other Visitor implementations to extend, 018 * as it provides a default implementation in case you one is only interested 019 * in one PicoVisitor type. Example: 020 * 021 *<pre> 022 * PicoContainer container = new DefaultPicoContainer(); 023 * PicoContainer child = container.makeChildContainer(); 024 * 025 * final List allContainers = new ArrayList(); 026 * 027 * PicoVisitor visitor = new TraversalCheckingVisitor() { 028 * public void visitContainer(PicoContainer pico) { 029 * super.visitContainer(pico); //Calls checkTraversal for us. 030 * allContainers.add(pico); 031 * } 032 * } 033 * </pre> 034 * 035 * @author Micheal Rimov 036 * @since 1.2 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 }