Package jadex.bytecode
Class Proxy
java.lang.Object
jadex.bytecode.Proxy
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Map
<jadex.common.Tuple2<ClassLoader, Set<Class<?>>>, Class<?>> static final AtomicInteger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static org.objectweb.asm.tree.MethodNode
genrateInvocationCode
(org.objectweb.asm.tree.MethodNode m, String classname, Class<?> iface, ClassLoader loader) Generate the code for delegating the call to the invocation handler.static InvocationHandler
getInvocationHandler
(Object proxy) Get the invocation handler of a proxy.static void
Main for testing.static Object
newProxyInstance
(ClassLoader loader, Class<?>[] ifaces, InvocationHandler handler) Generate a proxy for an existing class.static Object
newProxyInstance
(ClassLoader loader, Class<?> clazz, Class<?>[] ifaces, InvocationHandler handler) Generate a proxy for an existing class.
-
Field Details
-
OBJECTMETHODS
-
COUNTER
-
CLASSCACHE
-
-
Constructor Details
-
Proxy
public Proxy()
-
-
Method Details
-
getInvocationHandler
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
Main for testing.- Throws:
Exception
-