use of javax.transaction.NotSupportedException in project neo4j-mobile-android by neo4j-contrib.
the class TxManager method begin.
public void begin() throws NotSupportedException, SystemException {
if (blocked) {
throw new SystemException("TxManager is preventing new transactions from starting " + "due a shutdown is imminent");
}
assertTmOk("tx begin");
Thread thread = Thread.currentThread();
TransactionImpl tx = txThreadMap.get(thread);
if (tx != null) {
throw logAndReturn("TM error tx begin", new NotSupportedException("Nested transactions not supported"));
}
tx = new TransactionImpl(this);
txThreadMap.put(thread, tx);
int concurrentTxCount = txThreadMap.size();
if (concurrentTxCount > peakConcurrentTransactions) {
peakConcurrentTransactions = concurrentTxCount;
}
startedTxCount.incrementAndGet();
// start record written on resource enlistment
}
use of javax.transaction.NotSupportedException in project wildfly by wildfly.
the class TransactionalBatcher method createBatch.
@Override
public TransactionBatch createBatch() {
if (this.tm == null)
return NON_TX_BATCH;
TransactionBatch batch = getCurrentBatch();
try {
if ((batch != null) && (batch.getState() == Batch.State.ACTIVE)) {
return batch.interpose();
}
this.tm.suspend();
this.tm.begin();
Transaction tx = this.tm.getTransaction();
tx.registerSynchronization(CURRENT_BATCH_SYNCHRONIZATION);
batch = new TransactionalBatch<>(tx, this.exceptionTransformer);
setCurrentBatch(batch);
return batch;
} catch (RollbackException | SystemException | NotSupportedException e) {
throw this.exceptionTransformer.apply(e);
}
}
use of javax.transaction.NotSupportedException in project wildfly by wildfly.
the class BMTStateful method createTransaction.
public void createTransaction() {
try {
final UserTransaction userTransaction = ejbContext.getUserTransaction();
Assert.assertEquals(Status.STATUS_NO_TRANSACTION, userTransaction.getStatus());
userTransaction.begin();
} catch (SystemException e) {
throw new RuntimeException(e);
} catch (NotSupportedException e) {
throw new RuntimeException(e);
}
}
use of javax.transaction.NotSupportedException in project wildfly by wildfly.
the class TestEJBRunnable method run.
@Override
public void run() {
// asserts correct class loader is set
try {
Thread.currentThread().getContextClassLoader().loadClass(this.getClass().getName());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
// asserts correct naming context is set
final InitialContext initialContext;
try {
initialContext = new InitialContext();
} catch (NamingException e) {
throw new RuntimeException(e);
}
final EJBContext ejbContext;
try {
ejbContext = (SessionContext) initialContext.lookup("java:comp/EJBContext");
} catch (NamingException e) {
throw new RuntimeException(e);
}
// asserts correct security context is set
final Principal callerPrincipal = ejbContext.getCallerPrincipal();
if (expectedPrincipal != null) {
if (!expectedPrincipal.equals(callerPrincipal)) {
throw new IllegalStateException("the caller principal " + callerPrincipal + " is not the expected " + expectedPrincipal);
}
} else {
if (callerPrincipal != null) {
throw new IllegalStateException("the caller principal " + callerPrincipal + " is not the expected " + expectedPrincipal);
}
}
// assert tx context is set
try {
final UserTransaction userTransaction = (UserTransaction) initialContext.lookup("java:comp/UserTransaction");
userTransaction.begin();
userTransaction.rollback();
} catch (NamingException | SystemException | NotSupportedException e) {
throw new RuntimeException(e);
}
}
use of javax.transaction.NotSupportedException in project graphdb by neo4j-attic.
the class MasterImpl method beginTx.
private Transaction beginTx(SlaveContext txId) {
try {
TransactionManager txManager = graphDbConfig.getTxModule().getTxManager();
txManager.begin();
Transaction tx = txManager.getTransaction();
transactions.put(txId, tx);
return tx;
} catch (NotSupportedException e) {
throw new RuntimeException(e);
} catch (SystemException e) {
throw new RuntimeException(e);
}
}
Aggregations