public class DispatchQueueProxy extends 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.< >; } } ); } < > }
Constructor and Description |
---|
DispatchQueueProxy() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
create(Class<T> interfaceClass,
T target,
DispatchQueue queue)
Create an asynchronous dispatch proxy to the target object via the dispatch queue.
|
static <T> T |
create(ClassLoader classLoader,
Class<T> interfaceClass,
T target,
DispatchQueue queue)
Create an asynchronous dispatch proxy to the target object via the dispatch queue.
|
public DispatchQueueProxy()
public static <T> T create(Class<T> interfaceClass, T target, DispatchQueue queue) throws 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 onIllegalArgumentException
public static <T> T create(ClassLoader classLoader, Class<T> interfaceClass, T target, DispatchQueue queue) throws 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 onIllegalArgumentException
Copyright © 2010–2017 FuseSource, Corp.. All rights reserved.