@Test public void test_addGlobalSession() throws TransactionException, SQLException { GlobalSession session = GlobalSession.createGlobalSession("test", "test", "test123", 100); String xid = XID.generateXID(session.getTransactionId()); session.setXid(xid); session.setTransactionId(146757978); session.setBeginTime(System.currentTimeMillis()); session.setApplicationData("abc=878s"); session.setStatus(GlobalStatus.Begin); sessionManager.addGlobalSession(session); String sql = "select * from global_table where xid= '"+xid+"'"; String delSql = "delete from global_table where xid= '"+xid+"'"; Connection conn = null; try{ conn = dataSource.getConnection(); ResultSet rs = conn.createStatement().executeQuery(sql); if(rs.next()){ Assertions.assertTrue(true); }else{ Assertions.assertTrue(false); } conn.createStatement().execute(delSql); }finally { if(conn != null){ conn.close(); } } }
@Override public void addGlobalSession(GlobalSession session) throws TransactionException { if (StringUtils.isBlank(taskName)) { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_ADD, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } else { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_UPDATE, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } }
DataBaseSessionManager extends AbstractSessionManager implements SessionManager, SessionLifecycleListener, Initialize { @Override public void addGlobalSession(GlobalSession session) throws TransactionException { if (StringUtils.isBlank(taskName)) { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_ADD, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } else { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_UPDATE, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } } }
DataBaseSessionManager extends AbstractSessionManager implements SessionManager, SessionLifecycleListener, Initialize { @Override public void addGlobalSession(GlobalSession session) throws TransactionException { if (StringUtils.isBlank(taskName)) { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_ADD, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } else { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_UPDATE, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } } DataBaseSessionManager();  DataBaseSessionManager(String name); }
DataBaseSessionManager extends AbstractSessionManager implements SessionManager, SessionLifecycleListener, Initialize { @Override public void addGlobalSession(GlobalSession session) throws TransactionException { if (StringUtils.isBlank(taskName)) { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_ADD, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } else { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_UPDATE, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } } DataBaseSessionManager();  DataBaseSessionManager(String name); @Override void init(); @Override void addGlobalSession(GlobalSession session); @Override void updateGlobalSessionStatus(GlobalSession session, GlobalStatus status); @Override void removeGlobalSession(GlobalSession session); @Override void addBranchSession(GlobalSession globalSession, BranchSession session); @Override void updateBranchSessionStatus(BranchSession session, BranchStatus status); @Override void removeBranchSession(GlobalSession globalSession, BranchSession session); @Override GlobalSession findGlobalSession(String xid); @Override Collection<GlobalSession> allSessions(); @Override List<GlobalSession> findGlobalSessions(SessionCondition condition); }
DataBaseSessionManager extends AbstractSessionManager implements SessionManager, SessionLifecycleListener, Initialize { @Override public void addGlobalSession(GlobalSession session) throws TransactionException { if (StringUtils.isBlank(taskName)) { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_ADD, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } else { boolean ret = transactionStoreManager.writeSession(LogOperation.GLOBAL_UPDATE, session); if (!ret) { throw new StoreException("addGlobalSession failed."); } } } DataBaseSessionManager();  DataBaseSessionManager(String name); @Override void init(); @Override void addGlobalSession(GlobalSession session); @Override void updateGlobalSessionStatus(GlobalSession session, GlobalStatus status); @Override void removeGlobalSession(GlobalSession session); @Override void addBranchSession(GlobalSession globalSession, BranchSession session); @Override void updateBranchSessionStatus(BranchSession session, BranchStatus status); @Override void removeBranchSession(GlobalSession globalSession, BranchSession session); @Override GlobalSession findGlobalSession(String xid); @Override Collection<GlobalSession> allSessions(); @Override List<GlobalSession> findGlobalSessions(SessionCondition condition);  }