Package org.picocontainer
Class DefaultPicoContainer.KnowsContainerAdapter<T>
- java.lang.Object
-
- org.picocontainer.DefaultPicoContainer.KnowsContainerAdapter<T>
-
- All Implemented Interfaces:
ComponentAdapter<T>
- Enclosing class:
- DefaultPicoContainer
public static class DefaultPicoContainer.KnowsContainerAdapter<T> extends java.lang.Object implements ComponentAdapter<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter
ComponentAdapter.NOTHING
-
-
Constructor Summary
Constructors Constructor Description KnowsContainerAdapter(ComponentAdapter<T> ca, PicoContainer ctr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(PicoVisitor visitor)
Accepts a visitor for this ComponentAdapter.<U extends ComponentAdapter>
UfindAdapterOfType(java.lang.Class<U> adapterType)
Locates a component adapter of type componentAdapterType in the ComponentAdapter chain.java.lang.Class<? extends T>
getComponentImplementation()
Retrieve the class of the component.T
getComponentInstance(java.lang.reflect.Type into)
T
getComponentInstance(PicoContainer container)
Retrieve the component instance.T
getComponentInstance(PicoContainer container, java.lang.reflect.Type into)
Retrieve the component instance.java.lang.Object
getComponentKey()
Retrieve the key associated with the component.ComponentAdapter
getDelegate()
Component adapters may be nested in a chain, and this method is used to grab the next ComponentAdapter in the chain.java.lang.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.
-
-
-
Constructor Detail
-
KnowsContainerAdapter
public KnowsContainerAdapter(ComponentAdapter<T> ca, PicoContainer ctr)
-
-
Method Detail
-
getComponentInstance
public T getComponentInstance(java.lang.reflect.Type into) throws PicoCompositionException
- Throws:
PicoCompositionException
-
getComponentKey
public java.lang.Object getComponentKey()
Description copied from interface:ComponentAdapter
Retrieve the key associated with the component.- Specified by:
getComponentKey
in interfaceComponentAdapter<T>
- Returns:
- the component's key. Should either be a class type (normally an interface) or an identifier that is unique (within the scope of the current PicoContainer).
-
getComponentImplementation
public java.lang.Class<? extends T> getComponentImplementation()
Description copied from interface:ComponentAdapter
Retrieve the class of the component.- Specified by:
getComponentImplementation
in interfaceComponentAdapter<T>
- Returns:
- the component's implementation class. Should normally be a concrete class (ie, a class that can be instantiated).
-
getComponentInstance
public T getComponentInstance(PicoContainer container) throws PicoCompositionException
Description copied from interface:ComponentAdapter
Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example,Cached
will always return the same instance.- Specified by:
getComponentInstance
in interfaceComponentAdapter<T>
- Parameters:
container
- thePicoContainer
, that is used to resolve any possible dependencies of the instance.- Returns:
- the component instance.
- Throws:
PicoCompositionException
- if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambigous situation within the container.
-
getComponentInstance
public T getComponentInstance(PicoContainer container, java.lang.reflect.Type into) throws PicoCompositionException
Description copied from interface:ComponentAdapter
Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example,Cached
will always return the same instance.- Specified by:
getComponentInstance
in interfaceComponentAdapter<T>
- Parameters:
container
- thePicoContainer
, 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.- Returns:
- the component instance.
- Throws:
PicoCompositionException
- if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambiguous situation within the container.
-
verify
public void verify(PicoContainer container) throws PicoCompositionException
Description copied from interface:ComponentAdapter
Verify that all dependencies for this adapter can be satisfied. Normally, the adapter should verify this by checking that the associated PicoContainer contains all the needed dependencies.- Specified by:
verify
in interfaceComponentAdapter<T>
- Parameters:
container
- thePicoContainer
, that is used to resolve any possible dependencies of the instance.- Throws:
PicoCompositionException
- if one or more dependencies cannot be resolved.
-
accept
public void accept(PicoVisitor visitor)
Description copied from interface:ComponentAdapter
Accepts a visitor for this ComponentAdapter. The method is normally called by visiting aPicoContainer
, that cascades the visitor also down to all its ComponentAdapter instances.- Specified by:
accept
in interfaceComponentAdapter<T>
- Parameters:
visitor
- the visitor.
-
getDelegate
public ComponentAdapter getDelegate()
Description copied from interface:ComponentAdapter
Component adapters may be nested in a chain, and this method is used to grab the next ComponentAdapter in the chain.- Specified by:
getDelegate
in interfaceComponentAdapter<T>
- Returns:
- the next component adapter in line or null if there is no delegate ComponentAdapter.
-
findAdapterOfType
public <U extends ComponentAdapter> U findAdapterOfType(java.lang.Class<U> adapterType)
Description copied from interface:ComponentAdapter
Locates a component adapter of type componentAdapterType in the ComponentAdapter chain. Will return null if there is no adapter of the given type.- Specified by:
findAdapterOfType
in interfaceComponentAdapter<T>
- Type Parameters:
U
- the type of ComponentAdapter being located.- Parameters:
adapterType
- the class of the adapter type being located. Never null.- Returns:
- the appropriate component adapter of type U. May return null if the component adapter type is not returned.
-
getDescriptor
public java.lang.String getDescriptor()
Description copied from interface:ComponentAdapter
Get a string key descriptor of the component adapter for use in toString()- Specified by:
getDescriptor
in interfaceComponentAdapter<T>
- Returns:
- the descriptor
-
-