|
|||||||||||||||||||
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 | |||||||||||||||
PicoContainer.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 |
* Original code by *
|
|
9 |
*****************************************************************************/
|
|
10 |
package org.picocontainer;
|
|
11 |
|
|
12 |
import java.util.Collection;
|
|
13 |
import java.util.List;
|
|
14 |
|
|
15 |
/**
|
|
16 |
* This is the core interface for PicoContainer. It is used to retrieve component instances from the container; it only
|
|
17 |
* has accessor methods (in addition to the {@link #verify()} method). In order to register components in a
|
|
18 |
* PicoContainer, use a {@link MutablePicoContainer}, such as {@link org.picocontainer.defaults.DefaultPicoContainer}.
|
|
19 |
*
|
|
20 |
* @author Paul Hammant
|
|
21 |
* @author Aslak Hellesøy
|
|
22 |
* @author Jon Tirsén
|
|
23 |
* @version $Revision: 1.36 $
|
|
24 |
* @see "The <a href='package-summary.html#package_description'>The package description</a> has a basic overview of how to use the picocontainer package."
|
|
25 |
* @since 1.0
|
|
26 |
*/
|
|
27 |
public interface PicoContainer extends Startable, Disposable { |
|
28 |
|
|
29 |
/**
|
|
30 |
* Retrieve a component instance registered with a specific key. If a component cannot be found in this container,
|
|
31 |
* the parent container (if one exists) will be searched.
|
|
32 |
*
|
|
33 |
* @param componentKey the key that the component was registered with.
|
|
34 |
* @return an instantiated component, or <code>null</code> if no component has been registered for the specified
|
|
35 |
* key.
|
|
36 |
*/
|
|
37 |
Object getComponentInstance(Object componentKey); |
|
38 |
|
|
39 |
/**
|
|
40 |
* Find a component instance matching the specified type.
|
|
41 |
*
|
|
42 |
* @param componentType the type of the component.
|
|
43 |
* @return the adapter matching the class.
|
|
44 |
*/
|
|
45 |
Object getComponentInstanceOfType(Class componentType); |
|
46 |
|
|
47 |
/**
|
|
48 |
* Retrieve all the registered component instances in the container, (not including those in the parent container).
|
|
49 |
* The components are returned in their order of instantiation, which depends on the dependency order between them.
|
|
50 |
*
|
|
51 |
* @return all the components.
|
|
52 |
*/
|
|
53 |
List getComponentInstances(); |
|
54 |
|
|
55 |
/**
|
|
56 |
* Retrieve the parent container of this container.
|
|
57 |
*
|
|
58 |
* @return a {@link PicoContainer} instance, or <code>null</code> if this container does not have a parent.
|
|
59 |
*/
|
|
60 |
PicoContainer getParent(); |
|
61 |
|
|
62 |
/**
|
|
63 |
* Find a component adapter associated with the specified key. If a component adapter cannot be found in this
|
|
64 |
* container, the parent container (if one exists) will be searched.
|
|
65 |
*
|
|
66 |
* @param componentKey the key that the component was registered with.
|
|
67 |
* @return the component adapter associated with this key, or <code>null</code> if no component has been registered
|
|
68 |
* for the specified key.
|
|
69 |
*/
|
|
70 |
ComponentAdapter getComponentAdapter(Object componentKey); |
|
71 |
|
|
72 |
/**
|
|
73 |
* Find a component adapter associated with the specified type. If a component adapter cannot be found in this
|
|
74 |
* container, the parent container (if one exists) will be searched.
|
|
75 |
*
|
|
76 |
* @param componentType the type of the component.
|
|
77 |
* @return the component adapter associated with this class, or <code>null</code> if no component has been
|
|
78 |
* registered for the specified key.
|
|
79 |
*/
|
|
80 |
ComponentAdapter getComponentAdapterOfType(Class componentType); |
|
81 |
|
|
82 |
/**
|
|
83 |
* Retrieve all the component adapters inside this container. The component adapters from the parent container are
|
|
84 |
* not returned.
|
|
85 |
*
|
|
86 |
* @return a collection containing all the {@link ComponentAdapter}s inside this container. The collection will
|
|
87 |
* not be modifiable.
|
|
88 |
* @see #getComponentAdaptersOfType(Class) a variant of this method which returns the component adapters inside this
|
|
89 |
* container that are associated with the specified type.
|
|
90 |
*/
|
|
91 |
Collection getComponentAdapters(); |
|
92 |
|
|
93 |
/**
|
|
94 |
* Retrieve all component adapters inside this container that are associated with the specified type. The component
|
|
95 |
* adapters from the parent container are not returned.
|
|
96 |
*
|
|
97 |
* @param componentType the type of the components.
|
|
98 |
* @return a collection containing all the {@link ComponentAdapter}s inside this container that are associated with
|
|
99 |
* the specified type. Changes to this collection will not be reflected in the container itself.
|
|
100 |
*/
|
|
101 |
List getComponentAdaptersOfType(Class componentType); |
|
102 |
|
|
103 |
/**
|
|
104 |
* Verify that the dependencies for all the registered components can be satisfied. No components are
|
|
105 |
* instantiated during the verification process.
|
|
106 |
*
|
|
107 |
* @throws PicoVerificationException if there are unsatisifiable dependencies.
|
|
108 |
*/
|
|
109 |
void verify() throws PicoVerificationException; |
|
110 |
|
|
111 |
/**
|
|
112 |
* Callback method from the implementation to keep track of the instantiation order. <b>This method is not intended
|
|
113 |
* to be called explicitly by clients of the API!</b>
|
|
114 |
*
|
|
115 |
* @param componentAdapter the freshly added {@link ComponentAdapter}
|
|
116 |
*/
|
|
117 |
void addOrderedComponentAdapter(ComponentAdapter componentAdapter);
|
|
118 |
} |
|
119 |
|
|