本文整理汇总了Java中javax.transaction.Status.STATUS_ACTIVE属性的典型用法代码示例。如果您正苦于以下问题:Java Status.STATUS_ACTIVE属性的具体用法?Java Status.STATUS_ACTIVE怎么用?Java Status.STATUS_ACTIVE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.transaction.Status
的用法示例。
在下文中一共展示了Status.STATUS_ACTIVE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
public Object call(Callable<Object> callable, IInvocationCtx ctx)
throws Exception {
if (ctx.getTransactionManager().getStatus() == Status.STATUS_ACTIVE) {
return withTx.call(callable, ctx);
} else {
return withoutTx.call(callable, ctx);
}
}
示例2: tearDown
protected void tearDown() throws Exception
{
if ((testTX.getStatus() == Status.STATUS_ACTIVE) || (testTX.getStatus() == Status.STATUS_MARKED_ROLLBACK))
{
testTX.rollback();
}
AuthenticationUtil.clearCurrentSecurityContext();
super.tearDown();
}
示例3: tearDown
@Override
protected void tearDown() throws Exception
{
if ((userTransaction.getStatus() == Status.STATUS_ACTIVE) || (userTransaction.getStatus() == Status.STATUS_MARKED_ROLLBACK))
{
userTransaction.rollback();
}
AuthenticationUtil.clearCurrentSecurityContext();
super.tearDown();
}
示例4: registerTransactionSynchronization
/**
* Register a transaction synchronization for closing the given LobCreator,
* preferring Spring transaction synchronization and falling back to
* plain JTA transaction synchronization.
* @param lobCreator the LobCreator to close after transaction completion
* @param jtaTransactionManager the JTA TransactionManager to fall back to
* when no Spring transaction synchronization is active (may be {@code null})
* @throws IllegalStateException if there is neither active Spring transaction
* synchronization nor active JTA transaction synchronization
*/
public static void registerTransactionSynchronization(
LobCreator lobCreator, TransactionManager jtaTransactionManager) throws IllegalStateException {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
logger.debug("Registering Spring transaction synchronization for LobCreator");
TransactionSynchronizationManager.registerSynchronization(
new SpringLobCreatorSynchronization(lobCreator));
}
else {
if (jtaTransactionManager != null) {
try {
int jtaStatus = jtaTransactionManager.getStatus();
if (jtaStatus == Status.STATUS_ACTIVE || jtaStatus == Status.STATUS_MARKED_ROLLBACK) {
logger.debug("Registering JTA transaction synchronization for LobCreator");
jtaTransactionManager.getTransaction().registerSynchronization(
new JtaLobCreatorSynchronization(lobCreator));
return;
}
}
catch (Throwable ex) {
throw new TransactionSystemException(
"Could not register synchronization with JTA TransactionManager", ex);
}
}
throw new IllegalStateException("Active Spring transaction synchronization or active " +
"JTA transaction with specified [javax.transaction.TransactionManager] required");
}
}
示例5: teardown
@After
public void teardown() throws Exception
{
if (txn.getStatus() == Status.STATUS_ACTIVE)
{
txn.rollback();
}
}
示例6: tearDown
public void tearDown() throws Exception
{
if (txn.getStatus() == Status.STATUS_ACTIVE)
{
txn.rollback();
}
authenticationComponent.clearCurrentSecurityContext();
super.tearDown();
}
示例7: tearDown
@Override
protected void tearDown() throws Exception
{
if (testTX.getStatus() == Status.STATUS_ACTIVE)
{
testTX.rollback();
}
super.tearDown();
}
示例8: isActive
/**
* {@inheritDoc}
*/
public boolean isActive() {
try {
return getTransactionSupport().getTransactionManager().getStatus() == Status.STATUS_ACTIVE;
} catch (SystemException e) {
throw new RuntimeException(e);
}
}
示例9: isTransactionActive
/**
* Checks if the current transaction is active, rolled back or marked for
* rollback.
*
* @return {@code true} if the current transaction is active, rolled back or
* marked for rollback, {@code false} otherwise.
* @throws SystemException thrown if the transaction manager encounters an
* unexpected error condition
*/
private boolean isTransactionActive(TransactionManager transactionManager) throws SystemException {
switch (transactionManager.getStatus()) {
case Status.STATUS_ACTIVE:
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ROLLEDBACK:
return true;
default:
return false;
}
}
示例10: canRegisterSynchronization
public boolean canRegisterSynchronization() {
try {
return (this.transactionManager.getStatus() == Status.STATUS_ACTIVE);
}
catch (SystemException ex) {
throw new TransactionException("Could not determine JTA transaction status", ex);
}
}
示例11: transactionManager
private TransactionManager transactionManager() {
return new TransactionManager() {
private int status = Status.STATUS_NO_TRANSACTION;
@Override
public void begin() throws NotSupportedException, SystemException {
status = Status.STATUS_ACTIVE;
}
@Override
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
status = Status.STATUS_NO_TRANSACTION;
}
@Override
public void rollback() throws IllegalStateException, SecurityException, SystemException {
status = Status.STATUS_NO_TRANSACTION;
}
@Override
public void setRollbackOnly() throws IllegalStateException, SystemException {
// Nothing to do
}
@Override
public int getStatus() throws SystemException {
return status;
}
@Override
public Transaction getTransaction() throws SystemException {
return transaction();
}
@Override
public void setTransactionTimeout(int seconds) throws SystemException {
throw new AssertionError("setTransactionTimeout");
}
@Override
public Transaction suspend() throws SystemException {
return transaction();
}
@Override
public void resume(Transaction tobj) throws InvalidTransactionException, IllegalStateException, SystemException {
// nothing to do
}
};
}
示例12: getStatus
@Override
public int getStatus() {
return Integer.valueOf( 0 ).equals( getLocalId() ) ?
Status.STATUS_NO_TRANSACTION : Status.STATUS_ACTIVE;
}
示例13: registerJtaSynchronization
/**
* Register a JTA synchronization for the given Session, if any.
* @param sessionHolder the existing thread-bound SessionHolder, if any
* @param session the Session to register
* @param sessionFactory the SessionFactory that the Session was created with
* @param jdbcExceptionTranslator SQLExcepionTranslator to use for flushing the
* Session on transaction synchronization (may be {@code null})
*/
private static void registerJtaSynchronization(Session session, SessionFactory sessionFactory,
SQLExceptionTranslator jdbcExceptionTranslator, SessionHolder sessionHolder) {
// JTA synchronization is only possible with a javax.transaction.TransactionManager.
// We'll check the Hibernate SessionFactory: If a TransactionManagerLookup is specified
// in Hibernate configuration, it will contain a TransactionManager reference.
TransactionManager jtaTm = getJtaTransactionManager(sessionFactory, session);
if (jtaTm != null) {
try {
Transaction jtaTx = jtaTm.getTransaction();
if (jtaTx != null) {
int jtaStatus = jtaTx.getStatus();
if (jtaStatus == Status.STATUS_ACTIVE || jtaStatus == Status.STATUS_MARKED_ROLLBACK) {
logger.debug("Registering JTA transaction synchronization for new Hibernate Session");
SessionHolder holderToUse = sessionHolder;
// Register JTA Transaction with existing SessionHolder.
// Create a new SessionHolder if none existed before.
if (holderToUse == null) {
holderToUse = new SessionHolder(jtaTx, session);
}
else {
holderToUse.addSession(jtaTx, session);
}
jtaTx.registerSynchronization(
new SpringJtaSynchronizationAdapter(
new SpringSessionSynchronization(holderToUse, sessionFactory, jdbcExceptionTranslator, true),
jtaTm));
holderToUse.setSynchronizedWithTransaction(true);
if (holderToUse != sessionHolder) {
TransactionSynchronizationManager.bindResource(sessionFactory, holderToUse);
}
}
}
}
catch (Throwable ex) {
throw new DataAccessResourceFailureException(
"Could not register synchronization with JTA TransactionManager", ex);
}
}
}
示例14: tearDown
@After
public void tearDown() throws Exception
{
if (trans != null)
{
try
{
trans.commit();
trans = null;
}
catch (Exception e)
{
if ((trans.getStatus() == Status.STATUS_ACTIVE) ||
(trans.getStatus() == Status.STATUS_MARKED_ROLLBACK))
{
trans.rollback();
trans = null;
}
}
}
RetryingTransactionCallback<Void> cleanup = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
Set<NodeRef> adminGuestUserHomeFolders = deleteNonAdminGuestUsers();
deleteNonAdminGuestFolders(adminGuestUserHomeFolders);
deleteAllTenants();
return null;
}
};
try
{
transactionService.getRetryingTransactionHelper().doInTransaction(cleanup);
}
finally
{
AuthenticationUtil.clearCurrentSecurityContext();
userNameMatcher.setUserNamesAreCaseSensitive(false); // Put back the default
}
}
示例15: begin
@Override
public void begin() {
status = Status.STATUS_ACTIVE;
stubCalls.add("begin()");
}