|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.picocontainer.behaviors.AbstractBehavior<T>
org.picocontainer.gems.behaviors.Assimilated<T>
public final class Assimilated<T>
ComponentAdapter that assimilates a component for a specific type.
Allows the instance of another ComponentAdapter
to be converted into interface type
, that the
instance is not assignable from. In other words the instance of the delegated adapter does NOT necessarily implement the
type
interface.
For Example:
public interface Foo {
int size();
}
public class Bar {
public int size() {
return 1;
}
}
new Assimilated(Foo.class, new InstanceAdapter(new Bar()));
Notice how Bar does not implement the interface Foo. But Bar does have an identical size()
method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter |
---|
ComponentAdapter.NOTHING |
Field Summary |
---|
Fields inherited from class org.picocontainer.behaviors.AbstractBehavior |
---|
delegate |
Constructor Summary | |
---|---|
Assimilated(Class<T> type,
ComponentAdapter delegate)
Construct an Assimilated. |
|
Assimilated(Class<T> type,
ComponentAdapter delegate,
ProxyFactory proxyFactory)
Construct an Assimilated. |
Method Summary | |
---|---|
Class<T> |
getComponentImplementation()
Return the type of the component. |
T |
getComponentInstance(PicoContainer container,
Type into)
Create and return a component instance. |
Object |
getComponentKey()
Return the key of the component. |
String |
getDescriptor()
Get a string key descriptor of the component adapter. |
Methods inherited from class org.picocontainer.behaviors.AbstractBehavior |
---|
accept, changeMonitor, componentHasLifecycle, currentMonitor, dispose, dispose, findAdapterOfType, getComponentInstance, getDelegate, hasLifecycle, start, start, stop, stop, toString, verify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Assimilated(Class<T> type, ComponentAdapter delegate, ProxyFactory proxyFactory) throws PicoCompositionException
type
may not implement the type of the component instance.
If the component instance does implement the interface, no proxy is used though.
type
- The class type used as key.delegate
- The delegated ComponentAdapter
.proxyFactory
- The ProxyFactory
to use.
PicoCompositionException
- Thrown if the type
is not compatible and cannot be proxied.public Assimilated(Class<T> type, ComponentAdapter delegate)
type
may not implement the type of the component instance.
The implementation will use JDK Proxy
instances. If the component instant does
implement the interface, no proxy is used anyway.
type
- The class type used as key.delegate
- The delegated ComponentAdapter
.Method Detail |
---|
public T getComponentInstance(PicoContainer container, Type into) throws PicoCompositionException
getComponentInstance
in interface ComponentAdapter<T>
getComponentInstance
in class AbstractBehavior<T>
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.AbstractBehavior#getComponentInstance(org.picocontainer.PicoContainer, java.lang.Class into)
public String getDescriptor()
ComponentAdapter
public Class<T> getComponentImplementation()
getComponentImplementation
in interface ComponentAdapter<T>
getComponentImplementation
in class AbstractBehavior<T>
AbstractBehavior.getComponentImplementation()
public Object getComponentKey()
getComponentKey
in interface ComponentAdapter<T>
getComponentKey
in class AbstractBehavior<T>
AbstractBehavior.getComponentKey()
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |