Interface ModificationTracker

All Superinterfaces:
ExclusiveSessionProvider, SessionTaskDispatcher, TaskDispatcher, Terminatable

public interface ModificationTracker extends SessionTaskDispatcher, ExclusiveSessionProvider
Tracks global PDO changes.

The PDO tracker maintains its own session. The application can request an exclusive use of this session for a (short) period of time and release it afterward.

Author:
harald
  • Method Details

    • getInstance

      static ModificationTracker getInstance()
      The tracker singleton.
      Returns:
      the singleton
    • submit

      static void submit(Runnable runnable)
      Submits a task invoking given runnable.
      Parameters:
      runnable - the runnable to be executed once
    • transaction

      static void transaction(String txName, Runnable runnable)
      Submits a session task invoking the given runnable within a transaction of the tracker's session.
      Parameters:
      txName - the transaction name, null for default "<ModificationTracker>"
      runnable - the runnable to be executed once
    • transaction

      static void transaction(Runnable runnable)
      Submits a session task invoking the given runnable within a transaction of the tracker's session.
      Parameters:
      runnable - the runnable to be executed once
    • addModificationListener

      void addModificationListener(ModificationListener listener)
      Adds a modification listener.
      Parameters:
      listener - the listener to add
    • removeModificationListener

      boolean removeModificationListener(ModificationListener listener)
      Removes a modification listener.
      Parameters:
      listener - to remove
      Returns:
      true if removed
    • countModification

      long countModification(Session session, String name)
      Counts the modification for a given name.
      Used to trigger modification events.
      Parameters:
      session - the session persisting the modification, null if thread-local session (never remote)
      name - a unique name to track modifications
      Returns:
      the modification serial
    • addDeletion

      void addDeletion(Session session, String name, long id, long tableSerial)
      Adds a deletion to the previously counted modifications.
      Parameters:
      session - the session persisting the modification, null if thread-local session (never remote)
      name - a unique name to track modifications
      id - the ID of the object that was deleted
      tableSerial - the modification serial obtained from countModification(Session, String)
    • rollbackModification

      void rollbackModification(Session session, long txNumber)
      Invoked whenever a transaction is rolled back.
      Allows the tracker to adjust the pending counts.
      Parameters:
      session - the transaction's session (never remote)
      txNumber - the transaction number
    • addShutdownRunnable

      void addShutdownRunnable(Runnable runnable)
      Registers a pure runnable to be executed if the pdo tracker is terminated due to severe errors.
      Parameters:
      runnable - the runnable
    • removeShutdownRunnable

      boolean removeShutdownRunnable(Runnable runnable)
      Unregisters a shutdown runnable.
      Parameters:
      runnable - the runnable
      Returns:
      true if runnable removed
    • getSerial

      long getSerial(Class<?> clazz)
      Gets the serial for a given class.
      Parameters:
      clazz - the tracked class
      Returns:
      the table serial
    • getSerial

      long getSerial(String name)
      Gets the serial for a given modification name.
      Parameters:
      name - the modification name
      Returns:
      the table serial
    • invalidate

      void invalidate()
      Invalidates the tracker.
      Forces the tracking info to be rebuilt.
    • isLocalClientMode

      boolean isLocalClientMode()
      Returns whether the tracker runs in local client mode.
      In this mode, there is no middle-tier server and the clients are directly connected to the database.
      Although this mode isn't recommended, it is an option for simple desktop applications with only very few parallel users.
      Returns:
      true if in local client mode, false if remote client or server