Class Proxy

java.lang.Object
jadex.bytecode.Proxy

public class Proxy extends Object
Proxy class allows for generating proxy objects for interfaces and/or one class. Both sides are optional. Uses the InvocationHandler from standard Java interface proxy mechanism.
  • Field Details

  • Constructor Details

    • Proxy

      public Proxy()
  • Method Details

    • getInvocationHandler

      public static InvocationHandler getInvocationHandler(Object proxy)
      Get the invocation handler of a proxy.
      Parameters:
      proxy -
      Returns:
      The handler
    • newProxyInstance

      public static Object newProxyInstance(ClassLoader loader, Class<?>[] ifaces, InvocationHandler handler)
      Generate a proxy for an existing class.
      Parameters:
      loader - The class loader.
      ifaces - The interfaces (may contain one clazz).
      handler - The invocation handler.
      Returns:
      The new proxy extending the clazz and implementing all interfaces.
    • newProxyInstance

      public static Object newProxyInstance(ClassLoader loader, Class<?> clazz, Class<?>[] ifaces, InvocationHandler handler)
      Generate a proxy for an existing class.
      Parameters:
      loader - The class loader.
      clazz - The clazz.
      ifaces - The interfaces.
      handler - The invocation handler.
      Returns:
      The new proxy extending the clazz and implementing all interfaces.
    • genrateInvocationCode

      protected static org.objectweb.asm.tree.MethodNode genrateInvocationCode(org.objectweb.asm.tree.MethodNode m, String classname, Class<?> iface, ClassLoader loader) throws Exception
      Generate the code for delegating the call to the invocation handler.
      Parameters:
      m - The methodnode.
      classname - The class name.
      iface - The interface (null means the class is owner of the method)
      Returns:
      The new method node (or null).
      Throws:
      Exception
    • main

      public static void main(String[] args) throws Exception
      Main for testing.
      Throws:
      Exception