|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ComponentAdapter<T>
A component adapter is responsible for providing a specific component
instance of type <T>. An instance of an implementation of this interface is
used inside a PicoContainer
for every registered component or
instance. Each ComponentAdapter
instance has to have a key
which is unique within that container. The key itself is either a class type
(normally an interface) or an identifier.
In a overly simplistic sense, the ComponentAdapter can be thought of us a type of an object factory. If you need to modify how your object is constructed, use and appropriate ComponentAdapter or roll your own since the API is purposely kept rather simple. See http://www.picocontainer.org/adapters.html for more information.
Nested Class Summary | |
---|---|
static class |
ComponentAdapter.NOTHING
|
Method Summary | ||
---|---|---|
void |
accept(PicoVisitor visitor)
Accepts a visitor for this ComponentAdapter. |
|
|
findAdapterOfType(Class<U> adapterType)
Locates a component adapter of type componentAdapterType in the ComponentAdapter chain. |
|
Class<T> |
getComponentImplementation()
Retrieve the class of the component. |
|
T |
getComponentInstance(PicoContainer container)
Deprecated. since PicoContainer 2.2. Use getComponentInstance(PicoContainer,Type) with ComponentAdapter.NOTHING.class as type
if no type available. |
|
T |
getComponentInstance(PicoContainer container,
Type into)
Retrieve the component instance. |
|
Object |
getComponentKey()
Retrieve the key associated with the component. |
|
ComponentAdapter<T> |
getDelegate()
Component adapters may be nested in a chain, and this method is used to grab the next ComponentAdapter in the chain. |
|
String |
getDescriptor()
Get a string key descriptor of the component adapter for use in toString() |
|
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisfied. |
Method Detail |
---|
Object getComponentKey()
Class<T> getComponentImplementation()
T getComponentInstance(PicoContainer container) throws PicoCompositionException
getComponentInstance(PicoContainer,Type)
with ComponentAdapter.NOTHING.class
as type
if no type available.
Cached
will always return the
same instance.
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.
PicoCompositionException
- if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.T getComponentInstance(PicoContainer container, Type into) throws PicoCompositionException
Cached
will always return the
same instance.
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.into
- the class that is about to be injected into. Use ComponentAdapter.NOTHING.class if this is not important to you.
PicoCompositionException
- if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambiguous situation within the
container.void verify(PicoContainer container) throws PicoCompositionException
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.
PicoCompositionException
- if one or more dependencies cannot be resolved.void accept(PicoVisitor visitor)
PicoContainer
, that
cascades the visitor also down to all its ComponentAdapter instances.
visitor
- the visitor.ComponentAdapter<T> getDelegate()
<U extends ComponentAdapter> U findAdapterOfType(Class<U> adapterType)
U
- the type of ComponentAdapter being located.adapterType
- the class of the adapter type being located. Never null.
String getDescriptor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |