001    /*****************************************************************************
002     * Copyright (C) NanoContainer 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     * Original code by Aslak Hellesoy and Paul Hammant                          *
009     *****************************************************************************/
010    
011    package org.nanocontainer;
012    
013    import org.picocontainer.ComponentAdapter;
014    import org.picocontainer.MutablePicoContainer;
015    import org.picocontainer.Parameter;
016    import org.picocontainer.PicoIntrospectionException;
017    import org.picocontainer.PicoRegistrationException;
018    
019    import java.net.URL;
020    
021    /**
022     * A NanoContainer is a container that contains a PicoContainer. -Like
023     * <a href="http://www.monkeon.co.uk/russiandolls/">Russian dolls</a>.
024     *
025     * A NanoContainer adapts a {@link MutablePicoContainer} through a similar API that
026     * is based only on Strings. (It uses reflection to look up classes before registering them
027     * with the adapted PicoContainer). This adapter API is used primarily by the various
028     * {@link org.nanocontainer.script.ScriptedContainerBuilder} implementations in the
029     * org.nanocontainer.script.[scripting engine] packages.
030     *
031     * @author Paul Hammant
032     * @author Aslak Helles&oslash;y
033     */
034    public interface NanoContainer {
035    
036        ComponentAdapter registerComponentImplementation(String componentImplementationClassName) throws PicoRegistrationException, ClassNotFoundException, PicoIntrospectionException;
037    
038        ComponentAdapter registerComponentImplementation(Object key, String componentImplementationClassName) throws ClassNotFoundException;
039    
040        ComponentAdapter registerComponentImplementation(Object key, String componentImplementationClassName, Parameter[] parameters) throws ClassNotFoundException;
041    
042    
043        ComponentAdapter registerComponentImplementation(Object key,
044                                                         String componentImplementationClassName,
045                                                         String[] parameterTypesAsString,
046                                                         String[] parameterValuesAsString) throws PicoRegistrationException, ClassNotFoundException, PicoIntrospectionException;
047    
048        ComponentAdapter registerComponentImplementation(String componentImplementationClassName,
049                                                         String[] parameterTypesAsString,
050                                                         String[] parameterValuesAsString) throws PicoRegistrationException, ClassNotFoundException, PicoIntrospectionException;
051    
052        /**
053         * Adds a new URL that will be used in classloading
054         *
055         * @param url
056         */
057        ClassPathElement addClassLoaderURL(URL url);
058    
059        /**
060         * Returns the wrapped PicoContainer instance (russian doll concept). The method name is short
061         * in order to favour the use of nano.pico from Groovy.
062         *
063         * @return the wrapped PicoContainer instance.
064         */
065        MutablePicoContainer getPico();
066    
067        ClassLoader getComponentClassLoader();
068    
069        /**
070         * Find a component instance matching the specified type.
071         *
072         * @param componentType the type of the component.
073         * @return the adapter matching the class.
074         */
075        Object getComponentInstanceOfType(String componentType);
076    
077    
078        MutablePicoContainer addDecoratingPicoContainer(Class picoContainerClass);
079    
080    
081    }