Class AOPProxy<T>

java.lang.Object
de.tsl2.nano.core.util.DelegationHandler<T>
de.tsl2.nano.util.AOPProxy<T>
All Implemented Interfaces:
de.tsl2.nano.core.util.IDelegationHandler<T>, Serializable, Cloneable, InvocationHandler

public class AOPProxy<T> extends de.tsl2.nano.core.util.DelegationHandler<T>
simple proxy to enable aop-like enhancement.
Version:
$Revision$
Author:
Thomas Schneider
See Also:
  • Field Summary

    Fields inherited from class de.tsl2.nano.core.util.DelegationHandler

    delegate, interfaces, properties
  • Constructor Summary

    Constructors
    Constructor
    Description
    AOPProxy(T delegate, de.tsl2.nano.core.execution.ICRunnable<?> before, de.tsl2.nano.core.execution.ICRunnable<?> after, boolean proxyResult)
    constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    static final <T> T
    createEnhancement(T instance, de.tsl2.nano.core.execution.ICRunnable<?> before, de.tsl2.nano.core.execution.ICRunnable<?> after, boolean proxyResult)
    createEnhancement
    invoke(Object proxy, Method method, Object[] args)

    Methods inherited from class de.tsl2.nano.core.util.DelegationHandler

    canDelegate, clone, createProxy, getDelegate, getInterfaces, getMethodArgsId, getProperties, initDeserialization, invokeDelegate, setInterfaces, setProperty, toString

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AOPProxy

      public AOPProxy(T delegate, de.tsl2.nano.core.execution.ICRunnable<?> before, de.tsl2.nano.core.execution.ICRunnable<?> after, boolean proxyResult)
      constructor
      Parameters:
      delegate - original instance
      before - (optional) action to execute. will be run with arguments instance, method, and args - before executing the original method.
      after - (optional) action to execute. will be run with arguments instance, method, and args - after executing the original method.
      proxyResult - whether to wrap the result into a new proxy (recursive).
  • Method Details

    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Specified by:
      invoke in interface InvocationHandler
      Overrides:
      invoke in class de.tsl2.nano.core.util.DelegationHandler<T>
      Throws:
      Throwable
    • createEnhancement

      public static final <T> T createEnhancement(T instance, de.tsl2.nano.core.execution.ICRunnable<?> before, de.tsl2.nano.core.execution.ICRunnable<?> after, boolean proxyResult)
      createEnhancement
      Type Parameters:
      T -
      Parameters:
      instance - delegate
      before - (optional) action to execute. will be run with arguments instance, method, and args - before executing the original method.
      after - (optional) action to execute. will be run with arguments instance, method, and args - after executing the original method.
      proxyResult - whether to wrap the result into a new proxy (recursive).
      Returns: