public class FlexibleEventCollector extends Activity
FlexibleEventCollector
is an Activity
that just waits for events, indefinitely, and collects them. It
provides a method waitForEvents()
, to be used by other activities, to collect the events collected so far.Constructor and Description |
---|
FlexibleEventCollector(AbstractContext c)
Constructs a
FlexibleEventCollector 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.
|
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[] |
waitForEvents()
This method blocks waiting for events.
|
expectsEvents, getContext, identifier, mayBeStolen, setIdentifier
public FlexibleEventCollector(AbstractContext c)
FlexibleEventCollector
with the specified activity context. Note: this is an activity that will
receive events (see Activity.Activity(AbstractContext, boolean)
).c
- the activity contextpublic int initialize(Constellation c)
Activity
Activity.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 Activity
c
- 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)
Activity
Activity.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 Activity
c
- 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)
Activity
Constellation
running this Activity will deal with that.cleanup
in class Activity
c
- the Constellation
on which the Activity is runningpublic java.lang.String toString()
toString
in class java.lang.Object
public Event[] waitForEvents()