springs.communication
Class FutureResult

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--springs.communication.FutureResult
All Implemented Interfaces:
java.lang.Runnable

public class FutureResult
extends java.lang.Thread

A placeholder for a future result of a message or asynchronous operation.

Author:
Sergio Ilarri Artigas

Field Summary
private  java.lang.String _agentName
          The name of the agent.
private  java.lang.Object[] _args
          The arguments of the method to invoke.
private  boolean _cacheRef
          A boolean indicating whether a reference to the target agent should be cached.
private  java.lang.String _caller
          The name of the caller agent.
private  java.lang.Exception _error
          A possible error thrown during the execution of the asynchronous operation.
private  java.lang.String _methodName
          The name of the method to invoke.
private  java.lang.Object _result
          The result from the invocation.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FutureResult(java.lang.String agentName, java.lang.String methodName, java.lang.Object[] args, boolean cacheRef, java.lang.String caller)
          Constructor.
 
Method Summary
 java.lang.Exception getError()
          Obtains the error that took place during the execution of the asynchronous operation.
 java.lang.Object getResult()
          Obtains the result.
 boolean isResultAvailable()
          Checks whether there is a result available.
 boolean isSuccessful()
          Checks if the asynchronous operation was completed successfully.
 void run()
          The main method.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_result

private java.lang.Object _result
The result from the invocation.

See Also:
String

_methodName

private java.lang.String _methodName
The name of the method to invoke.

See Also:
String

_args

private java.lang.Object[] _args
The arguments of the method to invoke.

See Also:
Object

_error

private java.lang.Exception _error
A possible error thrown during the execution of the asynchronous operation.

See Also:
Exception

_agentName

private java.lang.String _agentName
The name of the agent.

See Also:
String

_cacheRef

private boolean _cacheRef
A boolean indicating whether a reference to the target agent should be cached.


_caller

private java.lang.String _caller
The name of the caller agent.

See Also:
String
Constructor Detail

FutureResult

public FutureResult(java.lang.String agentName,
                    java.lang.String methodName,
                    java.lang.Object[] args,
                    boolean cacheRef,
                    java.lang.String caller)
Constructor.

Parameters:
agentName - the agent's name.
methodName - the name of the method to invoke.
args - the arguments of the method.
cacheRef - a boolean indicating whether a reference to the target agent should be cached.
caller - the name of the caller agent.
See Also:
String, Object
Method Detail

run

public void run()
The main method.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getResult

public java.lang.Object getResult()
Obtains the result. If still not available, it blocks until it is.

Returns:
the result.
See Also:
Object

getError

public java.lang.Exception getError()
Obtains the error that took place during the execution of the asynchronous operation.

Returns:
the error.
See Also:
Exception

isSuccessful

public boolean isSuccessful()
Checks if the asynchronous operation was completed successfully.

Returns:
a boolean indicating that.

isResultAvailable

public boolean isResultAvailable()
Checks whether there is a result available.

Returns:
a boolean indicating whether there is a result available.