List of usage examples for javax.transaction TransactionManager getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.exolab.castor.jdo.engine.GlobalDatabaseImpl.java
/** * @inheritDoc//from www. j a va 2 s. c om * @see javax.transaction.Synchronization#afterCompletion(int) */ public void afterCompletion(final int status) { try { // XXX [SMH]: Find another test for txNotInProgress if (_transaction == null || _ctx == null) { throw new IllegalStateException(Messages.message("jdo.txNotInProgress")); } if (_ctx.getStatus() == Status.STATUS_ROLLEDBACK) { return; } if (_ctx.getStatus() != Status.STATUS_PREPARED && status != Status.STATUS_ROLLEDBACK) { throw new IllegalStateException( "Unexpected state: afterCompletion called at status " + _ctx.getStatus()); } switch (status) { case Status.STATUS_COMMITTED: try { _ctx.commit(); } catch (TransactionAbortedException except) { _log.fatal(Messages.format("jdo.fatalException", except)); _ctx.rollback(); } return; case Status.STATUS_ROLLEDBACK: _ctx.rollback(); return; case Status.STATUS_UNKNOWN: _ctx.rollback(); try { DatabaseContext context = DatabaseRegistry.getDatabaseContext(_dbName); TransactionManager transactionManager = context.getTransactionManager(); if (AtomikosTransactionManagerFactory.MANAGER_CLASS_NAME .equals(transactionManager.getClass().getName())) { // Accept 'unknown' as legal state for Atomikos as this state // is returned for read-only transactions. As nothing has changed // during the transaction it doesn't matter if we do a commit or // rollback. The handling of 'unknown' does not comply to J2EE spec. return; } } catch (Exception ex) { _log.fatal(Messages.format("jdo.fatalException", ex)); } throw new IllegalStateException("Unexpected state: afterCompletion called with status " + status); default: _ctx.rollback(); throw new IllegalStateException("Unexpected state: afterCompletion called with status " + status); } } finally { unregisterSynchronizables(); if (_txMap != null && _transaction != null) { _txMap.remove(_transaction); _txMap = null; } } }
From source file:org.springframework.transaction.jta.SpringJtaSynchronizationAdapter.java
/** * Create a new SpringJtaSynchronizationAdapter for the given Spring * TransactionSynchronization and JTA TransactionManager. * <p>Note that this adapter will never perform a rollback-only call on WebLogic, * since WebLogic Server is known to automatically mark the transaction as * rollback-only in case of a {@code beforeCompletion} exception. Hence, * on WLS, this constructor is equivalent to the single-arg constructor. * @param springSynchronization the Spring TransactionSynchronization to delegate to * @param jtaTransactionManager the JTA TransactionManager to use for rollback-only * setting in case of an exception thrown in {@code beforeCompletion} * (can be omitted if the JTA provider itself marks the transaction rollback-only * in such a scenario, which is required by the JTA specification as of JTA 1.1) *//* w w w . jav a 2 s.c o m*/ public SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, @Nullable TransactionManager jtaTransactionManager) { this(springSynchronization); if (jtaTransactionManager != null && !jtaTransactionManager.getClass().getName().startsWith("weblogic.")) { this.jtaTransaction = new UserTransactionAdapter(jtaTransactionManager); } }