|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.picocontainer.defaults.DecoratingComponentAdapter
org.picocontainer.gems.adapters.AssimilatingComponentAdapter
public class AssimilatingComponentAdapter
ComponentAdapter, that assimilates a component for a specific type.
Allows the instance of another ComponentAdapter
to be converted into interfacte 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 AssimilatingComponentAdapter(Foo.class, new InstanceComponentAdapter(new Bar()));
Notice how Bar does not implement the interface Foo. But Bar does have an identical size()
method.
Field Summary | |
---|---|
private boolean |
isCompatible
|
private com.thoughtworks.proxy.ProxyFactory |
proxyFactory
|
private java.lang.Class |
type
|
Constructor Summary | |
---|---|
AssimilatingComponentAdapter(java.lang.Class type,
org.picocontainer.ComponentAdapter delegate)
Construct an AssimilatingComponentAdapter. |
|
AssimilatingComponentAdapter(java.lang.Class type,
org.picocontainer.ComponentAdapter delegate,
com.thoughtworks.proxy.ProxyFactory proxyFactory)
Construct an AssimilatingComponentAdapter. |
Method Summary | |
---|---|
java.lang.Class |
getComponentImplementation()
Return the type of the component. |
java.lang.Object |
getComponentInstance(org.picocontainer.PicoContainer container)
Create and return a component instance. |
java.lang.Object |
getComponentKey()
Return the key of the component. |
Methods inherited from class org.picocontainer.defaults.DecoratingComponentAdapter |
---|
accept, changeMonitor, currentMonitor, dispose, dispose, getDelegate, hasLifecycle, hasLifecycle, start, start, stop, stop, toString, verify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.Class type
private com.thoughtworks.proxy.ProxyFactory proxyFactory
private boolean isCompatible
Constructor Detail |
---|
public AssimilatingComponentAdapter(java.lang.Class type, org.picocontainer.ComponentAdapter delegate, com.thoughtworks.proxy.ProxyFactory proxyFactory) throws org.picocontainer.PicoIntrospectionException
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.
org.picocontainer.PicoIntrospectionException
- Thrown if the type
is not compatible and cannot be proxied.public AssimilatingComponentAdapter(java.lang.Class type, org.picocontainer.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 java.lang.Object getComponentInstance(org.picocontainer.PicoContainer container) throws org.picocontainer.PicoInitializationException, org.picocontainer.PicoIntrospectionException
getComponentInstance
in interface org.picocontainer.ComponentAdapter
getComponentInstance
in class org.picocontainer.defaults.DecoratingComponentAdapter
org.picocontainer.PicoInitializationException
org.picocontainer.PicoIntrospectionException
DecoratingComponentAdapter.getComponentInstance(org.picocontainer.PicoContainer)
public java.lang.Class getComponentImplementation()
getComponentImplementation
in interface org.picocontainer.ComponentAdapter
getComponentImplementation
in class org.picocontainer.defaults.DecoratingComponentAdapter
DecoratingComponentAdapter.getComponentImplementation()
public java.lang.Object getComponentKey()
getComponentKey
in interface org.picocontainer.ComponentAdapter
getComponentKey
in class org.picocontainer.defaults.DecoratingComponentAdapter
DecoratingComponentAdapter.getComponentKey()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |