edu.emory.mathcs.rmix.spi
Class AbstractAsyncInvoker

java.lang.Object
  extended byedu.emory.mathcs.rmix.spi.AbstractInvoker
      extended byedu.emory.mathcs.rmix.spi.AbstractAsyncInvoker
All Implemented Interfaces:
AsyncInvoker, Invoker

public abstract class AbstractAsyncInvoker
extends AbstractInvoker
implements AsyncInvoker

Convenience base class for RMIX providers to implement AsyncInvoker.

The asynchronous invocation modes are implemented by mapping them onto synchronous calls using a thread pool.

Version:
2.0
Author:
Dawid Kurzyniec

Nested Class Summary
static interface AbstractAsyncInvoker.Call
           
static interface AbstractAsyncInvoker.PremarshalledCall
           
 
Field Summary
 
Fields inherited from class edu.emory.mathcs.rmix.spi.AbstractInvoker
interfaces, ref
 
Constructor Summary
protected AbstractAsyncInvoker(Executor engine, RemoteRef ref, java.lang.ClassLoader cloader, boolean resolveAll, BasicAsyncBindParams bindParams)
           
 
Method Summary
protected  java.lang.Object doInvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] params)
           
 Parameters getBindParameters()
          Retrieves parameters associated with this invoker.
 java.lang.Object getParameter(java.lang.String name)
          Gets the value of the provider-specific parameter with a given name.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method m, java.lang.Object[] params)
          Performs the remote method invocation.
 Rmix.Future invokeAsync(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] params)
          Serializes calls on this stub from same client thread.
 Rmix.Future invokeCbAsync(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] params, Callback cb)
          Serializes calls on this stub from same client thread
 void invokeOneWay(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] params)
          Schedules the one-way remote method invocation that offers no indication of completion.
protected abstract  AbstractAsyncInvoker.Call prepareCall(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] params)
          Returns object encapsulating a synchronous remote call.
protected abstract  AbstractAsyncInvoker.PremarshalledCall preparePremarshalledCall(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] params)
          Returns object encapsulating a synchronous, premarshalled remote call.
 void setParameter(java.lang.String name, java.lang.Object value)
          Sets the value of the provider-specific parameter given by name.
 
Methods inherited from class edu.emory.mathcs.rmix.spi.AbstractInvoker
equals, getInterfaces, getRef, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.emory.mathcs.rmix.Invoker
getInterfaces, getRef
 

Constructor Detail

AbstractAsyncInvoker

protected AbstractAsyncInvoker(Executor engine,
                               RemoteRef ref,
                               java.lang.ClassLoader cloader,
                               boolean resolveAll,
                               BasicAsyncBindParams bindParams)
                        throws java.lang.ClassNotFoundException
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method m,
                               java.lang.Object[] params)
                        throws java.lang.Exception
Description copied from interface: Invoker
Performs the remote method invocation. The requested method must belong to one of the interfaces available through #getInterfaces.

Specified by:
invoke in interface Invoker
Specified by:
invoke in class AbstractInvoker
Throws:
java.lang.Exception

doInvoke

protected java.lang.Object doInvoke(java.lang.Object proxy,
                                    java.lang.reflect.Method method,
                                    java.lang.Object[] params)

invokeAsync

public Rmix.Future invokeAsync(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] params)
                        throws java.rmi.RemoteException
Serializes calls on this stub from same client thread.

Specified by:
invokeAsync in interface AsyncInvoker
Parameters:
proxy - the client-side proxy that originated the invocation.
method - the remote method to invoke.
params - invocation parameters.
Returns:
future result of the invocation
Throws:
java.rmi.RemoteException - if the call could not be performed.
To Do:
support for different serialization modes

invokeOneWay

public void invokeOneWay(java.lang.Object proxy,
                         java.lang.reflect.Method method,
                         java.lang.Object[] params)
                  throws java.rmi.RemoteException
Description copied from interface: AsyncInvoker
Schedules the one-way remote method invocation that offers no indication of completion. This method must ensure that params are marshalled or copied before returning, so that subsequent changes to the state of params do not affect the invocation that may be still in progress. The requested method must belong to one of the interfaces available through Invoker.getInterfaces().

Specified by:
invokeOneWay in interface AsyncInvoker
Parameters:
proxy - the client-side proxy that originated the invocation.
method - the remote method to invoke.
params - invocation parameters.
Returns:
the future object that will hold the value returned by the remote method call (or exception thrown by it) once the call completes.
Throws:
java.rmi.RemoteException - if the call could not be performed.

invokeCbAsync

public Rmix.Future invokeCbAsync(java.lang.Object proxy,
                                 java.lang.reflect.Method method,
                                 java.lang.Object[] params,
                                 Callback cb)
                          throws java.rmi.RemoteException
Serializes calls on this stub from same client thread

Specified by:
invokeCbAsync in interface AsyncInvoker
Parameters:
proxy - the client-side proxy that originated the invocation.
method - the remote method to invoke.
params - invocation parameters.
cb - the callback to receive notification once the call completes.
Returns:
future result of the invocation
Throws:
java.rmi.RemoteException - if the call could not be performed.
To Do:
support for different serialization modes

prepareCall

protected abstract AbstractAsyncInvoker.Call prepareCall(java.lang.Object proxy,
                                                         java.lang.reflect.Method method,
                                                         java.lang.Object[] params)
                                                  throws java.rmi.RemoteException
Returns object encapsulating a synchronous remote call. To be implemented by subclasses. The call will be performed in the calling thread in case of synchronous calls, and in some other thread in case of asynchronous calls. The returned callable can include direct references to parameter objects. This is used for synchronous calls, and when "allowUnprotectedMarshal" parameter is set.

Parameters:
proxy - the proxy on which the method has been invoked
method - the method to be invoked
params - method parameters
Returns:
the callable object to carry the blocking call
Throws:
java.rmi.RemoteException

preparePremarshalledCall

protected abstract AbstractAsyncInvoker.PremarshalledCall preparePremarshalledCall(java.lang.Object proxy,
                                                                                   java.lang.reflect.Method method,
                                                                                   java.lang.Object[] params)
                                                                            throws java.rmi.RemoteException
Returns object encapsulating a synchronous, premarshalled remote call. To be implemented by subclasses. The call will be performed in the thread other than the calling thread. Caller must ensure that the asynchronous execution of the returned callable may not be affected by concurrent modifications of the parameter objects' state performed from the caller thread. This can be achieved either by fully serializing parameters into the callable object, or by using a pipe to minimize memory overhead.

Parameters:
proxy - the proxy on which the method has been invoked
method - the method to be invoked
params - method parameters
Returns:
the callable object to carry the blocking call
Throws:
java.rmi.RemoteException

getBindParameters

public Parameters getBindParameters()
Description copied from interface: Invoker
Retrieves parameters associated with this invoker. Binding to this invoker's remote reference using these parameters will create invoker indistinguishable from this one.

Specified by:
getBindParameters in interface Invoker
Overrides:
getBindParameters in class AbstractInvoker

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: Invoker
Sets the value of the provider-specific parameter given by name. Implementations should reject any parameter that they do not support by throwing IllegalParameterException.

Specified by:
setParameter in interface Invoker
Overrides:
setParameter in class AbstractInvoker
See Also:
Invoker.setParameter(java.lang.String, java.lang.Object)

getParameter

public java.lang.Object getParameter(java.lang.String name)
Description copied from interface: Invoker
Gets the value of the provider-specific parameter with a given name.

Specified by:
getParameter in interface Invoker
Overrides:
getParameter in class AbstractInvoker
See Also:
Invoker.setParameter(java.lang.String, java.lang.Object)