Class SafePersistenceWrappers.SafePersistenceEnvironment<R,​T extends Throwable>

  • Type Parameters:
    R - the type of a raw, environment specific object representation
    T - the type of a Throwable failure to protect
    All Implemented Interfaces:
    com.oracle.coherence.persistence.PersistenceEnvironment<R>
    Enclosing class:
    SafePersistenceWrappers

    public static class SafePersistenceWrappers.SafePersistenceEnvironment<R,​T extends Throwable>
    extends NullImplementation.NullPersistenceEnvironment<R>
    SafePersistenceEnvironment is a wrapper PersistenceEnvironment implementation which protects all operations on the underlying environment (and any PersistenceManger or PersistentStore instances opened through this environment) from unexpected failures, delegating the exception handling to a failure Continuation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.oracle.coherence.persistence.PersistenceManager<R> createSnapshot​(String sSnapshot, com.oracle.coherence.persistence.PersistenceManager<R> manager)
      Create a PersistenceManager used to manage the snapshot with the specified identifier.
      com.oracle.coherence.persistence.PersistenceEnvironment<R> getEnvironment()
      Return the underlying PersistenceEnvironment.
      String[] listSnapshots()
      Return the identifiers of the snapshots known to this environment.
      protected void onException​(T t)
      Called to handle an unexpected exception.
      com.oracle.coherence.persistence.PersistenceManager<R> openActive()
      Open and return the singleton active PersistenceManager.
      com.oracle.coherence.persistence.PersistenceManager<R> openBackup()
      Open and return a singleton PersistenceManager to store backup data.
      com.oracle.coherence.persistence.PersistenceManager<R> openEvents()
      Open and return a singleton PersistenceManager to store MapEvents.
      com.oracle.coherence.persistence.PersistenceManager<R> openSnapshot​(String sSnapshot)
      Open a PersistenceManager used to access the snapshot with the specified identifier.
      void release()
      Release all resources held by this environment.
      boolean removeSnapshot​(String sSnapshot)
      Remove the persistent artifacts associated with the snapshot with the specified identifier.
      String toString()
      Return a human readable description of this SafePersistenceEnvironment.
      protected com.oracle.coherence.persistence.PersistenceManager wrap​(com.oracle.coherence.persistence.PersistenceManager<R> mgr)
      Wrap the specified manager in a SafePersistenceManager implementation.
      • Methods inherited from interface com.oracle.coherence.persistence.PersistenceEnvironment

        createSnapshot
    • Constructor Detail

      • SafePersistenceEnvironment

        public SafePersistenceEnvironment​(com.oracle.coherence.persistence.PersistenceEnvironment<R> env)
        Construct a PersistenceEnvironment backed by the specified environment.
        Parameters:
        env - the underlying PersistenceEnvironment
      • SafePersistenceEnvironment

        public SafePersistenceEnvironment​(com.oracle.coherence.persistence.PersistenceEnvironment<R> env,
                                          Continuation<? super Throwable> cont)
        Construct a PersistenceEnvironment backed by the specified environment.
        Parameters:
        env - the underlying PersistenceEnvironment
        cont - the failure continuation to use to handle unexpected exceptions
      • SafePersistenceEnvironment

        public SafePersistenceEnvironment​(com.oracle.coherence.persistence.PersistenceEnvironment<R> env,
                                          SafePersistenceWrappers.FailureContinuationFactory<R,​? super T> factory)
        Construct a PersistenceEnvironment backed by the specified environment.
        Parameters:
        env - the underlying PersistenceEnvironment
        factory - the failure continuation factory to use to create handlers for unexpected exceptions
    • Method Detail

      • getEnvironment

        public com.oracle.coherence.persistence.PersistenceEnvironment<R> getEnvironment()
        Return the underlying PersistenceEnvironment.
        Returns:
        the underlying PersistenceEnvironment
      • onException

        protected void onException​(T t)
        Called to handle an unexpected exception.
        Parameters:
        t - the Throwable
      • wrap

        protected com.oracle.coherence.persistence.PersistenceManager wrap​(com.oracle.coherence.persistence.PersistenceManager<R> mgr)
        Wrap the specified manager in a SafePersistenceManager implementation.
        Parameters:
        mgr - the underlying PersistenceManger
        Returns:
        a "safe" PersistenceManger or null if the specified manager is null
      • openBackup

        public com.oracle.coherence.persistence.PersistenceManager<R> openBackup()
        Open and return a singleton PersistenceManager to store backup data.
        Returns:
        the singleton backup PersistenceManager or null if an active PersistenceManager has not been configured
      • openEvents

        public com.oracle.coherence.persistence.PersistenceManager<R> openEvents()
        Open and return a singleton PersistenceManager to store MapEvents.
        Returns:
        the singleton store of MapEvents or null if durable events is not enabled
      • openActive

        public com.oracle.coherence.persistence.PersistenceManager<R> openActive()
        Open and return the singleton active PersistenceManager.
        Specified by:
        openActive in interface com.oracle.coherence.persistence.PersistenceEnvironment<R>
        Overrides:
        openActive in class NullImplementation.NullPersistenceEnvironment<R>
        Returns:
        the singleton active PersistenceManager or null if an active PersistenceManager has not been configured
      • openSnapshot

        public com.oracle.coherence.persistence.PersistenceManager<R> openSnapshot​(String sSnapshot)
        Open a PersistenceManager used to access the snapshot with the specified identifier.
        Specified by:
        openSnapshot in interface com.oracle.coherence.persistence.PersistenceEnvironment<R>
        Overrides:
        openSnapshot in class NullImplementation.NullPersistenceEnvironment<R>
        Parameters:
        sSnapshot -  the snapshot identifier
        Returns:
        a PersistenceManager representing the snapshot
      • createSnapshot

        public com.oracle.coherence.persistence.PersistenceManager<R> createSnapshot​(String sSnapshot,
                                                                                     com.oracle.coherence.persistence.PersistenceManager<R> manager)
        Create a PersistenceManager used to manage the snapshot with the specified identifier.
        Specified by:
        createSnapshot in interface com.oracle.coherence.persistence.PersistenceEnvironment<R>
        Overrides:
        createSnapshot in class NullImplementation.NullPersistenceEnvironment<R>
        Parameters:
        sSnapshot -  the snapshot identifier
        manager - the optional PersistenceManager to create a snapshot of; if null, an empty snapshot will be created
        Returns:
        a PersistenceManager representing the snapshot
      • removeSnapshot

        public boolean removeSnapshot​(String sSnapshot)
        Remove the persistent artifacts associated with the snapshot with the specified identifier.
        Specified by:
        removeSnapshot in interface com.oracle.coherence.persistence.PersistenceEnvironment<R>
        Overrides:
        removeSnapshot in class NullImplementation.NullPersistenceEnvironment<R>
        Parameters:
        sSnapshot -  the snapshot identifier
        Returns:
        true if the snapshot was successfully deleted, false otherwise
      • listSnapshots

        public String[] listSnapshots()
        Return the identifiers of the snapshots known to this environment.
        Specified by:
        listSnapshots in interface com.oracle.coherence.persistence.PersistenceEnvironment<R>
        Overrides:
        listSnapshots in class NullImplementation.NullPersistenceEnvironment<R>
        Returns:
        a list of the known snapshot identifiers
      • release

        public void release()
        Release all resources held by this environment. Note that the behavior of all other methods on this environment is undefined after this method is called.
        Specified by:
        release in interface com.oracle.coherence.persistence.PersistenceEnvironment<R>
        Overrides:
        release in class NullImplementation.NullPersistenceEnvironment<R>
      • toString

        public String toString()
        Return a human readable description of this SafePersistenceEnvironment.
        Overrides:
        toString in class Object
        Returns:
        a human readable description