Package org.projectbarbel.histo.event
Enum EventType
- java.lang.Object
-
- java.lang.Enum<EventType>
-
- org.projectbarbel.histo.event.EventType
-
- All Implemented Interfaces:
Serializable
,Comparable<EventType>
,java.lang.constant.Constable
,PostableEvent
public enum EventType extends Enum<EventType> implements PostableEvent
Enum that contains all events thrown byBarbelHisto
.
Lifecycle when callingBarbelHisto.save(Object, java.time.ZonedDateTime, java.time.ZonedDateTime)
as follows:1.
TheBARBELINITIALIZED
whenBarbelHisto
instance is created, only once perBarbelHisto
session, both way 2.INITIALIZEJOURNAL
when journal is created, on every update, both way 3.ACQUIRELOCK
, whenBarbelHisto
starts updating a document journal, synchronous post 4.INACTIVATION
, when versions are inactivated, both way 5.INSERTBITEMPORAL
, when new versions are inserted, both way 6.UPDATEFINISHED
, when the update operation for journal was completed, once per save operation, both way 7.RELEASELOCK
, whenBarbelHisto
finishes the updating cycle, synchronous postRETRIEVEDATA
event is posted each time when clients retrieve data fromBarbelHisto
. TheONLOADOPERATION
andUNONLOADOPERATION
events is posted when the client performs a bulk load and unload withBarbelHisto.load(java.util.Collection)
andBarbelHisto.unload(Object...)
respectively, both posted both way.
"Both way" means that the event is published synchronously and asynchronously, i.e. clients can register listeners in asynchronous and synchronous bus to catch these events.
Different uses ofHistoEvent
s are possible. For instance clients may want to:- synchronize data in external data stores with
INACTIVATION
andINSERTBITEMPORAL
- lock journals stored in a database in complex distributed scenarios using
ACQUIRELOCK
andRELEASELOCK
- lazy load the backbone from external source depending on the data
requested by clients using the
RETRIEVEDATA
event
EventType
create listener classed like so;public class MyListener {
Then register the listeners with@Subscribe
public void handleEvent(AquireLockEvent event) { // handle the event } }BarbelHistoBuilder.withSynchronousEventListener(Object)
orBarbelHistoBuilder.withAsynchronousEventListener(Object)
.
If you perform synchronous events, you can control the behavior if the event processing fails. If the handler fails to handle the received synchronous event, then callHistoEvent.failed(Throwable)
. This will stop execution and anHistoEventFailedException
will be thrown without continuing processing. This could be useful in many situations, e.g. in situations where clients want to avoid any inconsistency between the backbone collection and an external data source targeted by an event.
- Author:
- Niklas Schlimm
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EventType.AbstractBarbelEvent
static class
EventType.AcquireLockEvent
class
EventType.BarbelInitializedEvent
static class
EventType.DefaultSubscriberExceptionHandler
static class
EventType.InactivationEvent
static class
EventType.InitializeJournalEvent
static class
EventType.InsertBitemporalEvent
class
EventType.OnLoadOperationEvent
static class
EventType.ReleaseLockEvent
static class
EventType.RetrieveDataEvent
class
EventType.UnLoadOperationEvent
static class
EventType.UpdateFinishedEvent
-
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ACQUIRELOCK
Event fired whenBarbelHisto
acquires the lock for a journal update.BARBELINITIALIZED
Event fired whenBarbelHisto
is ready for execution.INACTIVATION
Event fired whenBarbelHisto
inactivates versions.INITIALIZEJOURNAL
Event fired when a journal updated is started on aBarbelHisto.save(Object, java.time.ZonedDateTime, java.time.ZonedDateTime)
operation.INSERTBITEMPORAL
Event fired whenBarbelHisto
inserts new version data to a document journal for a given document ID.ONLOADOPERATION
Event fired when client performs load operation withBarbelHisto.load(java.util.Collection)
.RELEASELOCK
Event fired whenBarbelHisto
released a lock on a document journal for a given document ID in the operation.RETRIEVEDATA
Event fired whenBarbelHisto
performs a query on request of the client, e.g. inBarbelHisto.retrieve(Query)
.UNONLOADOPERATION
Event fired when client performs unload operation withBarbelHisto.unload(Object...)
.UPDATEFINISHED
Event fired whenBarbelHisto
finished updating the document journal of a given document id.
-
Method Summary
-
Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface org.projectbarbel.histo.event.PostableEvent
create
-
-
-
-
Enum Constant Detail
-
BARBELINITIALIZED
public static final EventType BARBELINITIALIZED
Event fired whenBarbelHisto
is ready for execution.
-
INITIALIZEJOURNAL
public static final EventType INITIALIZEJOURNAL
Event fired when a journal updated is started on aBarbelHisto.save(Object, java.time.ZonedDateTime, java.time.ZonedDateTime)
operation.
-
ACQUIRELOCK
public static final EventType ACQUIRELOCK
Event fired whenBarbelHisto
acquires the lock for a journal update. Posted once for each save-operation at the beginning of the update-operation.
-
INSERTBITEMPORAL
public static final EventType INSERTBITEMPORAL
Event fired whenBarbelHisto
inserts new version data to a document journal for a given document ID. Posted once for each save-operation.
-
INACTIVATION
public static final EventType INACTIVATION
Event fired whenBarbelHisto
inactivates versions. Posted once for each save-operation.
-
UPDATEFINISHED
public static final EventType UPDATEFINISHED
Event fired whenBarbelHisto
finished updating the document journal of a given document id. Posted once for each save-operation.
-
RELEASELOCK
public static final EventType RELEASELOCK
Event fired whenBarbelHisto
released a lock on a document journal for a given document ID in the operation. Posted once for each save-operation at the end of the update-operation
-
RETRIEVEDATA
public static final EventType RETRIEVEDATA
Event fired whenBarbelHisto
performs a query on request of the client, e.g. inBarbelHisto.retrieve(Query)
. Posted once for each retrieve-operation, both way.
-
ONLOADOPERATION
public static final EventType ONLOADOPERATION
Event fired when client performs load operation withBarbelHisto.load(java.util.Collection)
. Posted both way.
-
UNONLOADOPERATION
public static final EventType UNONLOADOPERATION
Event fired when client performs unload operation withBarbelHisto.unload(Object...)
. Posted both way.
-
-
Method Detail
-
values
public static EventType[] values()
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EventType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
-