Package overit.geocall.bl
Class GenericEvent<O>
java.lang.Object
overit.geocall.bl.GenericEvent<O>
- Type Parameters:
O- the type of the object contained into the output journal
- Direct Known Subclasses:
BusinessEvent,SystemEvent
The root class from which all event objects shall be derived.
All Events are constructed with a reference to the input and a journal of output, that is logically deemed to be the
object that contains the list of the output snapshots modified through side effect by the
BusinessTask.- GCApi:
- event
- No Reactors
- No Spouts
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classClass used to sort the task linked to an event -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidUtility method that unregister all the previous registered events.Predicate to define an interruption over the event binded tasks elaboration.Function used to define which Object should be considered as the event result from the ones contained into theJournal.protected abstract voidThe journal containing the event outputs.Returns the event result, taken from theJournal, as defined via the method defineResult() (defaults to the last object added to the journal).Returns the list of spout names associated with the current event, or an empty list if no spouts are associated.The journal containing theSpoutResultproduced by the event streaming phase.booleanDetermines if this event should be handled internally only (not published externally).launch()Launch the event using the identity that will be passed to the registered tasks.Launch the event using the identity that will be passed to the registered tasks and get the object returned by the first event's handler.Launch the event asynchronously providing the current identity to the registered tasks.launchAsync(PoolKit pk) Launch the event asynchronously providing the current identity to the registered tasks.static <O> voidUtility method that can be used to register a task to an event.In this way, when the event will be launched theBusinessTask.body(Object, PoolKit)task's method will be called.static voidregisterSpouts(Class<?> c) Utility method that can be used to register a stub to an event.
-
Field Details
-
journal
-
streamJournal
-
executorService
-
-
Constructor Details
-
GenericEvent
public GenericEvent()
-
-
Method Details
-
register
Utility method that can be used to register a task to an event.In this way, when the event will be launched theBusinessTask.body(Object, PoolKit)task's method will be called. The order depends on the number on the order param (lower number will be called first)- Type Parameters:
O- the type of the object contained into the output journal- Parameters:
c- class of the event on which to register
-
getSpouts
Returns the list of spout names associated with the current event, or an empty list if no spouts are associated.- Returns:
- the list of spout names associated with the current event, or an empty list if no spouts are associated.
-
isInternal
public boolean isInternal()Determines if this event should be handled internally only (not published externally). Subclasses can override this method to specify whether the event should be published to external spouts.- Returns:
trueif the event should be handled internally only;falseif it should be published externally. Default implementation returnsfalse.
-
registerSpouts
Utility method that can be used to register a stub to an event.- Parameters:
c- class of the event on which to register
-
clearEvents
public static void clearEvents()Utility method that unregister all the previous registered events. This method is called during the startup process and should never be called anymore. -
getJournal
The journal containing the event outputs.- Returns:
- The journal containing the event outputs.
-
getStreamJournal
The journal containing theSpoutResultproduced by the event streaming phase.- Returns:
- The journal containing the
SpoutResultproduced by the event streaming phase.
-
launch
Launch the event using the identity that will be passed to the registered tasks. This method will use a new database connection, therefore if you have anotherPoolKityet, please use thelaunch(PoolKit)instead.- Returns:
- The journal containing the event outputs.
- Throws:
DAValidateException- in case of database validation errorDAException- in case of database error
-
launchAsync
Launch the event asynchronously providing the current identity to the registered tasks.
This method will use a new database connection, therefore if you have another
Returns aPoolKityet, please use thelaunchAsync(PoolKit)instead.Futurethrough which to get the journal containing the pending results of the task.- Returns:
- a
Futurethrough which to get the journal containing the pending results of the task.
-
launchAsync
-
launch
Launch the event using the identity that will be passed to the registered tasks and get the object returned by the first event's handler. This method will re-use thePoolKitpassed by argument, therefore this method doesn't open a brand new database connection.- Parameters:
pk- the poolkit containing the reference to the database connection that can be used- Returns:
- the last event output before the interruption
- Throws:
DAValidateException- in case of database validation errorDAException- in case of database error
-
getResult
Returns the event result, taken from theJournal, as defined via the method defineResult() (defaults to the last object added to the journal).- Returns:
- the event result
-
doLaunch
protected abstract void doLaunch(PoolKit pk, Predicate<Journal<O>> interruptor) throws DAValidateException, DAException - Throws:
DAValidateExceptionDAException
-
defineResult
Function used to define which Object should be considered as the event result from the ones contained into theJournal. By default the last object added to the journal will be considered as the result.- Returns:
- the function used to define which Object should be considered as the event result from the ones contained
into the
Journal.
-
defineInterruptor
Predicate to define an interruption over the event binded tasks elaboration. By defaultthe seuqnence of tasks is not interrupted.- Returns:
- the predicate used to decide if the elaboration sequence must be interrupted
-