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>,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.
TheBARBELINITIALIZEDwhenBarbelHistoinstance is created, only once perBarbelHistosession, both way 2.INITIALIZEJOURNALwhen journal is created, on every update, both way 3.ACQUIRELOCK, whenBarbelHistostarts 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, whenBarbelHistofinishes the updating cycle, synchronous postRETRIEVEDATAevent is posted each time when clients retrieve data fromBarbelHisto. TheONLOADOPERATIONandUNONLOADOPERATIONevents 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 ofHistoEvents are possible. For instance clients may want to:- synchronize data in external data stores with
INACTIVATIONandINSERTBITEMPORAL - lock journals stored in a database in complex distributed scenarios using
ACQUIRELOCKandRELEASELOCK - lazy load the backbone from external source depending on the data
requested by clients using the
RETRIEVEDATAevent
EventTypecreate listener classed like so;public class MyListener {Then register the listeners with@Subscribepublic 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 anHistoEventFailedExceptionwill 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 classEventType.AbstractBarbelEventstatic classEventType.AcquireLockEventclassEventType.BarbelInitializedEventstatic classEventType.DefaultSubscriberExceptionHandlerstatic classEventType.InactivationEventstatic classEventType.InitializeJournalEventstatic classEventType.InsertBitemporalEventclassEventType.OnLoadOperationEventstatic classEventType.ReleaseLockEventstatic classEventType.RetrieveDataEventclassEventType.UnLoadOperationEventstatic classEventType.UpdateFinishedEvent
-
Enum Constant Summary
Enum Constants Enum Constant Description ACQUIRELOCKEvent fired whenBarbelHistoacquires the lock for a journal update.BARBELINITIALIZEDEvent fired whenBarbelHistois ready for execution.INACTIVATIONEvent fired whenBarbelHistoinactivates versions.INITIALIZEJOURNALEvent fired when a journal updated is started on aBarbelHisto.save(Object, java.time.ZonedDateTime, java.time.ZonedDateTime)operation.INSERTBITEMPORALEvent fired whenBarbelHistoinserts new version data to a document journal for a given document ID.ONLOADOPERATIONEvent fired when client performs load operation withBarbelHisto.load(java.util.Collection).RELEASELOCKEvent fired whenBarbelHistoreleased a lock on a document journal for a given document ID in the operation.RETRIEVEDATAEvent fired whenBarbelHistoperforms a query on request of the client, e.g.UNONLOADOPERATIONEvent fired when client performs unload operation withBarbelHisto.unload(Object...).UPDATEFINISHEDEvent fired whenBarbelHistofinished updating the document journal of a given document id.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static EventTypevalueOf(String name)Returns the enum constant of this type with the specified name.static EventType[]values()Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, 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 whenBarbelHistois 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 whenBarbelHistoacquires 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 whenBarbelHistoinserts 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 whenBarbelHistoinactivates versions. Posted once for each save-operation.
-
UPDATEFINISHED
public static final EventType UPDATEFINISHED
Event fired whenBarbelHistofinished updating the document journal of a given document id. Posted once for each save-operation.
-
RELEASELOCK
public static final EventType RELEASELOCK
Event fired whenBarbelHistoreleased 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 whenBarbelHistoperforms 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. This method may be used to iterate over the constants as follows:for (EventType c : EventType.values()) System.out.println(c);
- 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
-
-