Class MultipleInheritanceProxy

java.lang.Object
de.tsl2.nano.util.MultipleInheritanceProxy
All Implemented Interfaces:
InvocationHandler

public class MultipleInheritanceProxy extends Object implements 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 Details

    • MultipleInheritanceProxy

      protected MultipleInheritanceProxy()
      Constructor
    • MultipleInheritanceProxy

      protected MultipleInheritanceProxy(Collection<Object> delegates)
      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 implement
      delegates - 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 extendedImplementation
      extendedImplementation - object to be used as enhancer.
      cast - interface to be returned
      Returns:
      combination of both implementations.
    • getAllInterfaces

      protected static Collection<Class> getAllInterfaces(Class<?> cls)
      getAllInterfaces
      Parameters:
      cls - clazz to evaluate
      Returns:
      all implementing interfaces (of all subclasses)
    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      the first implementing delegate collection member will be used to invoke the given method.
      Specified by:
      invoke in interface InvocationHandler
      Throws:
      Throwable
      See Also:
    • toString

      public String toString()
      toString
      Overrides:
      toString in class Object
      See Also: