org.hypergraphdb.peer.workflow
Class Activity

java.lang.Object
  extended by org.hypergraphdb.peer.workflow.Activity
Direct Known Subclasses:
FSMActivity, GetInterestsTask, PublishInterestsTask, QueryTaskClient, QueryTaskServer

public abstract class Activity
extends java.lang.Object

An Activity is some task that a peer is currently working one. An activity is always currently in some state.

It is possible to directly extend this class and have complete control over the implementation of the activity simply by handling incoming messages and taking some action at that point in time. This recommended either for very simple P2P scenarios where not much state is maintained, or for very complicated ones that do not fit into the provided framework.

For most cases however, it is probably best to implement the activity as an FSM (a Finite State Machine) that does from state to state based on incoming messages and/or related sub-activities. In this case, the FSMActivity class

Author:
Borislav Iordanov

Constructor Summary
Activity(HyperGraphPeer thisPeer)
           
Activity(HyperGraphPeer thisPeer, java.util.UUID id)
           
 
Method Summary
 java.util.concurrent.Future<ActivityResult> getFuture()
           Return the Future object representing the completion of this activity.
 java.util.UUID getId()
           
 WorkflowState getState()
          Return this activity's workflow state.
 java.lang.String getType()
           Return the type name of this activity.
abstract  void handleMessage(Message message)
           Handle an incoming that was identified as belonging to this activity.
abstract  void initiate()
           Called by the framework to initiate a new activity.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Activity

public Activity(HyperGraphPeer thisPeer)

Activity

public Activity(HyperGraphPeer thisPeer,
                java.util.UUID id)
Method Detail

initiate

public abstract void initiate()

Called by the framework to initiate a new activity. This method is only invoked at the peer initiating the activity. Once an activity has been initiated, its state changes to Started.


handleMessage

public abstract void handleMessage(Message message)

Handle an incoming that was identified as belonging to this activity.

Parameters:
message - The full message.

getState

public final WorkflowState getState()

Return this activity's workflow state.


getFuture

public final java.util.concurrent.Future<ActivityResult> getFuture()

Return the Future object representing the completion of this activity.


getType

public java.lang.String getType()

Return the type name of this activity. By the default to fully-qualified class name is returned. This method can be overridden by sub-classes to provide a short and/or more human-readable type name.


getId

public final java.util.UUID getId()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object