public abstract class DelegatingTransactionSynchronizationRegistry extends Object implements Serializable, TransactionSynchronizationRegistry
abstract TransactionSynchronizationRegistry
implementation that delegates all method invocations to another
TransactionSynchronizationRegistry.
This class is public for convenience. It is extended by
other non-public internal classes.
TransactionSynchronizationRegistry,
Serialized Form| Modifier | Constructor and Description |
|---|---|
protected |
DelegatingTransactionSynchronizationRegistry(TransactionSynchronizationRegistry delegate)
Creates a new
DelegatingTransactionSynchronizationRegistry. |
| Modifier and Type | Method and Description |
|---|---|
Object |
getResource(Object key)
Gets an object from the
Map of resources being managed
for the transaction bound to the current thread at the time
this method is called. |
boolean |
getRollbackOnly()
Get the
rollbackOnly status of the transaction bound to
the current thread at the time this method is called. |
Object |
getTransactionKey()
Return an opaque object to represent the transaction bound to
the current thread at the time this method is called.
|
int |
getTransactionStatus()
Return the status of the transaction bound to the current
thread at the time this method is called.
|
void |
putResource(Object key,
Object value)
Adds or replaces an object in the
Map of resources
being managed for the transaction bound to the current thread
at the time this method is called. |
void |
registerInterposedSynchronization(Synchronization synchronization)
Registers a
Synchronization instance with special
ordering semantics. |
void |
setRollbackOnly()
Sets the
rollbackOnly status of the transaction bound
to the current thread at the time this method is called. |
protected DelegatingTransactionSynchronizationRegistry(TransactionSynchronizationRegistry delegate)
DelegatingTransactionSynchronizationRegistry.delegate - the TransactionSynchronizationRegistry
to which all method invocations will be delegated; may be
null in which case every method in this class will
throw an IllegalStateException when invokedpublic Object getTransactionKey()
This method may return null.
This object overrides Object.hashCode() and Object.equals(Object) to allow its use as the key in a Map for use by the caller. If there is no transaction
currently active, this method will return null.
The Object returned will return the same hashCode
and compare equal to all other objects returned by calling this
method from any component executing in the same transaction
context in the same application server.
The Object.toString() method returns a String that might be usable by a human reader to usefully
understand the transaction context. The Object.toString() result is otherwise not
defined. Specifically, there is no forward or backward
compatibility guarantee of the results of the returned Object's Object.toString() override.
The object is not necessarily serializable, and has no defined behavior outside the virtual machine whence it was obtained.
getTransactionKey in interface TransactionSynchronizationRegistrynullIllegalStateException - if a null delegate was supplied at construction timepublic void putResource(Object key, Object value)
Map of resources
being managed for the transaction bound to the current thread
at the time this method is called.
The supplied key should be of an caller-defined class so as
not to conflict with other users. The class of the key must
guarantee that the hashCode() and
equals(Object) methods are
suitable for use as keys in a Map. The key and value
are not examined or used by the implementation. The general
contract of this method is that of Map.put(Object,
Object) for a Map that supports non-null keys
and null values. For example, if there is already an value
associated with the key, it is replaced by the value
parameter.
putResource in interface TransactionSynchronizationRegistrykey - the key for the Map entry; must not be
nullvalue - the value for the Map entryIllegalStateException - if no transaction is active or
if a null delegate was supplied at construction timeNullPointerException - if the parameter key is
nullpublic Object getResource(Object key)
Map of resources being managed
for the transaction bound to the current thread at the time
this method is called.
The key should have been supplied earlier by a call to
putResource(Object, Object) in the same
transaction. If the key cannot be found in the current resource
Map, null is returned. The general contract of
this method is that of Map.get(Object) for a Map that supports non-null keys and null values. For
example, the returned value is null if there is no entry for
the parameter key or if the value associated with the
key is actually null.
getResource in interface TransactionSynchronizationRegistrykey - the key for the Map entrykey; may
be nullIllegalStateException - if no transaction is active or
if a null delegate was supplied at construction timeNullPointerException - if the parameter key is
nullpublic void registerInterposedSynchronization(Synchronization synchronization)
Synchronization instance with special
ordering semantics.
The supplied Synchronization's Synchronization.beforeCompletion() method will be called after
all SessionSynchronization#beforeCompletion() callbacks
and callbacks registered directly with the Transaction,
but before the 2-phase commit process starts. Similarly, the
Synchronization.afterCompletion(int) callback will be
called after 2-phase commit completes but before any SessionSynchronization and Transaction afterCompletion(int) callbacks.
The Synchronization.beforeCompletion() callback will
be invoked in the transaction context of the transaction bound
to the current thread at the time this method is
called. Allowable methods include access to resources,
e.g. connectors. No access is allowed to "user components"
(e.g. timer services or bean methods), as these might change
the state of data being managed by the caller, and might change
the state of data that has already been flushed by another
caller of registerInterposedSynchronization(Synchronization). The
general context is the component context of the caller of
registerInterposedSynchronization(Synchronization).
The Synchronization.afterCompletion(int) callback
will be invoked in an undefined context. No access is permitted
to "user components" as defined above. Resources can be closed
but no transactional work can be performed with them.
If this method is invoked without an active transaction
context, an IllegalStateException is thrown.
If this method is invoked after the two-phase commit
processing has started, an IllegalStateException is
thrown.
registerInterposedSynchronization in interface TransactionSynchronizationRegistrysynchronization - the Synchronization to register;
must not be nullIllegalStateException - if no transaction is active or
two-phase commit processing has started or if a null
delegate was supplied at construction timeSynchronization,
Synchronization.beforeCompletion(),
Synchronization.afterCompletion(int)public int getTransactionStatus()
This is the result of executing TransactionManager.getStatus() in the context of the
transaction bound to the current thread at the time this method
is called.
getTransactionStatus in interface TransactionSynchronizationRegistryStatus
classIllegalStateException - if a null delegate was supplied at construction timeTransactionManager.getStatus(),
Statuspublic void setRollbackOnly()
rollbackOnly status of the transaction bound
to the current thread at the time this method is called.setRollbackOnly in interface TransactionSynchronizationRegistryIllegalStateException - if no transaction is active or
if a null delegate was supplied at construction timepublic boolean getRollbackOnly()
rollbackOnly status of the transaction bound to
the current thread at the time this method is called.getRollbackOnly in interface TransactionSynchronizationRegistryrollbackOnly statusIllegalStateException - if no transaction is active or
if a null delegate was supplied at construction timeCopyright © 2020 JBoss by Red Hat. All rights reserved.