Class DelegatingTransactionSynchronizationRegistry
- All Implemented Interfaces:
TransactionSynchronizationRegistry
abstract
TransactionSynchronizationRegistry
implementation that delegates all method invocations to another
TransactionSynchronizationRegistry
.
Design Notes
This class is public
for convenience. It is extended by
other non-public
internal classes.
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newDelegatingTransactionSynchronizationRegistry
. -
Method Summary
Modifier and TypeMethodDescriptiongetResource
(Object key) Deprecated, for removal: This API element is subject to removal in a future version.Gets an object from theMap
of resources being managed for the transaction bound to the current thread at the time this method is called.boolean
Deprecated, for removal: This API element is subject to removal in a future version.Get therollbackOnly
status of the transaction bound to the current thread at the time this method is called.Deprecated, for removal: This API element is subject to removal in a future version.Return an opaque object to represent the transaction bound to the current thread at the time this method is called.int
Deprecated, for removal: This API element is subject to removal in a future version.Return the status of the transaction bound to the current thread at the time this method is called.void
putResource
(Object key, Object value) Deprecated, for removal: This API element is subject to removal in a future version.Adds or replaces an object in theMap
of resources being managed for the transaction bound to the current thread at the time this method is called.void
registerInterposedSynchronization
(Synchronization synchronization) Deprecated, for removal: This API element is subject to removal in a future version.Registers aSynchronization
instance with special ordering semantics.void
Deprecated, for removal: This API element is subject to removal in a future version.Sets therollbackOnly
status of the transaction bound to the current thread at the time this method is called.
-
Constructor Details
-
DelegatingTransactionSynchronizationRegistry
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newDelegatingTransactionSynchronizationRegistry
.- Parameters:
delegate
- theTransactionSynchronizationRegistry
to which all method invocations will be delegated; may benull
in which case every method in this class will throw anIllegalStateException
when invoked
-
-
Method Details
-
getTransactionKey
Deprecated, for removal: This API element is subject to removal in a future version.Return an opaque object to represent the transaction bound to the current thread at the time this method is called.This method may return
null
.This object overrides
Object.hashCode()
andObject.equals(Object)
to allow its use as the key in aMap
for use by the caller. If there is no transaction currently active, this method will returnnull
.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 aString
that might be usable by a human reader to usefully understand the transaction context. TheObject.toString()
result is otherwise not defined. Specifically, there is no forward or backward compatibility guarantee of the results of the returnedObject
'sObject.toString()
override.The object is not necessarily serializable, and has no defined behavior outside the virtual machine whence it was obtained.
- Specified by:
getTransactionKey
in interfaceTransactionSynchronizationRegistry
- Returns:
- an opaque object representing the transaction bound to
the current thread at the time this method is called, or
null
- Throws:
IllegalStateException
- if anull
delegate
was supplied at construction time
-
putResource
Deprecated, for removal: This API element is subject to removal in a future version.Adds or replaces an object in theMap
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()
andequals(Object)
methods are suitable for use as keys in aMap
. The key and value are not examined or used by the implementation. The general contract of this method is that ofMap.put(Object, Object)
for aMap
that supports non-null
keys and null values. For example, if there is already an value associated with the key, it is replaced by thevalue
parameter.- Specified by:
putResource
in interfaceTransactionSynchronizationRegistry
- Parameters:
key
- the key for theMap
entry; must not benull
value
- the value for theMap
entry- Throws:
IllegalStateException
- if no transaction is active or if anull
delegate
was supplied at construction timeNullPointerException
- if the parameterkey
isnull
-
getResource
Deprecated, for removal: This API element is subject to removal in a future version.Gets an object from theMap
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 resourceMap
,null
is returned. The general contract of this method is that ofMap.get(Object)
for aMap
that supports non-null
keys and null values. For example, the returned value is null if there is no entry for the parameterkey
or if the value associated with the key is actuallynull
.- Specified by:
getResource
in interfaceTransactionSynchronizationRegistry
- Parameters:
key
- the key for theMap
entry- Returns:
- the value associated with the supplied
key
; may benull
- Throws:
IllegalStateException
- if no transaction is active or if anull
delegate
was supplied at construction timeNullPointerException
- if the parameterkey
isnull
-
registerInterposedSynchronization
Deprecated, for removal: This API element is subject to removal in a future version.Registers aSynchronization
instance with special ordering semantics.The supplied
Synchronization
'sSynchronization.beforeCompletion()
method will be called after allSessionSynchronization#beforeCompletion()
callbacks and callbacks registered directly with theTransaction
, but before the 2-phase commit process starts. Similarly, theSynchronization.afterCompletion(int)
callback will be called after 2-phase commit completes but before anySessionSynchronization
andTransaction
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 ofregisterInterposedSynchronization(Synchronization)
. The general context is the component context of the caller ofregisterInterposedSynchronization(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.- Specified by:
registerInterposedSynchronization
in interfaceTransactionSynchronizationRegistry
- Parameters:
synchronization
- theSynchronization
to register; must not benull
- Throws:
IllegalStateException
- if no transaction is active or two-phase commit processing has started or if anull
delegate
was supplied at construction time- See Also:
-
getTransactionStatus
public int getTransactionStatus()Deprecated, for removal: This API element is subject to removal in a future version.Return the status of the transaction bound to the current thread at the time this method is called.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.- Specified by:
getTransactionStatus
in interfaceTransactionSynchronizationRegistry
- Returns:
- the status of the transaction bound to the current
thread at the time this method is called; will be equal the
value of one of the constants defined in the
Status
class - Throws:
IllegalStateException
- if anull
delegate
was supplied at construction time- See Also:
-
setRollbackOnly
public void setRollbackOnly()Deprecated, for removal: This API element is subject to removal in a future version.Sets therollbackOnly
status of the transaction bound to the current thread at the time this method is called.- Specified by:
setRollbackOnly
in interfaceTransactionSynchronizationRegistry
- Throws:
IllegalStateException
- if no transaction is active or if anull
delegate
was supplied at construction time
-
getRollbackOnly
public boolean getRollbackOnly()Deprecated, for removal: This API element is subject to removal in a future version.Get therollbackOnly
status of the transaction bound to the current thread at the time this method is called.- Specified by:
getRollbackOnly
in interfaceTransactionSynchronizationRegistry
- Returns:
- the
rollbackOnly
status - Throws:
IllegalStateException
- if no transaction is active or if anull
delegate
was supplied at construction time
-