public class DispatchQueueProxy
extends java.lang.Object
This class creates proxy objects that allow you to easily service all
method calls to an interface via a DispatchQueue.
The general idea is that proxy asynchronously invoke the delegate using the dispatch queue. The proxy implementation is generated using ASM using the following code generation pattern:
class <>$__ACTOR_PROXY__ implements < > { private final < > target; private final DispatchQueue queue; public < >$__ACTOR_PROXY__(< > target, DispatchQueue queue) { this.target = target; this.queue = queue; } < > < > { queue.execute( new Runnable() { public void run() { this.target.< >; } } ); } < > }
| Modifier and Type | Class and Description |
|---|---|
private static class |
DispatchQueueProxy.Generator<T> |
| Constructor and Description |
|---|
DispatchQueueProxy() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
create(java.lang.Class<T> interfaceClass,
T target,
DispatchQueue queue)
Create an asynchronous dispatch proxy to the target object via the dispatch queue.
|
static <T> T |
create(java.lang.ClassLoader classLoader,
java.lang.Class<T> interfaceClass,
T target,
DispatchQueue queue)
Create an asynchronous dispatch proxy to the target object via the dispatch queue.
|
private static <T> java.lang.Class<T> |
getProxyClass(java.lang.ClassLoader loader,
java.lang.Class<T> interfaceClass) |
private static java.lang.String |
proxyName(java.lang.Class<?> clazz) |
public static <T> T create(java.lang.Class<T> interfaceClass,
T target,
DispatchQueue queue)
throws java.lang.IllegalArgumentException
T - the type of the interface classinterfaceClass - the interface that will be implemented by the proxytarget - the delegate object the proxy will asynchronously invokequeue - the dispatch queue that the asynchronous runnables will execute onjava.lang.IllegalArgumentExceptionpublic static <T> T create(java.lang.ClassLoader classLoader,
java.lang.Class<T> interfaceClass,
T target,
DispatchQueue queue)
throws java.lang.IllegalArgumentException
T - the type of the interface asynchronousclassLoader - the classloader which the proxy class should useinterfaceClass - the interface that will be implemented by the proxytarget - the delegate object the proxy will asynchronously invokequeue - the dispatch queue that the asyncronous runnables will execute onjava.lang.IllegalArgumentExceptionprivate static <T> java.lang.Class<T> getProxyClass(java.lang.ClassLoader loader,
java.lang.Class<T> interfaceClass)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionprivate static java.lang.String proxyName(java.lang.Class<?> clazz)