public class SingleEventCollector extends Activity
SingleEventCollector is an Activity that just waits for a single event, and saves it. It provides a
method waitForEvent(), to be used by other activities, to collect the event and block until it arrives, after which
the SingleEventCollector will finish.| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SingleEventCollector(AbstractContext c)
Constructs a
SingleEventCollector with the specified activity context. |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup(Constellation c)
The implementation of this method is called when the activity is finished.
|
int |
initialize(Constellation c)
The implementation of this method should perform the initial processing when the activity is first activated.
|
boolean |
isFinished()
This method returns whether the event collector is finished, without blocking.
|
int |
process(Constellation c,
Event e)
The implementation of this method is called when an event is received for this activity.
|
java.lang.String |
toString() |
Event |
waitForEvent()
This method blocks waiting for this object to receive an event.
|
expectsEvents, getContext, identifier, mayBeStolen, setIdentifierpublic SingleEventCollector(AbstractContext c)
SingleEventCollector with the specified activity context. Note: this is an activity that will
receive events (see Activity.Activity(AbstractContext, boolean)).c - the activity context of this event collectorpublic int initialize(Constellation c)
ActivityActivity.SUSPEND or Activity.FINISH, depending on what the activity is to do next:
Activity.SUSPEND when it wants to wait for events, and Activity.FINISH when it is done.
Note that this method does not throw checked exceptions. It can, however, throw runtime exceptions or errors, and the
Constellation running this Activity will deal with that.initialize in class Activityc - the Constellation on which the Activity is runningFINISH if this Activity is done or SUSPEND if this Activity expects events.public int process(Constellation c, Event e)
ActivityActivity.SUSPEND or Activity.FINISH, depending on what the activity is to do next: Activity.SUSPEND when it
expects other events, and Activity.FINISH when it is done.
This method is invoked once at a time, even if more events arrive more or less simultaneously.
Note that this method does not throw checked exceptions. It can, however, throw runtime exceptions or errors, and the
Constellation running this Activity will deal with that.process in class Activityc - the Constellation on which the Activity is runninge - the Event to process.FINISH if this Activity is done or SUSPEND if this Activity expects events.public void cleanup(Constellation c)
ActivityConstellation running this Activity will deal with that.cleanup in class Activityc - the Constellation on which the Activity is runningpublic java.lang.String toString()
toString in class java.lang.Objectpublic Event waitForEvent()
public boolean isFinished()