use of javax.transaction.NotSupportedException in project carbon-business-process by wso2.
the class TransactionManagerProvider method doNonTransactionalWork.
public void doNonTransactionalWork(Runnable runnable) throws NotSupportedException {
TransactionManager tm;
Transaction transaction;
try {
tm = getTransactionManager();
transaction = tm.suspend();
} catch (Exception e) {
NotSupportedException nse = new NotSupportedException(e.getMessage());
nse.initCause(e);
throw nse;
}
runnable.run();
try {
tm.resume(transaction);
} catch (Exception e) {
try {
transaction.setRollbackOnly();
} catch (SystemException se2) {
throw new GeneralException(se2);
}
NotSupportedException nse = new NotSupportedException(e.getMessage());
nse.initCause(e);
throw nse;
}
}
use of javax.transaction.NotSupportedException in project carbon-business-process by wso2.
the class TransactionManagerProvider method doNonTransactionalWork.
public void doNonTransactionalWork(java.lang.Runnable runnable) throws NotSupportedException {
TransactionManager transactionManager = null;
Transaction transaction = null;
try {
transactionManager = getTransactionManager();
transaction = transactionManager.suspend();
} catch (Exception e) {
NotSupportedException nse = new NotSupportedException(e.getMessage());
nse.initCause(e);
log.error(nse.getLocalizedMessage(), nse);
throw nse;
}
runnable.run();
try {
transactionManager.resume(transaction);
} catch (Exception e) {
log.error(e.getLocalizedMessage(), e);
try {
transaction.setRollbackOnly();
} catch (SystemException se2) {
throw new GeneralException(se2);
}
NotSupportedException nse = new NotSupportedException(e.getMessage());
nse.initCause(e);
throw nse;
}
}
use of javax.transaction.NotSupportedException in project narayana by jbosstm.
the class Test02 method main.
public static void main(String[] args) {
Setup orbClass = null;
try {
boolean needOrb = true;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-local")) {
needOrb = false;
}
}
if (needOrb) {
Class c = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.jbossts.qa.Utils.OrbSetup");
orbClass = (Setup) c.newInstance();
orbClass.start(args);
}
boolean correct = true;
javax.transaction.TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
correct = correct && (transactionManager.getTransaction() == null);
correct = correct && (transactionManager.getStatus() == Status.STATUS_NO_TRANSACTION);
transactionManager.begin();
correct = correct && (transactionManager.getTransaction() != null);
correct = correct && (transactionManager.getStatus() == Status.STATUS_ACTIVE);
try {
transactionManager.begin();
correct = false;
} catch (NotSupportedException notSupportedException) {
}
correct = correct && (transactionManager.getTransaction() != null);
correct = correct && (transactionManager.getStatus() == Status.STATUS_ACTIVE);
transactionManager.commit();
correct = correct && (transactionManager.getTransaction() == null);
correct = correct && (transactionManager.getStatus() == Status.STATUS_NO_TRANSACTION);
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.print("Test02.main: ");
exception.printStackTrace(System.err);
} catch (Error error) {
System.out.println("Failed");
System.err.print("Test02.main: ");
error.printStackTrace(System.err);
}
try {
if (orbClass != null) {
orbClass.stop();
}
} catch (Exception exception) {
System.err.print("Test02.main: ");
exception.printStackTrace(System.err);
} catch (Error error) {
System.err.print("Test02.main: ");
error.printStackTrace(System.err);
}
}
use of javax.transaction.NotSupportedException in project galley by Commonjava.
the class FastLocalCacheProvider method createFile.
@Deprecated
@Override
public void createFile(ConcreteResource resource) throws IOException {
final String pathKey = getKeyForResource(resource);
try {
lockByISPN(nfsOwnerCache, resource, LockLevel.write);
final File nfsFile = getNFSDetachedFile(resource);
if (!nfsFile.exists()) {
nfsFile.getParentFile().mkdirs();
nfsFile.createNewFile();
}
} catch (NotSupportedException | SystemException | InterruptedException e) {
final String errorMsg = String.format("[galley] Cache TransactionManager got error, locking key is %s", pathKey);
logger.error(errorMsg, e);
throw new IllegalStateException(errorMsg, e);
} finally {
unlockByISPN(nfsOwnerCache, false, resource);
}
}
use of javax.transaction.NotSupportedException in project narayana by jbosstm.
the class UserTransactionUnitTest method testSubordinate.
@Test
public void testSubordinate() throws Exception {
ThreadActionData.purgeActions();
UserTransactionImple ut = new UserTransactionImple();
assertTrue(ut.createSubordinate() != null);
ut.begin();
try {
ut.createSubordinate();
fail();
} catch (final NotSupportedException ex) {
}
ut.commit();
}
Aggregations