abstract class Reversible
extends java.lang.Object
rollback(boolean, boolean)
method
reverses a specific database action on that record. The action taken to
roll back the original action depends upon the subclass' implementation of
the rollback
method.Modifier and Type | Field and Description |
---|---|
protected static java.util.logging.Logger |
LOG
Logger
|
private boolean |
newlyCreated
Was DMO record newly created at the time Reversible was created?
|
Constructor and Description |
---|
Reversible() |
Modifier and Type | Method and Description |
---|---|
(package private) Reversible |
duplicate(java.io.Serializable key)
Duplicate this reversible action.
|
protected java.lang.String |
getAction()
Get a string which briefly describes the action which this object
will reverse upon rollback.
|
protected abstract Persistable |
getDMO()
Get the underlying DMO.
|
protected abstract java.lang.String |
getDMOName()
Get the unqualified interface name of the DMO being managed by this
reversible.
|
protected abstract java.io.Serializable |
getId()
Get the ID of the underlying DMO.
|
protected boolean |
isNewlyCreated()
Indicate whether the DMO which is the target of a rollback was newly
created by the current context.
|
protected void |
prepareRollback(Persistable dmo)
Prepare for this reversible to be rolled back.
|
protected abstract void |
rollback(boolean rollForward,
boolean transaction)
Roll back the database change represented by this object.
|
protected abstract void |
setDMO(Persistable dmo)
Set the underlying DMO for this reversible action.
|
protected void |
setNewlyCreated(boolean isNew)
Indicate whether the DMO which is the target of a rollback was newly
created by the current context.
|
protected abstract boolean |
storesDMO()
Indicate whether this
Reversible implementation stores its
DMO locally, as opposed to storing an identifier and having to retrieve
the DMO from the backing database, or not making a DMO available at all. |
java.lang.String |
toString()
Get a string representation of the internal state of this object,
primarily for debugging purposes.
|
protected static final java.util.logging.Logger LOG
private boolean newlyCreated
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String getAction()
protected abstract boolean storesDMO()
Reversible
implementation stores its
DMO locally, as opposed to storing an identifier and having to retrieve
the DMO from the backing database, or not making a DMO available at all.true
if the DMO is stored locally, else
false
.protected abstract java.lang.String getDMOName()
protected abstract void rollback(boolean rollForward, boolean transaction) throws PersistenceException
Subclasses must implement this method in a manner appropriate to the database actions they represent.
rollForward
- If true
, this method is being invoked in order to
re-roll forward a non-undoable change, after a database-level
rollback. This indicates the modification is made within a
new transaction invoked after the database-level rollback.
If false
, this method is being invoked in order to
roll back an undoable change within the context of an
application-level, full transaction or sub-transaction
rollback.transaction
- true
if this rollback occurs at a full transaction
boundary, else false
.PersistenceException
- if an error occurs at the database or in the persistence
layer when reversing the action.protected abstract Persistable getDMO()
protected abstract void setDMO(Persistable dmo)
dmo
- The underlying DMO; may not be null.java.lang.NullPointerException
- if dmo
is null
.protected abstract java.io.Serializable getId()
protected void prepareRollback(Persistable dmo)
dmo
- If non-null
, the caller is providing a DMO which
it thinks is the appropriate object to act upon during rollback
processing.protected boolean isNewlyCreated()
true
to indicate target DMO was newly created by
the current context; else false
.protected void setNewlyCreated(boolean isNew)
isNew
- true
to indicate dmo
is newly created
by the current context; else false
.Reversible duplicate(java.io.Serializable key)
key
- The key to set for the new reversible action.java.lang.UnsupportedOperationException
- If this operation is not supported.