@Test public void testNoTX() throws ResourceException, IllegalStateException, RollbackException, SystemException { final UserTransactionManager tm = mock(UserTransactionManager.class); when(tm.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION); BasicTransactionAssistanceFactory f = new BasicTransactionAssistanceFactoryImpl("a"){ @Override protected UserTransactionManager getTM() { return tm; } }; try{ f.getTransactionAssistant(); fail("no exception"); }catch(ResourceException e){ } }
@Override public TransactionAssistant getTransactionAssistant() throws ResourceException { final CommitRollbackCallback commitRollbackCallback = TransactionConfigurator.getCommitRollbackCallback(jndiName); MicroserviceXAResource ms = new MicroserviceXAResource(jndiName, commitRollbackCallback); UserTransactionManager utm = getTM(); try { if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){ throw new ResourceException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus()); } Transaction tx = utm.getTransaction(); tx.enlistResource(ms); return new AtomikosTransactionAssistantImpl(ms); } catch (Exception e) { throw new ResourceException("Unable to get transaction status", e); } }
BasicTransactionAssistanceFactoryImpl implements BasicTransactionAssistanceFactory { @Override public TransactionAssistant getTransactionAssistant() throws ResourceException { final CommitRollbackCallback commitRollbackCallback = TransactionConfigurator.getCommitRollbackCallback(jndiName); MicroserviceXAResource ms = new MicroserviceXAResource(jndiName, commitRollbackCallback); UserTransactionManager utm = getTM(); try { if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){ throw new ResourceException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus()); } Transaction tx = utm.getTransaction(); tx.enlistResource(ms); return new AtomikosTransactionAssistantImpl(ms); } catch (Exception e) { throw new ResourceException("Unable to get transaction status", e); } } }
BasicTransactionAssistanceFactoryImpl implements BasicTransactionAssistanceFactory { @Override public TransactionAssistant getTransactionAssistant() throws ResourceException { final CommitRollbackCallback commitRollbackCallback = TransactionConfigurator.getCommitRollbackCallback(jndiName); MicroserviceXAResource ms = new MicroserviceXAResource(jndiName, commitRollbackCallback); UserTransactionManager utm = getTM(); try { if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){ throw new ResourceException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus()); } Transaction tx = utm.getTransaction(); tx.enlistResource(ms); return new AtomikosTransactionAssistantImpl(ms); } catch (Exception e) { throw new ResourceException("Unable to get transaction status", e); } } BasicTransactionAssistanceFactoryImpl(String jndiName); }
BasicTransactionAssistanceFactoryImpl implements BasicTransactionAssistanceFactory { @Override public TransactionAssistant getTransactionAssistant() throws ResourceException { final CommitRollbackCallback commitRollbackCallback = TransactionConfigurator.getCommitRollbackCallback(jndiName); MicroserviceXAResource ms = new MicroserviceXAResource(jndiName, commitRollbackCallback); UserTransactionManager utm = getTM(); try { if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){ throw new ResourceException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus()); } Transaction tx = utm.getTransaction(); tx.enlistResource(ms); return new AtomikosTransactionAssistantImpl(ms); } catch (Exception e) { throw new ResourceException("Unable to get transaction status", e); } } BasicTransactionAssistanceFactoryImpl(String jndiName); @Override TransactionAssistant getTransactionAssistant(); }
BasicTransactionAssistanceFactoryImpl implements BasicTransactionAssistanceFactory { @Override public TransactionAssistant getTransactionAssistant() throws ResourceException { final CommitRollbackCallback commitRollbackCallback = TransactionConfigurator.getCommitRollbackCallback(jndiName); MicroserviceXAResource ms = new MicroserviceXAResource(jndiName, commitRollbackCallback); UserTransactionManager utm = getTM(); try { if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){ throw new ResourceException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus()); } Transaction tx = utm.getTransaction(); tx.enlistResource(ms); return new AtomikosTransactionAssistantImpl(ms); } catch (Exception e) { throw new ResourceException("Unable to get transaction status", e); } } BasicTransactionAssistanceFactoryImpl(String jndiName); @Override TransactionAssistant getTransactionAssistant();  }