- All Superinterfaces:
MasterSerial,Serializable
- All Known Implementing Classes:
MasterSerialListEvent
Interface for a master serial event.
Such events can be sent from the server to the client via the
Such events can be sent from the server to the client via the
ModificationTracker.
Implementing such an application-specific event involves the following steps:
-
create a class implementing
MasterSerialEvent.
Example:public class MyEvent implements MasterSerialEvent { private long serial; @Override public void setSerial(long serial) { this.serial = serial; } @Override public long serial() { return serial; } // plus extra payload specific to this event } -
create a
Consumerfor this event which will serve as its event handler. The handler must be annotated withMasterSerialEventService. This is aMappedServiceand provides the mapping of the event to its handler, which allows providing different handlers for different clients connecting to the same server. Furthermore, the server does not need to know the handlers at all.
Example:@MasterSerialEventService(MyEvent.class) public class MyEventHandler implements Consumer<MyEvent> { @Override public void accept(MyEvent event) { ... } } -
To send an event from the server to the client, use the method
org.tentackle.dbms.rmi.RemoteDbSessionImpl#addMasterSerialEvent, which is part of the moduletentackle-database.
If the event is a Collection, the elements of the event are
processed instead of the event itself, see org.tentackle.dbms.DbModificationTracker#extractMasterSerial.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanisOverridingEvent(MasterSerialEvent olderEvent) Returns whether this event is overriding given other event.
The method is only invoked ifisOverridingOlderEvents()returns true.default booleanReturns whether only the latest event counts.
Useful for events, that contain status information or alike.voidsetSerial(long serial) Sets the serial value.Methods inherited from interface org.tentackle.session.MasterSerial
serial
-
Method Details
-
setSerial
void setSerial(long serial) Sets the serial value.- Parameters:
serial- the serial
-
isOverridingOlderEvents
default boolean isOverridingOlderEvents()Returns whether only the latest event counts.
Useful for events, that contain status information or alike.- Returns:
- true if replace older event of this type, false to deliver each event
-
isOverridingEvent
Returns whether this event is overriding given other event.
The method is only invoked ifisOverridingOlderEvents()returns true.- Parameters:
olderEvent- the older event- Returns:
- true if other event should be replaced by this event
-