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, setTargetServercheckOnClient, checkOnServer, getClientContext, getLogChannel, getServerContext, isLogDebug, isLogVerbose, isOnClient, isOnServer, setClientContext, setLogChannelclone, copyconfigureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitdoBeforeSend, 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, setTargetServerisOnClient, isOnServer, setClientContext, setServerContextgetClientContextgetServerContexttoDumpString, toStringcopygetProcessingDuration, getReceivedTime, getSentTime, getTotalDuration, getTransferDuration, setReceivedTime, setSentTimegetLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannelpublic AbstractSuperAgent(C clientCtx)
public AbstractSuperAgent(C clientCtx, boolean isAsync)
public AbstractSuperAgent(ClientConnector conn)
public AbstractSuperAgent(ClientConnector conn, boolean isAsync)
public boolean isIgnoreMessageError()
SuperAgentisIgnoreMessageError in interface SuperAgent<C extends ClientContext,S extends ServerContext>SuperAgent.setIgnoreMessageError(boolean)public void setIgnoreMessageError(boolean isIgnoreError)
SuperAgentsetIgnoreMessageError in interface SuperAgent<C extends ClientContext,S extends ServerContext>SuperAgent.isIgnoreMessageError()public int getMessageTimeout()
SuperAgentgetMessageTimeout in interface SuperAgent<C extends ClientContext,S extends ServerContext>public void setMessageTimeout(int seconds)
SuperAgentAgentExecutionTimeoutException. 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()
SuperAgentAgentExecutionTimeoutException.isTimedOut in interface SuperAgent<C extends ClientContext,S extends ServerContext>public boolean isAsync()
SuperAgentisAsync in interface SuperAgent<C extends ClientContext,S extends ServerContext>SuperAgent.setAsync(boolean)public void setAsync(boolean isAsync)
SuperAgentsetAsync 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.Exceptionpublic 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()
SuperAgentwasCancelled 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()
SuperAgentgetKillerSessionId in interface SuperAgent<C extends ClientContext,S extends ServerContext>public void doOnClientSideCancellation()
SuperAgentTaskManager 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()
SuperAgentAgentExecutorTask 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()
SuperAgentisNoReturn in interface SuperAgent<C extends ClientContext,S extends ServerContext>SuperAgent.setNoReturn(boolean)public void setNoReturn(boolean isNoReturn)
SuperAgentsetNoReturn in interface SuperAgent<C extends ClientContext,S extends ServerContext>SuperAgent.setMessageTimeout(int),
SuperAgent.isNoReturn()public void executeForResponse()
throws java.lang.Exception
SuperAgentNetMessage.
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.Exceptionpublic boolean hasClientParam(java.lang.String key)
SuperAgenthasClientParam in interface SuperAgent<C extends ClientContext,S extends ServerContext>public void clearClientParams()
SuperAgentclearClientParams in interface SuperAgent<C extends ClientContext,S extends ServerContext>public java.util.Map getClientParams()
SuperAgentgetClientParams 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)
SuperAgentgetClientParam in interface SuperAgent<C extends ClientContext,S extends ServerContext>SuperAgent.getClientParams()public <A extends Agent<C,S>> A sendForSilentExecution()
AgentAgent.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 Renderablepublic java.lang.String getRenderText()
getRenderText in interface Renderablepublic java.awt.Color getRenderColor()
getRenderColor in interface Renderablepublic ToString toString(ToString s)
AbstractAgenttoString in interface DumpabletoString in class AbstractAgent<C extends ClientContext,S extends ServerContext>public DumpString toDumpString(DumpString s)
AbstractAgenttoDumpString in interface DumpabletoDumpString in class AbstractAgent<C extends ClientContext,S extends ServerContext>Copyright © 2012 EsprIT-Systems. All Rights Reserved.