public class ActivityManager extends java.lang.Object implements MessageHandler
The ActivityManager
manages all activities currently in effect within
a given peer.
Constructor and Description |
---|
ActivityManager(HyperGraphPeer thisPeer) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all internal data structures such as registered activities,
queues of pending actions etc.
|
void |
clearActivities()
Clear all activity-related data structures.
|
Activity |
getActivity(java.util.UUID id)
Retrieve an
Activity by its UUID. |
Activity |
getParent(Activity a) |
void |
handleMessage(Json msg) |
java.util.concurrent.Future<ActivityResult> |
initiateActivity(Activity activity) |
java.util.concurrent.Future<ActivityResult> |
initiateActivity(Activity activity,
Activity parentActivity,
ActivityListener listener)
Initiate a new activity.
|
java.util.concurrent.Future<ActivityResult> |
initiateActivity(Activity activity,
ActivityListener listener) |
void |
registerActivityType(java.lang.Class<? extends Activity> activityClass)
A simplified version of
registerActivityType in which the
type name is taken to be the fully qualified classname of the
activityClass parameter and a DefaultActivityFactory
instance is going to be used to create new activities of that type. |
void |
registerActivityType(java.lang.Class<? extends Activity> activityClass,
ActivityFactory factory)
Register an activity type with an associated factory.
|
void |
registerActivityType(java.lang.String type,
java.lang.Class<? extends Activity> activityClass)
Register an activity type with the specified non-default type name.
|
void |
registerActivityType(java.lang.String type,
java.lang.Class<? extends Activity> activityClass,
ActivityFactory factory)
Register an activity type with the specified non-default type name and
factory.
|
void |
start() |
void |
stop() |
public ActivityManager(HyperGraphPeer thisPeer)
public void start()
public void stop()
public void clear()
Clear all internal data structures such as registered activities, queues of pending actions etc. This method should never be called while the scheduler is currently running.
public void clearActivities()
Clear all activity-related data structures. This method should never be called while the scheduler is currently running. Registered activity types remain so there's no need to re-register and the start method could be called again.
public void registerActivityType(java.lang.Class<? extends Activity> activityClass)
A simplified version of registerActivityType
in which the
type name is taken to be the fully qualified classname of the
activityClass
parameter and a DefaultActivityFactory
instance is going to be used to create new activities of that type.
activityClass
- The class implementing the activity.public void registerActivityType(java.lang.Class<? extends Activity> activityClass, ActivityFactory factory)
Register an activity type with an associated factory. The factory will be used to construct new activity instances based on incoming message.
activityClass
- The class implementing the activity.factory
- The activity factory associated with this type.public void registerActivityType(java.lang.String type, java.lang.Class<? extends Activity> activityClass)
Register an activity type with the specified non-default type name.
type
- The type name.activityClass
- The class that implements the activity.public void registerActivityType(java.lang.String type, java.lang.Class<? extends Activity> activityClass, ActivityFactory factory)
Register an activity type with the specified non-default type name and factory.
type
- The type name.activityClass
- The class that implements the activity.factory
- The activity factory associated with this type.public java.util.concurrent.Future<ActivityResult> initiateActivity(Activity activity)
public java.util.concurrent.Future<ActivityResult> initiateActivity(Activity activity, ActivityListener listener)
public java.util.concurrent.Future<ActivityResult> initiateActivity(Activity activity, Activity parentActivity, ActivityListener listener)
Initiate a new activity.
activity
- parentActivity
- listener
- public void handleMessage(Json msg)
handleMessage
in interface MessageHandler