Class ReachabilityAtCommitHandler

java.lang.Object
org.datanucleus.ReachabilityAtCommitHandler

public class ReachabilityAtCommitHandler extends Object
Handler to process "persistence-by-reachability" at commit. This is a feature of the JDO spec that is enabled by default for that API. It runs a cursory check for objects that have been pulled in to be persisted by "persistence-by-reachability" (cascading) but that are no longer needing to be persisted maybe due to the cascading origin object being deleted.
  • Field Details

    • ec

      private ExecutionContext ec
    • executing

      private boolean executing
      Flag for whether we are running "persistence-by-reachability" at commit execute() at this point in time.
    • persistedIds

      private Set persistedIds
      Reachability : Set of ids of objects persisted using persistObject, or known as already persistent in the current txn.
    • deletedIds

      private Set deletedIds
      Reachability : Set of ids of objects deleted using deleteObject.
    • flushedNewIds

      private Set flushedNewIds
      Reachability : Set of ids of objects newly persistent in the current transaction
    • enlistedIds

      private Set enlistedIds
      Reachability : Set of ids for all objects enlisted in this transaction.
  • Constructor Details

    • ReachabilityAtCommitHandler

      public ReachabilityAtCommitHandler(ExecutionContext ec)
      Constructor for a reachability-at-commit handler.
      Parameters:
      ec - ExecutionContext that it is for
  • Method Details

    • clear

      public void clear()
      Method to clear the stored ids of objects involved in the reachability process.
    • isExecuting

      public boolean isExecuting()
    • addEnlistedObject

      public void addEnlistedObject(Object id)
    • isObjectEnlisted

      public boolean isObjectEnlisted(Object id)
    • addPersistedObject

      public void addPersistedObject(Object id)
    • isObjectPersisted

      public boolean isObjectPersisted(Object id)
    • addDeletedObject

      public void addDeletedObject(Object id)
    • isObjectDeleted

      public boolean isObjectDeleted(Object id)
    • addFlushedNewObject

      public void addFlushedNewObject(Object id)
    • isObjectFlushedNew

      public boolean isObjectFlushedNew(Object id)
    • swapObjectId

      public void swapObjectId(Object oldID, Object newID)
      Method that will allow swapping of an "id", for example when an object has recently been assigned its true "id".
      Parameters:
      oldID - The old id that it is registered with. If this is null then we do nothing
      newID - The new id to use in place
    • execute

      public void execute()
      Method to perform the "persistence-by-reachability" at commit.