mandala.rami
Class AbstractFutureClient

java.lang.Object
  extended bymandala.rami.AbstractFutureClient
All Implemented Interfaces:
Cancelable, FutureClient, InvocationEventsWaiter, InvocationInfo, InvocationObserver, MethodResult

public abstract class AbstractFutureClient
extends Object
implements FutureClient

Abstract implementation of the FutureClient interface.

Version:
1.0
Author:
eipi
See Also:
FutureClient

Field Summary
protected  AsynchronousReference ar
           
protected  Object[] args
           
 Callback callback
           
protected  ThreadOp caller
           
protected  Cancelable cancelable
           
protected  MethodOp method
           
 
Constructor Summary
protected AbstractFutureClient(AsynchronousReference ar, MethodOp method, Object[] args, ThreadOp caller, Callback callback)
           
 
Method Summary
 boolean cancel()
          Cancel the operation related to this cancelable object.
 Object[] getArgs()
          Returns the argument of the method involved in an asynchronous method invocation.
 AsynchronousReference getAsynchronousReference()
          Returns the AsynchronousReference involved in an asynchronous method invocation.
 Callback getCallback()
          Returns the Callback instance to use when the method invocation is considered terminated.
 ThreadOp getCallerThread()
          Get the thread which has been registered has interested in this object.
 MethodOp getMethod()
          Returns the MethodOp involved in an asynchronous method invocation.
 Object getReturnedResult()
          Return the result returned by the call to an asynchronous method invocation.
 boolean interrupt()
          Interrupt the operation related to this cancelable object.
 boolean isStarted()
          Returns true if the asynchronous method invocation is started.
 String toString()
           
 ThreadOp waitForCalleeThread()
          Wait for the thread which is running the method invocation (the "callee") to be set.
 ThreadOp waitForCalleeThread(long timeout)
          Wait for the thread which is running the method invocation (the "callee") to be set for a specified amount of time.
 Object waitForResult()
          Equivalent to waitForResult(Long.MAX_VALUE).
 Object waitForResult(long timeout)
          Wait for the availability of the result of an asynchronous method invocation for a specified amount of time.
 void waitUntilCalleeAvailable()
          Wait until the callee thread become available.
 void waitUntilResultAvailable()
          Wait until the result become available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface mandala.rami.InvocationObserver
getCalleeThread, isCalleeAvailable, isResultAvailable
 
Methods inherited from interface mandala.rami.MethodResult
exceptionOccured, getException, getReturnedResultTrusted
 
Methods inherited from interface mandala.rami.InvocationEventsWaiter
waitUntilCalleeAvailable, waitUntilResultAvailable
 

Field Detail

ar

protected final AsynchronousReference ar

method

protected final MethodOp method

args

protected final Object[] args

caller

protected final ThreadOp caller

callback

public final Callback callback

cancelable

protected Cancelable cancelable
Constructor Detail

AbstractFutureClient

protected AbstractFutureClient(AsynchronousReference ar,
                               MethodOp method,
                               Object[] args,
                               ThreadOp caller,
                               Callback callback)
Method Detail

getAsynchronousReference

public AsynchronousReference getAsynchronousReference()
Description copied from interface: InvocationInfo

Returns the AsynchronousReference involved in an asynchronous method invocation. This method is safe related

The value returned is the asynchronous reference on which the reflective asynchronous invocation of the method returned by getMethod has been performed.

Specified by:
getAsynchronousReference in interface InvocationInfo
Returns:
the AsynchronousReference value

getMethod

public MethodOp getMethod()
Description copied from interface: InvocationInfo

Returns the MethodOp involved in an asynchronous method invocation. This method is safe related

Specified by:
getMethod in interface InvocationInfo
Returns:
the MethodOp involved in an asynchronous method invocation
See Also:
MethodOp

getArgs

public Object[] getArgs()
Description copied from interface: InvocationInfo

Returns the argument of the method involved in an asynchronous method invocation. This method is safe related

Specified by:
getArgs in interface InvocationInfo
Returns:
the argument of the method involved in an asynchronous method invocation

getCallback

public Callback getCallback()
Description copied from interface: InvocationInfo

Returns the Callback instance to use when the method invocation is considered terminated. This method is safe related

Specified by:
getCallback in interface InvocationInfo
Returns:
a Callback value
See Also:
Callback

getCallerThread

public ThreadOp getCallerThread()
Description copied from interface: InvocationInfo

Get the thread which has been registered has interested in this object. This method is safe related.

Implementation may return null if the information has not been set (maybe for efficiency reasons).

Specified by:
getCallerThread in interface InvocationInfo
Returns:
a ThreadOp value

isStarted

public boolean isStarted()
Description copied from interface: InvocationObserver

Returns true if the asynchronous method invocation is started. This method is safe related

If this method returns false, then the asynchronous method invocation has not start its execution. Otherwise, the method may be currently running or terminated.

Specified by:
isStarted in interface InvocationObserver
Returns:
true if this method has started its execution, false otherwise.

getReturnedResult

public Object getReturnedResult()
                         throws Throwable
Description copied from interface: MethodResult

Return the result returned by the call to an asynchronous method invocation. If doesExceptionOccured() returns true, the exception caught is thrown. This method is unsafe related.

Specified by:
getReturnedResult in interface MethodResult
Returns:
the result returned by the call to a asynchronous method invocation.
Throws:
Throwable - The exception thrown during the call.

waitForResult

public Object waitForResult(long timeout)
                     throws Throwable,
                            TimedOutException,
                            InterruptedException
Description copied from interface: InvocationEventsWaiter

Wait for the availability of the result of an asynchronous method invocation for a specified amount of time. This method is safe related.

If an exception occured during the call, it is thrown.

If the specified timeout expires, a TimedOutException is thrown.

Specified by:
waitForResult in interface InvocationEventsWaiter
Returns:
The object returned by the asynchronous method invocation.
Throws:
Throwable - The exception thrown by the asynchronous method invocation.
InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
TimedOutException - if the specified timeout expires.

waitForResult

public Object waitForResult()
                     throws Throwable,
                            InterruptedException
Description copied from interface: InvocationEventsWaiter

Equivalent to waitForResult(Long.MAX_VALUE). This method is safe related.

Specified by:
waitForResult in interface InvocationEventsWaiter
Returns:
The object returned by the asynchronous method invocation.
Throws:
Throwable - the exception thrown by the asynchronous method invocation.
InterruptedException - if the thread has been interrupted

waitUntilResultAvailable

public void waitUntilResultAvailable()
                              throws InterruptedException
Description copied from interface: InvocationEventsWaiter

Wait until the result become available. This method is safe related.

Specified by:
waitUntilResultAvailable in interface InvocationEventsWaiter
Throws:
InterruptedException

waitForCalleeThread

public ThreadOp waitForCalleeThread(long timeout)
                             throws TimedOutException,
                                    InterruptedException
Description copied from interface: InvocationEventsWaiter

Wait for the thread which is running the method invocation (the "callee") to be set for a specified amount of time. This method is safe related.

If the callee has not yet been set, wait timeout before returning the result.

Specified by:
waitForCalleeThread in interface InvocationEventsWaiter
Parameters:
timeout - the maximum time to wait in milliseconds (0 means wait for ever).
Returns:
the callee thread.
Throws:
InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
TimedOutException

waitForCalleeThread

public ThreadOp waitForCalleeThread()
                             throws InterruptedException
Description copied from interface: InvocationEventsWaiter

Wait for the thread which is running the method invocation (the "callee") to be set. This method is safe related.

Specified by:
waitForCalleeThread in interface InvocationEventsWaiter
Returns:
the callee thread.
Throws:
InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.

waitUntilCalleeAvailable

public void waitUntilCalleeAvailable()
                              throws InterruptedException
Description copied from interface: InvocationEventsWaiter

Wait until the callee thread become available. This method is safe related.

Specified by:
waitUntilCalleeAvailable in interface InvocationEventsWaiter
Throws:
InterruptedException

cancel

public boolean cancel()
Description copied from interface: Cancelable

Cancel the operation related to this cancelable object.

This method does nothing if the related operation is already started or terminated.

This method returns true if the related operation has been succesfully cancelled, false otherwise.

Specified by:
cancel in interface Cancelable
Returns:
true if the related operation has been succesfully cancelled, false otherwise

interrupt

public boolean interrupt()
Description copied from interface: Cancelable

Interrupt the operation related to this cancelable object.

Interruption of an operation means that the thread which is running the related operation is interrupted. It is the responsibilty of the operation to check the interrupt status of the current thread (see Thread.interrupted() in order to be able to return as soon as possible on interruption.

This method does nothing if the related operation is not started yet or if it is already terminated.

This method returns true if the related operation has been succesfully interrupted, false otherwise.

Specified by:
interrupt in interface Cancelable
Returns:
true if the related operation has been succesfully interrupted, false otherwise.

toString

public String toString()


Mandala help mailing list