Interface MasterSerialEvent

All Superinterfaces:
MasterSerial, Serializable
All Known Implementing Classes:
MasterSerialListEvent

public interface MasterSerialEvent extends MasterSerial
Interface for a master serial event.
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 Consumer for this event which will serve as its event handler. The handler must be annotated with MasterSerialEventService. This is a MappedService and 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 module tentackle-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 Type
    Method
    Description
    default boolean
    Returns whether this event is overriding given other event.
    The method is only invoked if isOverridingOlderEvents() returns true.
    default boolean
    Returns whether only the latest event counts.
    Useful for events, that contain status information or alike.
    void
    setSerial(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

      default boolean isOverridingEvent(MasterSerialEvent olderEvent)
      Returns whether this event is overriding given other event.
      The method is only invoked if isOverridingOlderEvents() returns true.
      Parameters:
      olderEvent - the older event
      Returns:
      true if other event should be replaced by this event