|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MutablePicoContainer.java | - | - | - | - |
|
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 various *
|
|
9 |
*****************************************************************************/
|
|
10 |
package org.picocontainer;
|
|
11 |
|
|
12 |
/**
|
|
13 |
* This is the core interface used for registration of components with a container. It is possible to register {@link
|
|
14 |
* #registerComponentImplementation(Object,Class) an implementation class}, {@link #registerComponentInstance(Object) an
|
|
15 |
* instance} or {@link #registerComponent(ComponentAdapter) a ComponentAdapter}.
|
|
16 |
*
|
|
17 |
* @author Paul Hammant
|
|
18 |
* @author Aslak Hellesøy
|
|
19 |
* @author Jon Tirsén
|
|
20 |
* @version $Revision: 1.30 $
|
|
21 |
* @see "The <a href='package-summary.html#package_description'>The package description</a> has a basic overview of how to use the picocontainer package."
|
|
22 |
* @since 1.0
|
|
23 |
*/
|
|
24 |
public interface MutablePicoContainer extends PicoContainer { |
|
25 |
|
|
26 |
/**
|
|
27 |
* Register a component.
|
|
28 |
*
|
|
29 |
* @param componentKey a key that identifies the component. Must be unique within the container. The type
|
|
30 |
* of the key object has no semantic significance unless explicitly specified in the
|
|
31 |
* documentation of the implementing container.
|
|
32 |
* @param componentImplementation the component's implementation class. This must be a concrete class (ie, a
|
|
33 |
* class that can be instantiated).
|
|
34 |
* @return the ComponentAdapter that has been associated with this component. In the majority of cases, this return
|
|
35 |
* value can be safely ignored, as one of the <code>getXXX()</code> methods of the
|
|
36 |
* {@link PicoContainer} interface can be used to retrieve a reference to the component later on.
|
|
37 |
* @throws PicoRegistrationException if registration of the component fails.
|
|
38 |
* @see #registerComponentImplementation(Object,Class,Parameter[]) a variant of this method that allows more control
|
|
39 |
* over the parameters passed into the componentImplementation constructor when constructing an instance.
|
|
40 |
*/
|
|
41 |
ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException;
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Register a component.
|
|
45 |
*
|
|
46 |
* @param componentKey a key that identifies the component. Must be unique within the container. The type
|
|
47 |
* of the key object has no semantic significance unless explicitly specified in the
|
|
48 |
* documentation of the implementing container.
|
|
49 |
* @param componentImplementation the component's implementation class. This must be a concrete class (ie, a
|
|
50 |
* class that can be instantiated).
|
|
51 |
* @param parameters an array of parameters that gives the container hints about what arguments to pass
|
|
52 |
* to the constructor when it is instantiated. Container implementations may ignore
|
|
53 |
* one or more of these hints.
|
|
54 |
* @return the ComponentAdapter that has been associated with this component. In the majority of cases, this return
|
|
55 |
* value can be safely ignored, as one of the <code>getXXX()</code> methods of the
|
|
56 |
* {@link PicoContainer} interface can be used to retrieve a reference to the component later on.
|
|
57 |
* @throws PicoRegistrationException if registration of the component fails.
|
|
58 |
*/
|
|
59 |
ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoRegistrationException;
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Register a component using the componentImplementation as key. Calling this method is equivalent to calling
|
|
63 |
* <code>registerComponentImplementation(componentImplementation, componentImplementation)</code>.
|
|
64 |
*
|
|
65 |
* @param componentImplementation the concrete component class.
|
|
66 |
* @return the ComponentAdapter that has been associated with this component. In the majority of cases, this return
|
|
67 |
* value can be safely ignored, as one of the <code>getXXX()</code> methods of the
|
|
68 |
* {@link PicoContainer} interface can be used to retrieve a reference to the component later on.
|
|
69 |
* @throws PicoRegistrationException if registration fails.
|
|
70 |
*/
|
|
71 |
ComponentAdapter registerComponentImplementation(Class componentImplementation) throws PicoRegistrationException;
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Register an arbitrary object. The class of the object will be used as a key. Calling this method is equivalent to
|
|
75 |
* calling * <code>registerComponentImplementation(componentImplementation, componentImplementation)</code>.
|
|
76 |
*
|
|
77 |
* @param componentInstance
|
|
78 |
* @return the ComponentAdapter that has been associated with this component. In the majority of cases, this return
|
|
79 |
* value can be safely ignored, as one of the <code>getXXX()</code> methods of the
|
|
80 |
* {@link PicoContainer} interface can be used to retrieve a reference to the component later on.
|
|
81 |
* @throws PicoRegistrationException if registration fails.
|
|
82 |
*/
|
|
83 |
ComponentAdapter registerComponentInstance(Object componentInstance) throws PicoRegistrationException;
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Register an arbitrary object as a component in the container. This is handy when other components in the same
|
|
87 |
* container have dependencies on this kind of object, but where letting the container manage and instantiate it is
|
|
88 |
* impossible.
|
|
89 |
* <p/>
|
|
90 |
* Beware that too much use of this method is an <a href="http://docs.codehaus.org/display/PICO/Instance+Registration">antipattern</a>.
|
|
91 |
*
|
|
92 |
* @param componentKey a key that identifies the component. Must be unique within the conainer. The type of the
|
|
93 |
* key object has no semantic significance unless explicitly specified in the implementing
|
|
94 |
* container.
|
|
95 |
* @param componentInstance an arbitrary object.
|
|
96 |
* @return the ComponentAdapter that has been associated with this component. In the majority of cases, this return
|
|
97 |
* value can be safely ignored, as one of the <code>getXXX()</code> methods of the
|
|
98 |
* {@link PicoContainer} interface can be used to retrieve a reference to the component later on.
|
|
99 |
* @throws PicoRegistrationException if registration fails.
|
|
100 |
*/
|
|
101 |
ComponentAdapter registerComponentInstance(Object componentKey, Object componentInstance) throws PicoRegistrationException;
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Register a component via a ComponentAdapter. Use this if you need fine grained control over what
|
|
105 |
* ComponentAdapter to use for a specific component.
|
|
106 |
*
|
|
107 |
* @param componentAdapter the adapter
|
|
108 |
* @return the same adapter that was passed as an argument.
|
|
109 |
* @throws PicoRegistrationException if registration fails.
|
|
110 |
*/
|
|
111 |
ComponentAdapter registerComponent(ComponentAdapter componentAdapter) throws PicoRegistrationException;
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Unregister a component by key.
|
|
115 |
*
|
|
116 |
* @param componentKey key of the component to unregister.
|
|
117 |
* @return the ComponentAdapter that was associated with this component.
|
|
118 |
*/
|
|
119 |
ComponentAdapter unregisterComponent(Object componentKey); |
|
120 |
|
|
121 |
/**
|
|
122 |
* Unregister a component by instance.
|
|
123 |
*
|
|
124 |
* @param componentInstance the component instance to unregister.
|
|
125 |
* @return the ComponentAdapter that was associated with this component.
|
|
126 |
*/
|
|
127 |
ComponentAdapter unregisterComponentByInstance(Object componentInstance); |
|
128 |
|
|
129 |
/**
|
|
130 |
* Set the Parent container.
|
|
131 |
*
|
|
132 |
* @param parent parent container.
|
|
133 |
* @deprecated This will probably go away. implementations should take the parent in the constructor (constructor
|
|
134 |
* injection!)
|
|
135 |
*/
|
|
136 |
void setParent(PicoContainer parent);
|
|
137 |
|
|
138 |
} |
|
139 |
|
|