use of javax.transaction.NotSupportedException in project aries by apache.
the class TranStrategyTest method testRequiresNew_TmExceptions.
@Test
public void testRequiresNew_TmExceptions() throws Exception {
int[] allStates = new int[] { Status.STATUS_COMMITTED, Status.STATUS_COMMITTING, Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_PREPARED, Status.STATUS_PREPARING, Status.STATUS_ROLLEDBACK, Status.STATUS_MARKED_ROLLBACK, Status.STATUS_ROLLING_BACK, Status.STATUS_UNKNOWN };
// SystemException and NotSupportedException from tm.begin()
Set<Exception> ees = new HashSet<Exception>();
ees.add(new SystemException("KABOOM!"));
ees.add(new NotSupportedException("KABOOM!"));
// from tm.begin()
for (int i = 0; i < allStates.length; i++) {
Iterator<Exception> iterator = ees.iterator();
while (iterator.hasNext()) {
Exception e = iterator.next();
c.reset();
expect(tm.getStatus()).andReturn(allStates[i]);
expect(tm.getTransaction()).andReturn(null).anyTimes();
tm.begin();
expectLastCall().andThrow(e);
requiresNewExceptionCheck(tm, allStates[i]);
}
}
}
use of javax.transaction.NotSupportedException in project meecrowave by apache.
the class RequiredInterceptor method start.
@Override
protected State start() {
try {
final Transaction transaction = transactionManager.getTransaction();
final Transaction current;
if (transaction == null) {
transactionManager.begin();
current = transactionManager.getTransaction();
} else {
current = transaction;
}
return new State(transaction, current);
} catch (final SystemException | NotSupportedException se) {
throw new TransactionalException(se.getMessage(), se);
}
}
use of javax.transaction.NotSupportedException in project meecrowave by apache.
the class RequiredNewInterceptor method start.
@Override
protected State start() {
try {
final Transaction transaction = transactionManager.suspend();
transactionManager.begin();
return new State(transaction, transactionManager.getTransaction());
} catch (final SystemException | NotSupportedException se) {
throw new TransactionalException(se.getMessage(), se);
}
}
use of javax.transaction.NotSupportedException in project smscgateway by RestComm.
the class SchedulerResourceAdaptor method doInjectSms.
private boolean doInjectSms(SmsSet smsSet, boolean callFromSbb) throws NotSupportedException, SystemException, Exception, RollbackException, HeuristicMixedException, HeuristicRollbackException {
if (!callFromSbb) {
// If this call is from SBB it comes with Transaction and no need to start one
SleeTransaction sleeTx = this.sleeTransactionManager.beginSleeTransaction();
}
try {
this.doSetDestCluster(smsSet);
String eventName = null;
switch(smsSet.getType()) {
case SMS_FOR_ESME:
eventName = EVENT_SMPP_SM;
break;
case SMS_FOR_SS7:
eventName = EVENT_SS7_SM;
break;
case SMS_FOR_SIP:
eventName = EVENT_SIP_SM;
break;
}
final FireableEventType eventTypeId = this.eventIdCache.getEventId(eventName);
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
SchedulerActivityImpl activity = new SchedulerActivityImpl(this);
this.sleeEndpoint.startActivityTransacted(activity.getActivityHandle(), activity, ACTIVITY_FLAGS);
try {
this.sleeEndpoint.fireEventTransacted(activity.getActivityHandle(), eventTypeId, event, null, null);
} catch (Exception e) {
if (this.tracer.isSevereEnabled()) {
this.tracer.severe("Failed to fire SmsSet event Class=: " + eventTypeId.getEventClassName(), e);
}
try {
this.sleeEndpoint.endActivityTransacted(activity.getActivityHandle());
} catch (Exception ee) {
}
}
markAsInSystem(smsSet);
} catch (Exception e) {
if (!callFromSbb) {
this.sleeTransactionManager.rollback();
}
throw e;
}
if (!callFromSbb) {
// If this call is from SBB it comes with Transaction and no need to commit here
this.sleeTransactionManager.commit();
}
this.incrementActivityCount();
return true;
}
use of javax.transaction.NotSupportedException in project partyline by Commonjava.
the class InfinispanJFS method updateBlock.
void updateBlock(final FileBlock block) throws IOException {
TransactionManager transactionManager = blockCache.getAdvancedCache().getTransactionManager();
try {
transactionManager.begin();
blockCache.put(block.getBlockID(), block);
} catch (NotSupportedException | SystemException e) {
try {
transactionManager.rollback();
throw new PartylineException("Failed to begin transaction. Rolling back. Block: " + block.getBlockID(), e);
} catch (SystemException e1) {
LoggerFactory.getLogger(getClass().getName()).error("System Exception during transaction rollback involving Block: " + block.getBlockID(), e1);
}
} finally {
try {
transactionManager.commit();
} catch (RollbackException | HeuristicMixedException | HeuristicRollbackException | SystemException e) {
LoggerFactory.getLogger(getClass().getName()).error("Exception during transaction commit involving block: " + block.getBlockID(), e);
}
}
}
Aggregations