Package com.tangosol.persistence
Class SafePersistenceWrappers.SafePersistenceEnvironment<R,T extends Throwable>
- java.lang.Object
-
- com.tangosol.util.NullImplementation.NullPersistenceEnvironment<R>
-
- com.tangosol.persistence.SafePersistenceWrappers.SafePersistenceEnvironment<R,T>
-
- Type Parameters:
R
- the type of a raw, environment specific object representationT
- 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 failureContinuation
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Continuation<? super T>
f_contFailure
The failure continuation for this environment.protected com.oracle.coherence.persistence.PersistenceEnvironment<R>
f_env
The underlying PersistenceEnvironment.protected SafePersistenceWrappers.FailureContinuationFactory<R,? super T>
f_factoryCont
The FailureContinuationFactory.-
Fields inherited from class com.tangosol.util.NullImplementation.NullPersistenceEnvironment
INSTANCE
-
-
Constructor Summary
Constructors Constructor Description SafePersistenceEnvironment(com.oracle.coherence.persistence.PersistenceEnvironment<R> env)
Construct a PersistenceEnvironment backed by the specified environment.SafePersistenceEnvironment(com.oracle.coherence.persistence.PersistenceEnvironment<R> env, Continuation<? super Throwable> cont)
Construct a PersistenceEnvironment backed by the specified environment.SafePersistenceEnvironment(com.oracle.coherence.persistence.PersistenceEnvironment<R> env, SafePersistenceWrappers.FailureContinuationFactory<R,? super T> factory)
Construct a PersistenceEnvironment backed by the specified environment.
-
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.
-
-
-
Field Detail
-
f_env
protected final com.oracle.coherence.persistence.PersistenceEnvironment<R> f_env
The underlying PersistenceEnvironment.
-
f_contFailure
protected final Continuation<? super T extends Throwable> f_contFailure
The failure continuation for this environment.
-
f_factoryCont
protected final SafePersistenceWrappers.FailureContinuationFactory<R,? super T extends Throwable> f_factoryCont
The FailureContinuationFactory.
-
-
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 PersistenceEnvironmentcont
- 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 PersistenceEnvironmentfactory
- 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 interfacecom.oracle.coherence.persistence.PersistenceEnvironment<R>
- Overrides:
openActive
in classNullImplementation.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 interfacecom.oracle.coherence.persistence.PersistenceEnvironment<R>
- Overrides:
openSnapshot
in classNullImplementation.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 interfacecom.oracle.coherence.persistence.PersistenceEnvironment<R>
- Overrides:
createSnapshot
in classNullImplementation.NullPersistenceEnvironment<R>
- Parameters:
sSnapshot
- the snapshot identifiermanager
- 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 interfacecom.oracle.coherence.persistence.PersistenceEnvironment<R>
- Overrides:
removeSnapshot
in classNullImplementation.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 interfacecom.oracle.coherence.persistence.PersistenceEnvironment<R>
- Overrides:
listSnapshots
in classNullImplementation.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 interfacecom.oracle.coherence.persistence.PersistenceEnvironment<R>
- Overrides:
release
in classNullImplementation.NullPersistenceEnvironment<R>
-
-