KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > NanoContainer


1 /*****************************************************************************
2  * Copyright (C) NanoContainer 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  * Original code by Aslak Hellesoy and Paul Hammant *
9  *****************************************************************************/

10
11 package org.nanocontainer;
12
13 import org.picocontainer.ComponentAdapter;
14 import org.picocontainer.MutablePicoContainer;
15 import org.picocontainer.Parameter;
16 import org.picocontainer.PicoIntrospectionException;
17 import org.picocontainer.PicoRegistrationException;
18
19 import java.net.URL JavaDoc;
20
21 /**
22  * A NanoContainer is a container that contains a PicoContainer. -Like
23  * <a HREF="http://www.monkeon.co.uk/russiandolls/">Russian dolls</a>.
24  *
25  * A NanoContainer adapts a {@link MutablePicoContainer} through a similar API that
26  * is based only on Strings. (It uses reflection to look up classes before registering them
27  * with the adapted PicoContainer). This adapter API is used primarily by the various
28  * {@link org.nanocontainer.script.ScriptedContainerBuilder} implementations in the
29  * org.nanocontainer.script.[scripting engine] packages.
30  *
31  * @author Paul Hammant
32  * @author Aslak Helles&oslash;y
33  */

34 public interface NanoContainer {
35
36     ComponentAdapter registerComponentImplementation(String JavaDoc componentImplementationClassName) throws PicoRegistrationException, ClassNotFoundException JavaDoc, PicoIntrospectionException;
37
38     ComponentAdapter registerComponentImplementation(Object JavaDoc key, String JavaDoc componentImplementationClassName) throws ClassNotFoundException JavaDoc;
39
40     ComponentAdapter registerComponentImplementation(Object JavaDoc key, String JavaDoc componentImplementationClassName, Parameter[] parameters) throws ClassNotFoundException JavaDoc;
41
42
43     ComponentAdapter registerComponentImplementation(Object JavaDoc key,
44                                                      String JavaDoc componentImplementationClassName,
45                                                      String JavaDoc[] parameterTypesAsString,
46                                                      String JavaDoc[] parameterValuesAsString) throws PicoRegistrationException, ClassNotFoundException JavaDoc, PicoIntrospectionException;
47
48     ComponentAdapter registerComponentImplementation(String JavaDoc componentImplementationClassName,
49                                                      String JavaDoc[] parameterTypesAsString,
50                                                      String JavaDoc[] parameterValuesAsString) throws PicoRegistrationException, ClassNotFoundException JavaDoc, PicoIntrospectionException;
51
52     /**
53      * Adds a new URL that will be used in classloading
54      *
55      * @param url
56      */

57     ClassPathElement addClassLoaderURL(URL JavaDoc url);
58
59     /**
60      * Returns the wrapped PicoContainer instance (russian doll concept). The method name is short
61      * in order to favour the use of nano.pico from Groovy.
62      *
63      * @return the wrapped PicoContainer instance.
64      */

65     MutablePicoContainer getPico();
66
67     ClassLoader JavaDoc getComponentClassLoader();
68
69     /**
70      * Find a component instance matching the specified type.
71      *
72      * @param componentType the type of the component.
73      * @return the adapter matching the class.
74      */

75     Object JavaDoc getComponentInstanceOfType(String JavaDoc componentType);
76
77
78     MutablePicoContainer addDecoratingPicoContainer(Class JavaDoc picoContainerClass);
79
80
81 }
82
Popular Tags