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;
009    
010    /**
011     * Interface realizing a visitor pattern for {@link PicoContainer} as described in the GoF.
012     * The visitor should visit the container, its children, all registered {@link ComponentAdapter}
013     * instances and all instantiated components.
014     * 
015     * @author Aslak Hellesøy
016     * @author Jörg Schaible
017     */
018    public interface PicoVisitor {
019        /**
020         * Entry point for the PicoVisitor traversal. The given node is the first object, that is 
021         * asked for acceptance. Only objects of type {@link PicoContainer}, {@link ComponentAdapter},
022         * or {@link Parameter} are valid.
023         * 
024         * @param node the start node of the traversal.
025         * @return a visitor-specific value.
026         * @throws IllegalArgumentException in case of an argument of invalid type. 
027         */
028        Object traverse(Object node);
029    
030        /**
031         * Visit a {@link PicoContainer} that has to accept the visitor.
032         * 
033         * @param pico the visited container.
034         */
035    
036        void visitContainer(PicoContainer pico);
037        /**
038         * Visit a {@link ComponentAdapter} that has to accept the visitor.
039         * 
040         * @param componentAdapter the visited ComponentAdapter.
041         */
042    
043        void visitComponentAdapter(ComponentAdapter componentAdapter);
044        /**
045         * Visit a {@link Parameter} that has to accept the visitor.
046         * 
047         * @param parameter the visited Parameter.
048         */
049        void visitParameter(Parameter parameter);
050    }