|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.curjent.impl.agent.MessageFuture
org.curjent.impl.agent.MessageCall
final class MessageCall
Implements AgentCall
on behalf of a message. Returned to clients
instead of a reference to the message in order to avoid synchronization
conflicts (i.e., it is safe for clients to synchronize on the returned
MessageCall
instance but not on a Message
instance). MessageCall instances are passed to listeners via
CallStateListener.callStateChanged(AgentCall, CallState)
in
Message.setState(CallState, CallCompletion, Object, Throwable)
and in
the generated agent proxy for agent interface methods returning
AgentCall
.
Message.getCall()
Field Summary | |
---|---|
private CallStateListener<?>[] |
assigned
Call's assigned state listeners. |
private Object |
data
Client data for this message. |
(package private) CallStateListener<?>[] |
effective
Call's effective state listeners. |
private CallStateListener<?> |
listener
Call's default listener for unassigned state listeners. |
Fields inherited from class org.curjent.impl.agent.MessageFuture |
---|
message |
Constructor Summary | |
---|---|
MessageCall(Message message)
Saves the owning message. |
Methods inherited from class org.curjent.impl.agent.MessageFuture |
---|
cancel, get, get, isCancelled, isDone, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.concurrent.Future |
---|
cancel, get, get, isCancelled, isDone |
Field Detail |
---|
private CallStateListener<?> listener
setCallStateListener(CallStateListener)
private CallStateListener<?>[] assigned
setCallStateListener(CallState, CallStateListener)
CallStateListener<?>[] effective
This is accessed directly by the message's
setState
method and is therefore synchronized on the message's monitor,
as is listener
and assigned
.
setEffectiveListeners(CallStateListener[], CallStateListener, CallStateListener[])
private Object data
setData(Object)
Constructor Detail |
---|
MessageCall(Message message)
Method Detail |
---|
public CallState getState()
Message.getState()
.
getState
in interface AgentCall<Object>
CallState
public CallCompletion getCompletion()
Message.getCompletion()
.
getCompletion
in interface AgentCall<Object>
CallCompletion
public boolean isReentry()
Message.isReentry()
.
isReentry
in interface AgentCall<Object>
public int getArgumentCount()
Message.getArgumentCount()
.
getArgumentCount
in interface AgentCall<Object>
public Object getArgument(int index)
Message.getArgument(int)
.
getArgument
in interface AgentCall<Object>
index
- Index of the argument. The first value is at index
0
and the last at index getArgumentCount() - 1
.public void setArgument(int index, Object value)
Message.setArgument(int, Object)
.
setArgument
in interface AgentCall<Object>
AgentCall.getArgument(int)
public Object getResult()
Message.getResult()
.
getResult
in interface AgentCall<Object>
public void setResult(Object value)
Message.setResult(Object)
.
setResult
in interface AgentCall<Object>
AgentCall.getResult()
public Throwable getException()
Message.getException()
.
getException
in interface AgentCall<Object>
AgentCall.setException(Throwable)
public void setException(Throwable exception)
Message.setException(Throwable)
.
setException
in interface AgentCall<Object>
AgentCall.getException()
public boolean finish()
Message.finish(boolean, boolean, Object, Throwable)
.
finish
in interface AgentCall<Object>
false
if the call was already FINISHED
;
true
in all other cases.AgentCall.setResult(Object)
,
AgentCall.setException(Throwable)
public boolean finish(Object result)
Message.finish(boolean, boolean, Object, Throwable)
.
finish
in interface AgentCall<Object>
result
- The value of the call's result if successfully finished.
May cause this method to throw an exception if the value is invalid. Sets
the result value to the system default value (0
,
false
, \u0000
, etc.) for primitive types
if result
is null
. Ignored for
void
result types with a result
value of
null
.
true
if successfully transitioned to the
FINISHED
state.AgentCall.setResult(Object)
,
AgentCall.setException(Throwable)
,
AgentCall.finish()
,
AgentCall.finish(boolean, boolean, Object, Throwable)
public boolean finish(Throwable exception)
Message.finish(boolean, boolean, Object, Throwable)
.
finish
in interface AgentCall<Object>
exception
- The call's exception value if successfully finished.
This value takes precedence over the result
value; i.e., if
exception
is non-null, it is thrown regardless of the
result
value.
true
if successfully transitioned to the
FINISHED
state.AgentCall.setResult(Object)
,
AgentCall.setException(Throwable)
,
AgentCall.finish()
,
AgentCall.finish(boolean, boolean, Object, Throwable)
public boolean finish(boolean interrupt, boolean abandon, Object result, Throwable exception)
Message.finish(boolean, boolean, Object, Throwable)
.
finish
in interface AgentCall<Object>
interrupt
- If true
and the call is in the
EXECUTING
state with an assigned thread, the executing
thread is interrupted. Ignored if false
.abandon
- If true
and the call is in the
EXECUTING
state, finishes the call and abandons the running
task, leaving it running orphaned in the background. Ignored if
false
.result
- The value of the call's result if successfully finished.
May cause this method to throw an exception if the value is invalid. Sets
the result value to the system default value (0
,
false
, \u0000
, etc.) for primitive types
if result
is null
. Ignored for
void
result types with a result
value of
null
.exception
- The call's exception value if successfully finished.
This value takes precedence over the result
value; i.e., if
exception
is non-null, it is thrown regardless of the
result
value.
true
if successfully transitioned to the
FINISHED
state.public void await() throws InterruptedException
Message.await(CallState, long, TimeUnit)
.
await
in interface AgentCall<Object>
InterruptedException
- The caller's thread was interrupted.public void await(CallState state) throws InterruptedException
Message.await(CallState, long, TimeUnit)
.
await
in interface AgentCall<Object>
state
- Call state to reach or pass.
InterruptedException
- The caller's thread was interrupted.public boolean await(CallState state, long timeout, TimeUnit unit) throws InterruptedException
Message.await(CallState, long, TimeUnit)
.
await
in interface AgentCall<Object>
state
- Call state to reach or pass. For example, if
state
is EXECUTING
, this method waits until the
call's state is either EXECUTING
or FINISHED
.timeout
- The timeout period. 0
or negative to timeout
immediately. Long.MAX_VALUE
to never timeout.unit
- The timeout units. May be null
if
timeout
is 0
or Long.MAX_VALUE
.
true
if the call state was reached or passed.
false
if the call state was not reached when the timeout
period expired.
InterruptedException
- The caller's thread was interrupted.public boolean setExpirationTimeout(long value, TimeUnit unit)
Expirations.setExpirationTimeout(Message, long, TimeUnit)
.
setExpirationTimeout
in interface AgentCall<Object>
Expiration
public long getExpirationTimeoutNanos()
Expirations.getExpirationTimeoutNanos(Message)
.
getExpirationTimeoutNanos
in interface AgentCall<Object>
public CallStateListener<?> getCallStateListener()
getCallStateListener
in interface AgentCall<Object>
AgentCall.setCallStateListener(CallStateListener)
public CallState setCallStateListener(CallStateListener<?> listener)
setCallStateListener
in interface AgentCall<Object>
AgentCall.setCallStateListener(CallState, CallStateListener)
public CallStateListener<?> getCallStateListener(CallState state)
getCallStateListener
in interface AgentCall<Object>
AgentCall.setCallStateListener(CallState, CallStateListener)
public boolean setCallStateListener(CallState state, CallStateListener<?> listener)
true
if the call has already reached or passed the
given state
.
setCallStateListener
in interface AgentCall<Object>
AgentCall.setCallStateListener(CallStateListener)
private void initializeListeners()
private static void setEffectiveListeners(CallStateListener<?>[] effective, CallStateListener<?> listener, CallStateListener<?>[] assigned)
public void run(Runnable runnable)
runnable
. This ensures the agent and message are stable
while runnable
is executing.
run
in interface AgentCall<Object>
runnable
- Object to run.AgentCall.run(Runnable)
public Object getData()
getData
in interface AgentCall<Object>
public void setData(Object data)
setData
in interface AgentCall<Object>
public CallSite getCallSite()
message.info
.
getCallSite
in interface AgentCall<Object>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |