public class CatchUpTaskServer extends TaskActivity<CatchUpTaskServer.State>
Modifier and Type | Class and Description |
---|---|
static class |
CatchUpTaskServer.CatchUpTaskServerFactory |
protected static class |
CatchUpTaskServer.State |
endState, startState, stateChangedLatch
Constructor and Description |
---|
CatchUpTaskServer(HyperGraphPeer thisPeer,
java.util.UUID taskId) |
Modifier and Type | Method and Description |
---|---|
void |
handleMessage(Json msg)
Called by the peer interface when a message arrives for this task.
|
createNewConversation, doRun, getPeerInterface, getTaskId, getThisPeer, handleActivity, initiate, registerConversation, registerConversationHandler, sendReply, setTaskId, stateChanged
afterStateChanged, compareAndSetState, getEndState, getStartState, getState, isStopped, run, setState, setStateListener
public CatchUpTaskServer(HyperGraphPeer thisPeer, java.util.UUID taskId)
public void handleMessage(Json msg)
TaskActivity
Called by the peer interface when a message arrives for this task. Can be
overridden by derived TaskActivity
implementations. The
default implementation delegates to the conversation identified by the
CONVERSATION_ID
attribute of the message (if any). If there's
no conversation associated with this message, an attempt to create a new one
is made by calling createNewConversation
which can be overridden
also. If createNewConversation
returns a non-null
Conversation
instance, the conversation is assigned an ID and
registered with this task.
So a task implementation can chose to implement handleMessage
and
respond to messages directly on it own or it can just implement createNewConversation
to delegate the work to conversation implementations. Or it can have a combination
of both like the following pattern:
public void handleMessage(Object msg)
{
if msg should trigger a new conversation between this peer and
the sending peer then
super.handleMessage(msg);
else
respond to msg directly here...
}
public void createNewConversation(Object msg)
{
// handleMessage determined that a new conversation must be started
// so based on the content of the message, create and return
// an appropriate conversation here.
}
handleMessage
in class TaskActivity<CatchUpTaskServer.State>
msg
- The message just received.