public final class LocalTransactionContext extends Object implements org.wildfly.common.context.Contextual<LocalTransactionContext>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TXN_TIMEOUT
The default transaction timeout (5 minutes).
|
Constructor and Description |
---|
LocalTransactionContext(LocalTransactionProvider provider)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
LocalTransaction |
beginTransaction(int timeout)
Begin a new, local transaction on behalf of a local peer.
|
LocalTransaction |
beginTransaction(int timeout,
boolean failOnSuspend)
Begin a new, local transaction on behalf of a local or remote peer.
|
ImportResult<LocalTransaction> |
findOrImportTransaction(Xid xid,
int timeout)
Attempt to import a transaction, which subsequently may be controlled by its XID or by the returned handle.
|
ImportResult<LocalTransaction> |
findOrImportTransaction(Xid xid,
int timeout,
boolean doNotImport)
Attempt to import a transaction, which subsequently may be controlled by its XID or by the returned handle.
|
static org.wildfly.common.context.ContextManager<LocalTransactionContext> |
getContextManager()
Get the context manager.
|
static LocalTransactionContext |
getCurrent()
Get the current local transaction context.
|
org.wildfly.common.context.ContextManager<LocalTransactionContext> |
getInstanceContextManager()
Get the context manager; delegates to
getContextManager() . |
XARecoverable |
getRecoveryInterface()
Get the recovery interface for this context.
|
XATerminator |
getXATerminator() |
boolean |
importProviderTransaction()
Attempt to import a provider's current transaction as a local transaction.
|
void |
registerCreationListener(CreationListener creationListener)
Register a transaction creation listener.
|
void |
removeCreationListener(CreationListener creationListener)
Remove a transaction creation listener.
|
void |
resumeRequests()
Cause requests to create new transactions to be allowed after a previous call to
suspendRequests() . |
void |
suspendRequests()
Cause requests to create new transactions to be refused.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
run, runAction, runBiConsumer, runBiFunction, runBiPredicate, runCallable, runConsumer, runExBiConsumer, runExBiFunction, runExBiPredicate, runExceptionAction, runExConsumer, runExFunction, runExIntFunction, runExLongFunction, runExPredicate, runFunction, runIntFunction, runLongFunction, runPredicate
public static final int DEFAULT_TXN_TIMEOUT
public LocalTransactionContext(LocalTransactionProvider provider)
provider
- the local transaction provider@NotNull public static org.wildfly.common.context.ContextManager<LocalTransactionContext> getContextManager()
null
)@NotNull public org.wildfly.common.context.ContextManager<LocalTransactionContext> getInstanceContextManager()
getContextManager()
.getInstanceContextManager
in interface org.wildfly.common.context.Contextual<LocalTransactionContext>
null
)@NotNull public static LocalTransactionContext getCurrent()
null
)public void registerCreationListener(CreationListener creationListener)
creationListener
- the creation listener (must not be null
)public void removeCreationListener(CreationListener creationListener)
creationListener
- the creation listener (must not be null
)@NotNull public LocalTransaction beginTransaction(int timeout) throws SystemException, SecurityException
timeout
- the transaction timeout to use for this transactionnull
)SystemException
- if the transaction creation failed for some reason, one of the possible reasons being
suspended serverSecurityException
- if the caller is not authorized to create a local transaction in this context@NotNull public LocalTransaction beginTransaction(int timeout, boolean failOnSuspend) throws SystemException, SecurityException
timeout
- the transaction timeout to use for this transactionfailOnSuspend
- true
to fail if the server is suspended, false
to begin the transaction even if the server is suspendednull
)SystemException
- if the transaction creation failed for some reason, one of the possible reasons being
suspended serverSecurityException
- if the caller is not authorized to create a local transaction in this contextpublic ImportResult<LocalTransaction> findOrImportTransaction(Xid xid, int timeout, boolean doNotImport) throws XAException
xid
- the XID of the transaction to import (must not be null
)timeout
- the transaction timeout to use, if newdoNotImport
- true
to indicate that a non-existing transaction should not be imported, false
otherwisenull
if (and only if) doNotImport
is true
and the transaction didn't exist locallyXAException
- if a problem occurred while importing the transaction@NotNull public ImportResult<LocalTransaction> findOrImportTransaction(Xid xid, int timeout) throws XAException
xid
- the XID of the transaction to import (must not be null
)timeout
- the transaction timeout to use, if newnull
)XAException
- if a problem occurred while importing the transactionpublic boolean importProviderTransaction() throws SystemException
true
if the transaction was associated, false
if the provider had no current transactionSystemException
- if an error occurred acquiring the current transaction from the providerIllegalStateException
- if the thread is associated with a transaction that isn't equal to the provider's transaction@NotNull public XARecoverable getRecoveryInterface()
findOrImportTransaction(Xid, int)
.null
)@NotNull public XATerminator getXATerminator()
public void suspendRequests() throws SecurityException
SecurityException
- if a security manager is present and the caller does not have the suspendRequests
TransactionPermission
public void resumeRequests() throws SecurityException
suspendRequests()
.SecurityException
- if a security manager is present and the caller does not have the resumeRequests
TransactionPermission
Copyright © 2017 JBoss by Red Hat. All rights reserved.