org.fusesource.hawtdispatch
Class DispatchQueueProxy

java.lang.Object
  extended by org.fusesource.hawtdispatch.DispatchQueueProxy

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.<>;
             }
          } );
      }
    <>
 }
 

Author:
Hiram Chirino

Constructor Summary
DispatchQueueProxy()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DispatchQueueProxy

public DispatchQueueProxy()
Method Detail

create

public static <T> T create(Class<T> interfaceClass,
                           T target,
                           DispatchQueue queue)
                throws IllegalArgumentException
Create an asynchronous dispatch proxy to the target object via the dispatch queue. The class loader of the generated proxy will be the same as the class loader of the target object.

Type Parameters:
T - the type of the interface class
Parameters:
interfaceClass - the interface that will be implemented by the proxy
target - the delegate object the proxy will asynchronously invoke
queue - the dispatch queue that the asynchronous runnables will execute on
Returns:
the new asynchronous dispatch proxy
Throws:
IllegalArgumentException

create

public static <T> T create(ClassLoader classLoader,
                           Class<T> interfaceClass,
                           T target,
                           DispatchQueue queue)
                throws IllegalArgumentException
Create an asynchronous dispatch proxy to the target object via the dispatch queue.

Type Parameters:
T - the type of the interface asynchronous
Parameters:
classLoader - the classloader which the proxy class should use
interfaceClass - the interface that will be implemented by the proxy
target - the delegate object the proxy will asynchronously invoke
queue - the dispatch queue that the asyncronous runnables will execute on
Returns:
the new asynchronous dispatch proxy
Throws:
IllegalArgumentException


Copyright © 2010-2012 FuseSource, Corp.. All Rights Reserved.