public interface TransactionSynchronizationRegistry
In standard application server environments, an instance implementing this interface can be looked up by a standard name via JNDI. The standard name is java:comp/TransactionSynchronizationRegistry.
Modifier and Type | Method and Description |
---|---|
Object |
getResource(Object key)
Get 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)
Add or replace 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 sync)
Register a Synchronization instance with special ordering
semantics.
|
void |
setRollbackOnly()
Set the rollbackOnly status of the transaction bound to the
current thread at the time this method is called.
|
Object getTransactionKey()
This object 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 toString method returns a String that might be usable by a human reader to usefully understand the transaction context. The toString result is otherwise not defined. Specifically, there is no forward or backward compatibility guarantee of the results of toString.
The object is not necessarily serializable, and has no defined behavior outside the virtual machine whence it was obtained.
void putResource(Object key, Object value)
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.key
- the key for the Map entry.value
- the value for the Map entry.IllegalStateException
- if no transaction is active.NullPointerException
- if the parameter key is null.Object getResource(Object key)
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.key
- the key for the Map entry.IllegalStateException
- if no transaction is active.NullPointerException
- if the parameter key is null.void registerInterposedSynchronization(Synchronization sync)
The 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. The general context is the component context of the caller of registerInterposedSynchronization.
The afterCompletion 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.
sync
- the Synchronization instance.IllegalStateException
- if no transaction is active.int getTransactionStatus()
void setRollbackOnly()
IllegalStateException
- if no transaction is active.boolean getRollbackOnly()
IllegalStateException
- if no transaction is active.Copyright © 2021 JBoss by Red Hat. All rights reserved.