public interface Agent<C extends ClientContext,S extends ServerContext> extends CrossPlatformObject<C,S>, TimeMeasurable, SimpleLogSupport
NetRequest
to the server for execution by calling
one of its send... methods. The Agent must contain everything that is needed for execution on
server side (i.e. processing arguments). The server processes it and sends it back to the client
within the NetResponse
.
The client checks the received agent for error. If it contains any, the error is handled by the
client's AgentErrorAdapter
. Otherwise the agent is
postprocessed by calling it's doOnResponseReceived()
method.
Modifier and Type | Method and Description |
---|---|
void |
clearClientParams()
Clears the parameters in the client cache that have been set by this agent.
|
void |
doFinallyOnClient()
This method is called on the client, after the agent has completely been processed.
|
void |
doFinallyOnServer()
This method is called on the server, just before the agent is sent backt to the client.
|
void |
doInitiallyOnClient()
Is executed just before the agent is being sent to the server.
|
void |
doInitiallyOnServer()
This method is called on the server, when the agent is received by the server.
|
void |
doOnResponseConfirmed()
Is called on an agent when it was received in a
NetResponse AFTER the response
has been confirmed to the server. |
void |
doOnResponseError()
Processes the error contained in the agent received in a response.
|
void |
doOnResponseReceived()
Is called on an agent when it was received in a
NetResponse but yet
BEFORE the response was confirmed to the server. |
void |
executeOnServer()
This is the agent's main execution method called on the server.
|
AgentId |
getAgentId()
Returns a server side unique identifier.
|
java.lang.Object |
getArgument()
Returns the optional argument of this agent.
|
<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.
|
java.lang.Exception |
getError()
Returns the Exception that may have been raised during agent execution on the server.
|
java.lang.String |
getName()
Returns a meaningful name for debugging purposes.
|
SessionId |
getOwnerSessionId()
Return the SessionId of the actual originator client which is always a normal client (NOT a
CoClient).
|
int |
getPriority()
Returns the thread priority which is used to execute this agent
|
int |
getResponseTimeout()
Returns the desired timeout (in seconds) that should apply to this agent, or 0 if no timeout
should be used.
|
SessionId |
getSessionId()
Returns the SessionId of the sender of this agent.
|
java.lang.String |
getTargetServer()
Returns the target server if one is set.
|
boolean |
hasClientParam(java.lang.String key)
Checks whether an agent specific parameter exists in the client cache.
|
boolean |
hasError()
Tells whether the agent had an Exception during execution on server side.
|
boolean |
hasRun()
Tells whether this agent has been executed on the server.
|
boolean |
isPartialResultsEnabled()
Tells whether the agent supports partial results.
|
boolean |
isReceived()
Tells whether this agent yet has been received by the client.
|
boolean |
isReceivedInMessage()
Returns true if the agent has been received within a message.
|
boolean |
isReceivedInResponse()
Returns true if the agent has been received within a response.
|
boolean |
isRejectable()
Tells whether this agent can be rejected when the server is on heavy load.
|
void |
putClientParam(java.lang.String key,
java.lang.Object value)
Puts an agent specific parameter into client cache.
|
boolean |
sendForBooleanExecution()
Same as
sendForExecution() but does not return the agent, rather it returns true if
the agent has successfully being processed, false otherwise. |
<A extends Agent<C,S>> |
sendForExecution()
Sends the agent to the server for execution and returns the readily processed agent.
|
<A extends Agent<C,S>> |
sendForSilentExecution()
Same as
sendForExecution() just without throwing an Exception. |
void |
setArgument(java.lang.Object arg)
Besides any internal variables the agent may optionally carry an arbitrary argument.
|
void |
setArgument(java.lang.Object arg,
boolean isZip)
Same as setArgument(Object) but compresses the argument to a zipped byte array.
|
void |
setFailed(java.lang.Exception error)
Sets the internal Exception of the Agent.
|
void |
setFinished()
Is called by the server to mark this agent as being processed and stores the processing
duration.
|
void |
setName(java.lang.String agentName)
Sets a meaningful name for debugging purposes.
|
void |
setOwnerSessionId(SessionId origSessId)
Sets the sessionId of the user who creates the agent
|
void |
setPartialResultsEnabled(boolean isEnabled)
Tells whether the agent supports partial results.
|
void |
setPriority(int priority)
Sets the thread priority which is used to execute this agent
|
void |
setReceivedInMessage(boolean state)
Is set when this agent has been received within a message
|
void |
setRejectable(boolean state)
If set to false, then the agent cannot be rejected by the server even if the server is on
heavy load.
|
void |
setResponseTimeout(int seconds)
Sets the response timeout (in seconds) that should apply to this agent.
|
void |
setSessionId(SessionId sessId)
Allows for setting the SessionId of this agent
|
void |
setTargetServer(java.lang.String targetServer)
Sets the target server.
|
isOnClient, isOnServer, setClientContext, setServerContext
getClientContext
getServerContext
toDumpString, toDumpString, toString, toString
deepClone
getProcessingDuration, getReceivedTime, getSentTime, getTotalDuration, getTransferDuration, setReceivedTime, setSentTime
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
SessionId getSessionId()
setSessionId(SessionId)
,
getOwnerSessionId()
void setSessionId(SessionId sessId)
getSessionId()
AgentId getAgentId()
void setArgument(java.lang.Object arg)
void setArgument(java.lang.Object arg, boolean isZip)
java.lang.Object getArgument()
java.lang.String getName()
void setName(java.lang.String agentName)
int getResponseTimeout()
setResponseTimeout(int)
void setResponseTimeout(int seconds)
getResponseTimeout()
void doInitiallyOnClient() throws java.lang.Exception
java.lang.Exception
void doFinallyOnClient() throws java.lang.Exception
Note: If the client has got a GUI, this method runs in the EventDispatcher Thread.
java.lang.Exception
void doInitiallyOnServer() throws java.lang.Exception
java.lang.Exception
void doFinallyOnServer() throws java.lang.Exception
java.lang.Exception
void doOnResponseReceived() throws java.lang.Exception
NetResponse
but yet
BEFORE the response was confirmed to the server.java.lang.Exception
void doOnResponseConfirmed() throws java.lang.Exception
NetResponse
AFTER the response
has been confirmed to the server.java.lang.Exception
void doOnResponseError()
void executeOnServer() throws java.lang.Exception
java.lang.Exception
void setFinished()
boolean hasRun()
hasError()
boolean isReceived()
boolean isReceivedInResponse()
boolean isReceivedInMessage()
setReceivedInMessage(boolean)
void setReceivedInMessage(boolean state)
isReceivedInMessage()
boolean isPartialResultsEnabled()
setPartialResultsEnabled(boolean)
void setPartialResultsEnabled(boolean isEnabled)
isPartialResultsEnabled()
boolean hasError()
getError()
java.lang.Exception getError()
hasError()
whether an Exception exists in the agent.setFailed(Exception)
,
hasError()
int getPriority()
void setPriority(int priority)
void setFailed(java.lang.Exception error)
getError()
,
hasError()
<A extends Agent<C,S>> A sendForExecution() throws java.lang.Exception
java.lang.Exception
- on failuresendForSilentExecution()
,
sendForBooleanExecution()
<A extends Agent<C,S>> A sendForSilentExecution()
sendForExecution()
just without throwing an Exception. The returned Agent should be
manually checked if it contains an Exception.sendForExecution()
,
sendForBooleanExecution()
boolean sendForBooleanExecution()
sendForExecution()
but does not return the agent, rather it returns true if
the agent has successfully being processed, false otherwise. In the case of agent processing
failure the error Exception is stored in the original input agent and can be requested from
there.sendForExecution()
,
sendForSilentExecution()
java.lang.String getTargetServer()
setTargetServer(String)
void setTargetServer(java.lang.String targetServer)
Note that target server routing is not supported for async agents.
getTargetServer()
SessionId getOwnerSessionId()
void setOwnerSessionId(SessionId origSessId)
void setRejectable(boolean state)
boolean isRejectable()
java.util.Map getClientParams()
void putClientParam(java.lang.String key, java.lang.Object value)
getClientParams()
<T> T getClientParam(java.lang.String key)
getClientParams()
void clearClientParams()
boolean hasClientParam(java.lang.String key)
Copyright © 2014 EsprIT-Systems. All Rights Reserved.