public abstract class AbstractSuperAgent<C extends ClientContext,S extends ServerContext> extends AbstractAgent<C,S> implements SuperAgent<C,S>
isAsync()
flag. Because the agent always contains a SessionId
the server
knows who the actor is.
Note that if the agent is running asynchronously you should implement the
Agent.executeOnServer()
method such that the agent remains cancellable in a well controlled
way. You achieve this by calling the checkCancelled()
method in regular time frames.
Constructor and Description |
---|
AbstractSuperAgent(C clientCtx) |
AbstractSuperAgent(C clientCtx,
boolean isAsync) |
AbstractSuperAgent(ClientConnector conn) |
AbstractSuperAgent(ClientConnector conn,
boolean isAsync) |
Modifier and Type | Method and Description |
---|---|
void |
checkCancelled()
Throws a
CancellationException when the agent was cancelled. |
void |
clearClientParams()
Clears the parameters in the client cache that have been set by this agent.
|
void |
doOnClientSideCancellation()
Is called by the
TaskManager when an AgentId is being cancelled. |
void |
doOnMessageError()
Is called on the client when the received agent contains an error.
|
void |
doOnMessageReceived()
Is called on the client side when the agent has been received in a message.
|
void |
doOnServerSideCancellation()
Is called by the
AgentExecutorTask when a cancellation has been detected. |
void |
executeForResponse()
This method is called on an asynchronous agent only, before it is returned within the
NetResponse.
|
<T> T |
getClientParam(java.lang.String key)
Fetches an agent specific parameter from the client cache.
|
java.util.Map |
getClientParams()
Allows an async agent to store an Agent-specific parameter in a client cache.
|
SessionId |
getKillerSessionId()
Tells which foreign user has cancelled the agent
|
int |
getMessageTimeout()
Returns the async execution timeout
|
java.awt.Color |
getRenderColor() |
javax.swing.Icon |
getRenderIcon() |
java.lang.String |
getRenderText() |
boolean |
hasClientParam(java.lang.String key)
Checks whether an agent specific parameter exists in the client cache.
|
boolean |
isAsync()
Tells whether the agent should be executed asynchroneosly on the server
in which case it is sent back to the client via a NetMessage.
|
boolean |
isIgnoreMessageError()
Tells whether errors are being ignored by the client when the agent is
received in a message.
|
boolean |
isNoReturn()
Tells whether this async agent should never be returned to the sender within a NetMessage.
|
boolean |
isTimedOut()
Tells whether the agent has been cancelled due to an async execution timeout on server side.
|
void |
putClientParam(java.lang.String key,
java.lang.Object value)
Putting a null value results in removing the key
|
<A extends Agent<C,S>> |
sendForSilentExecution()
Same as
Agent.sendForExecution() just without throwing an Exception. |
void |
setAsync(boolean isAsync)
If this flag is set the agent is executed asynchroneosly on the server.
|
void |
setCancelledBy(SessionId killerSessId)
Marks the agent to be cancelled without performing any further
cancel action.
|
void |
setIgnoreMessageError(boolean isIgnoreError)
Allows for suppressing automatic error handling.
|
void |
setMessageTimeout(int seconds)
Defines a timeout in seconds for asynchronous execution on server side before the agent is
returned in a message.
|
void |
setNoReturn(boolean isNoReturn)
Tells whether this async agent should never be returned to the sender within a NetMessage.
|
void |
sleepChecked(long millis)
Used to delay async execution.
|
DumpString |
toDumpString(DumpString s)
This method creates a multi line debug output to display the full content of the agent.
|
ToString |
toString(ToString s)
This method creates a single line debug output to display the most important properties of the agent
|
boolean |
wasCancelled()
Tells whether this agent ever has been tried to be cancelled.
|
createAgentId, doBeforeSend, doFinallyOnClient, doFinallyOnServer, doInitiallyOnClient, doInitiallyOnServer, doOnResponseConfirmed, doOnResponseError, doOnResponseReceived, equals, fetchSession, finished, getAgentId, getArgument, getError, getName, getOwnerSessionId, getPriority, getProcessingDuration, getReceivedTime, getResponseTimeout, getSentTime, getSessionId, getTargetServer, getTaskId, getTotalDuration, getTransferDuration, getZippedArgumentLength, hasError, hashCode, hasRun, isPartialResultsEnabled, isReceived, isReceivedInMessage, isReceivedInResponse, isRejectable, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, sendForBooleanExecution, sendForExecution, setArgument, setArgument, setFailed, setName, setOwnerSessionId, setPartialResultsEnabled, setPriority, setReceivedInMessage, setReceivedTime, setRejectable, setResponseTimeout, setSentTime, setServerContext, setSessionId, setTargetServer
checkOnClient, checkOnServer, getClientContext, getLogChannel, getServerContext, isLogDebug, isLogVerbose, isOnClient, isOnServer, setClientContext, setLogChannel
clone, copy
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
doBeforeSend, doFinallyOnClient, doFinallyOnServer, doInitiallyOnClient, doInitiallyOnServer, doOnResponseConfirmed, doOnResponseError, doOnResponseReceived, executeOnServer, fetchSession, finished, getAgentId, getArgument, getError, getName, getOwnerSessionId, getPriority, getResponseTimeout, getSessionId, getTargetServer, hasError, hasRun, isPartialResultsEnabled, isReceived, isReceivedInMessage, isReceivedInResponse, isRejectable, sendForBooleanExecution, sendForExecution, setArgument, setArgument, setFailed, setName, setOwnerSessionId, setPartialResultsEnabled, setPriority, setReceivedInMessage, setRejectable, setResponseTimeout, setSessionId, setTargetServer
isOnClient, isOnServer, setClientContext, setServerContext
getClientContext
getServerContext
toDumpString, toString
copy
getProcessingDuration, getReceivedTime, getSentTime, getTotalDuration, getTransferDuration, setReceivedTime, setSentTime
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
public AbstractSuperAgent(C clientCtx)
public AbstractSuperAgent(C clientCtx, boolean isAsync)
public AbstractSuperAgent(ClientConnector conn)
public AbstractSuperAgent(ClientConnector conn, boolean isAsync)
public boolean isIgnoreMessageError()
SuperAgent
isIgnoreMessageError
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.setIgnoreMessageError(boolean)
public void setIgnoreMessageError(boolean isIgnoreError)
SuperAgent
setIgnoreMessageError
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.isIgnoreMessageError()
public int getMessageTimeout()
SuperAgent
getMessageTimeout
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public void setMessageTimeout(int seconds)
SuperAgent
AgentExecutionTimeoutException
. A value of zero indicates that infinite execution is allowed.
Note: a default agent async execution timeout may be set as a ServerStartup
parameter
setMessageTimeout
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
ServerStartup.getAsyncAgentTimeout()
public final boolean isTimedOut()
SuperAgent
AgentExecutionTimeoutException
.isTimedOut
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public boolean isAsync()
SuperAgent
isAsync
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.setAsync(boolean)
public void setAsync(boolean isAsync)
SuperAgent
setAsync
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.isAsync()
public void doOnMessageReceived() throws java.lang.Exception
doOnMessageReceived
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
java.lang.Exception
public void doOnMessageError()
doOnMessageError
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public void sleepChecked(long millis)
CancellationException
is thrown just in case.java.util.concurrent.CancellationException
- if cancellation was detected during sleeppublic final void checkCancelled()
CancellationException
when the agent was cancelled.public boolean wasCancelled()
SuperAgent
wasCancelled
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public void setCancelledBy(SessionId killerSessId)
setCancelledBy
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public SessionId getKillerSessionId()
SuperAgent
getKillerSessionId
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public void doOnClientSideCancellation()
SuperAgent
TaskManager
when an AgentId
is being cancelled.
Within this method the agent may perform any client-side reaction on cancellation.
Note that this method is called BEFORE the cancel-request is sent to the server.doOnClientSideCancellation
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public void doOnServerSideCancellation()
SuperAgent
AgentExecutorTask
when a cancellation has been detected.
Within this method the agent may perform any server-side reaction on cancellation.doOnServerSideCancellation
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public boolean isNoReturn()
SuperAgent
isNoReturn
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.setNoReturn(boolean)
public void setNoReturn(boolean isNoReturn)
SuperAgent
setNoReturn
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.setMessageTimeout(int)
,
SuperAgent.isNoReturn()
public void executeForResponse() throws java.lang.Exception
SuperAgent
NetMessage
.
Note that by this way it is possible that an asynchronous agent, which is received in a response, already may have partial results. Further results will be received within a message after the asynchronous execution has finished.
executeForResponse
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
java.lang.Exception
public boolean hasClientParam(java.lang.String key)
SuperAgent
hasClientParam
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public void clearClientParams()
SuperAgent
clearClientParams
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public java.util.Map getClientParams()
SuperAgent
getClientParams
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
public void putClientParam(java.lang.String key, java.lang.Object value)
putClientParam
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.getClientParams()
public <T> T getClientParam(java.lang.String key)
SuperAgent
getClientParam
in interface SuperAgent<C extends ClientContext,S extends ServerContext>
SuperAgent.getClientParams()
public <A extends Agent<C,S>> A sendForSilentExecution()
Agent
Agent.sendForExecution()
just without throwing an Exception. The returned Agent should be
manually checked if it contains an Exception.sendForSilentExecution
in interface Agent<C extends ClientContext,S extends ServerContext>
sendForSilentExecution
in class AbstractAgent<C extends ClientContext,S extends ServerContext>
Agent.sendForExecution()
,
Agent.sendForBooleanExecution()
public javax.swing.Icon getRenderIcon()
getRenderIcon
in interface Renderable
public java.lang.String getRenderText()
getRenderText
in interface Renderable
public java.awt.Color getRenderColor()
getRenderColor
in interface Renderable
public ToString toString(ToString s)
AbstractAgent
toString
in interface Dumpable
toString
in class AbstractAgent<C extends ClientContext,S extends ServerContext>
public DumpString toDumpString(DumpString s)
AbstractAgent
toDumpString
in interface Dumpable
toDumpString
in class AbstractAgent<C extends ClientContext,S extends ServerContext>
Copyright © 2012 EsprIT-Systems. All Rights Reserved.