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 java.lang.Object
implements FutureClient

Abstract implementation of the FutureClient interface.

Version:
1.0
Author:
eipi
See Also:
FutureClient

Field Summary
 AsynchronousReference ar
           
 java.lang.Object[] args
           
 Callback callback
           
 ThreadOp caller
           
protected  Cancelable cancelable
           
 MethodOp method
           
 
Constructor Summary
protected AbstractFutureClient(AsynchronousReference ar, MethodOp method, java.lang.Object[] args, ThreadOp caller, Callback callback)
           
 
Method Summary
 boolean cancel()
          Cancel the operation related to this cancelable object.
 java.lang.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 getCalleeThread()
          Get the thread which is running the method invocation (the "callee").
 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.
 java.lang.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 isCalleeAvailable()
          Test the usable value of the callee thread.
 boolean isCancelled()
          Returns true if the asynchronous method invocation has been cancelled.
 boolean isInterrupted()
          Returns true if the asynchronous method invocation has been interrupted.
 java.lang.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.
 java.lang.Object waitForResult()
          Equivalent to waitForResult(Long.MAX_VALUE).
 java.lang.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.
 boolean waitUntilCalleeAvailable(long timeout)
          Wait until the callee thread become available for a specified amount of time.
 void waitUntilResultAvailable()
          Wait until the result become available.
 void waitUntilStarted()
          Wait until the method is runned by a callee thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface mandala.rami.InvocationObserver
isResultAvailable, isStarted
 
Methods inherited from interface mandala.rami.MethodResult
exceptionOccured, getException, getReturnedResultTrusted
 
Methods inherited from interface mandala.rami.InvocationEventsWaiter
waitUntilResultAvailable, waitUntilStarted
 

Field Detail

ar

public final AsynchronousReference ar

method

public final MethodOp method

args

public final java.lang.Object[] args

caller

public final ThreadOp caller

callback

public final Callback callback

cancelable

protected Cancelable cancelable
Constructor Detail

AbstractFutureClient

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

getAsynchronousReference

public final 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 final 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 final java.lang.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 final 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 final 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

isCalleeAvailable

public final boolean isCalleeAvailable()
Description copied from interface: InvocationObserver

Test the usable value of the callee thread. This method is safe related.

While the callee thread as not yet been set by the implementation of asynchronous method invocation, this method returns false. Otherwise, it returns true.

This method may return true whereas InvocationObserver.getCalleeThread() returns a null value. This situation means that the callee has been set, has executed the method and is no longer available (it has died for example).

Specified by:
isCalleeAvailable in interface InvocationObserver
Returns:
true if the callee thread has been set by the implementation
See Also:
ResultUpdater.setCalleeThread(ThreadOp)

getCalleeThread

public final ThreadOp getCalleeThread()
Description copied from interface: InvocationObserver

Get the thread which is running the method invocation (the "callee"). This method is unsafe related.

While isCalleeAvailable() returns false, the value returned is undefined. Else, the ThreadOp instance referencing the thread which is running the method is returned which can be null if the method is considered terminated.

Specified by:
getCalleeThread in interface InvocationObserver
Returns:
the callee thread.
See Also:
ThreadOp

isCancelled

public final boolean isCancelled()
Description copied from interface: InvocationObserver

Returns true if the asynchronous method invocation has been cancelled. This method is safe related

Specified by:
isCancelled in interface InvocationObserver
Returns:
a boolean value

isInterrupted

public final boolean isInterrupted()
Description copied from interface: InvocationObserver

Returns true if the asynchronous method invocation has been interrupted. This method is safe related

Specified by:
isInterrupted in interface InvocationObserver
Returns:
a boolean value

getReturnedResult

public final java.lang.Object getReturnedResult()
                                         throws java.lang.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:
java.lang.Throwable - The exception thrown during the call.

waitForResult

public final java.lang.Object waitForResult(long timeout)
                                     throws java.lang.Throwable,
                                            TimedOutException,
                                            java.lang.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:
TimedOutException - if the specified timeout expires.
java.lang.Throwable - The exception thrown by the asynchronous method invocation.
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.

waitForResult

public final java.lang.Object waitForResult()
                                     throws java.lang.Throwable,
                                            java.lang.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:
java.lang.InterruptedException - if the thread has been interrupted
java.lang.Throwable - the exception thrown by the asynchronous method invocation.

waitUntilResultAvailable

public final void waitUntilResultAvailable()
                                    throws java.lang.InterruptedException
Description copied from interface: InvocationEventsWaiter

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

Specified by:
waitUntilResultAvailable in interface InvocationEventsWaiter
Throws:
java.lang.InterruptedException

waitForCalleeThread

public final ThreadOp waitForCalleeThread()
                                   throws java.lang.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:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.

waitForCalleeThread

public final ThreadOp waitForCalleeThread(long timeout)
                                   throws java.lang.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:
java.lang.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 final void waitUntilCalleeAvailable()
                                    throws java.lang.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:
java.lang.InterruptedException

waitUntilCalleeAvailable

public final boolean waitUntilCalleeAvailable(long timeout)
                                       throws java.lang.InterruptedException
Description copied from interface: InvocationEventsWaiter

Wait until the callee thread become available for a specified amount of time. This method is safe related.

If the callee is not available, wait timeout before returning.

Specified by:
waitUntilCalleeAvailable in interface InvocationEventsWaiter
Parameters:
timeout - the maximum time to wait in milliseconds (0 means wait for ever).
Returns:
true if the callee thread is available, false if the timeout expires.
Throws:
java.lang.InterruptedException

waitUntilStarted

public final void waitUntilStarted()
                            throws java.lang.InterruptedException
Description copied from interface: InvocationEventsWaiter

Wait until the method is runned by a callee thread. This method is safe related.

Specified by:
waitUntilStarted in interface InvocationEventsWaiter
Throws:
java.lang.InterruptedException

cancel

public final 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 final 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 java.lang.String toString()


Mandala help mailing list