Package de.tsl2.nano.util
Class DelegatorProxy
java.lang.Object
de.tsl2.nano.util.DelegatorProxy
- All Implemented Interfaces:
Serializable,InvocationHandler
generic delegator to be usable as base class for simple delegation implementations. the delegator doesn't have to
implement the given interface, but has to provide the desired implementation with a method thats name and arguments
have to match the interface method.
if you give more than one delegator, they will be asked in the given order to have the desired method - to invoke it.
if no delegator provides the called method, the standard proxy implementation will be used.
the delegator is also usable as instance extender on runtime.
example:
public void setBeanFinder(final IBeanFinder<T, Object> beanFinder) {
Object internalBeanFinder = new Object() {
Collection getData(T from, Object to) {
collection = (COLLECTIONTYPE) beanFinder.getData(from, to);
return collection;
};
};
this.beanFinder = DelegatorProxy.delegator(IBeanFinder.class, internalBeanFinder, beanFinder);
}
To work directly on interface implementations, use MultipleInheritanceProxy.- Version:
- $Revision$
- Author:
- Thomas Schneider
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DelegatorProxy
-
-
Method Details
-
invoke
- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-
delegator
delegator- Type Parameters:
T-- Parameters:
proxyInterface-delegators-- Returns:
-
delegator
delegator- Type Parameters:
T-- Parameters:
proxyInterfaces-delegators-- Returns:
-