Package de.tsl2.nano.util
Class MultipleInheritanceProxy
java.lang.Object
de.tsl2.nano.util.MultipleInheritanceProxy
- All Implemented Interfaces:
InvocationHandler
simple proxy mechanism to enhance implemenations through additional interfaces and their delegates. the order of the
delegates will define the priority of the delegates. each delegate will be asked, if it implement the
interface-method.
To work on delegator not directly implementing this interfaces, use
DelegatorProxy.- Version:
- $Revision: 1.0 $
- Author:
- ts 26.02.2010
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructorprotectedMultipleInheritanceProxy(Collection<Object> delegates) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic final <T> TcreateEnhancedPresenter(Object instanceToEnhance, Object extendedImplementation, Class<T> cast, ClassLoader classLoader) combines two instances into one.static ObjectcreateMultipleInheritance(Class[] interfazes, Collection delegates, ClassLoader classLoader) creates a new proxy instance with BeanProxy as invocationhandler.protected static Collection<Class>getAllInterfaces(Class<?> cls) getAllInterfacesthe first implementing delegate collection member will be used to invoke the given method.toString()toString
-
Constructor Details
-
MultipleInheritanceProxy
protected MultipleInheritanceProxy()Constructor -
MultipleInheritanceProxy
Constructor- Parameters:
delegates- see delegates
-
-
Method Details
-
createMultipleInheritance
public static Object createMultipleInheritance(Class[] interfazes, Collection delegates, ClassLoader classLoader) creates a new proxy instance with BeanProxy as invocationhandler.- Parameters:
interfazes- interfaces to implementdelegates- implementation instances. the order is important!classloader- classloader to use the interfaces and instances- Returns:
- implementation of the given interfaces.
-
createEnhancedPresenter
public static final <T> T createEnhancedPresenter(Object instanceToEnhance, Object extendedImplementation, Class<T> cast, ClassLoader classLoader) combines two instances into one.- Parameters:
instanceToEnhance- object to enhance with functionality of extendedImplementationextendedImplementation- object to be used as enhancer.cast- interface to be returned- Returns:
- combination of both implementations.
-
getAllInterfaces
getAllInterfaces- Parameters:
cls- clazz to evaluate- Returns:
- all implementing interfaces (of all subclasses)
-
invoke
the first implementing delegate collection member will be used to invoke the given method.- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable- See Also:
-
toString
toString
-