KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > Parameter


1 /*****************************************************************************
2  * Copyright (c) PicoContainer 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  * Idea by Rachel Davies, Original code by Jon Tirsen *
9  *****************************************************************************/

10
11 package org.picocontainer;
12
13 /**
14  * This class provides control over the arguments that will be passed to a constructor. It can be used for finer control
15  * over what arguments are passed to a particular constructor.
16  *
17  * @author Jon Tirsén
18  * @author Aslak Hellesøy
19  * @author Thomas Heller
20  * @see MutablePicoContainer#registerComponentImplementation(Object,Class,Parameter[]) a method on the {@link
21  * MutablePicoContainer} interface which allows passing in of an array of <code>Parameter</code>s.
22  * @see org.picocontainer.defaults.ComponentParameter an implementation of this interface that allows you to specify the
23  * key used for resolving the parameter.
24  * @see org.picocontainer.defaults.ConstantParameter an implementation of this interface that allows you to specify a
25  * constant that will be used for resolving the parameter.
26  * @since 1.0
27  */

28 public interface Parameter {
29     /**
30      * Retrieve the object from the Parameter that statisfies the expected type.
31      *
32      * @param container the container from which dependencies are resolved.
33      * @param adapter the ComponentAdapter that is asking for the instance
34      * @param expectedType the type that the returned instance needs to match.
35      * @return the instance or <code>null</code> if no suitable instance can be found.
36      * @throws PicoInitializationException if a referenced component could not be instantiated.
37      * @since 1.1
38      */

39     Object JavaDoc resolveInstance(PicoContainer container, ComponentAdapter adapter, Class JavaDoc expectedType) throws PicoInitializationException;
40
41     /**
42      * Check if the Parameter can statisfy the expected type using the container.
43      *
44      * @param container the container from which dependencies are resolved.
45      * @param adapter the container that should be searched
46      * @param expectedType the required type
47      * @return <code>true</code> if the component parameter can be resolved.
48      * @since 1.1
49      */

50     boolean isResolvable(PicoContainer container, ComponentAdapter adapter, Class JavaDoc expectedType);
51
52     /**
53      * Verify that the Parameter can statisfied the expected type using the container
54      *
55      * @param container the container from which dependencies are resolved.
56      * @param adapter the container that should be searched
57      * @param expectedType the required type
58      * @throws PicoIntrospectionException if parameter and its dependencies cannot be resolved
59      * @since 1.1
60      */

61     void verify(PicoContainer container, ComponentAdapter adapter, Class JavaDoc expectedType) throws PicoIntrospectionException;
62
63     /**
64      * Accepts a visitor for this Parameter. The method is normally called by visiting a {@link ComponentAdapter}, that
65      * cascades the visitor also down to all its Parameters.
66      *
67      * @param visitor the visitor.
68      * @since 1.1
69      */

70     void accept(PicoVisitor visitor);
71 }
72
Popular Tags