public GlobalTxSynchronization getGlobalSynchronization(Transaction tx) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = (GlobalTxSynchronization) txSynch.get(tx); if(globalSync == null) { globalSync = new GlobalTxSynchronization(tx); txSynch.set(tx, globalSync); tx.registerSynchronization(globalSync); } return globalSync; }
public void beforeCompletion() { if(log.isTraceEnabled()) { log.trace("beforeCompletion called for tx " + tx); } // let the runtime exceptions fall out, so the committer can determine // the root cause of a rollback synchronize(); for(Synchronization sync : otherSync) { sync.beforeCompletion(); } }
private Views getViews() { Transaction tx = txLocal.getTransaction(); GlobalTxSynchronization globalSync; try { globalSync = txLocal.getGlobalSynchronization(tx); } catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); } catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); } if(globalSync == null) throw new IllegalStateException("Global transaction synchronization is not available for transaction " + tx); Views views = (Views) globalSync.getTxLocal(viewsTxLocalKey); if(views == null) { views = new Views(tx); globalSync.putTxLocal(viewsTxLocalKey, views); globalSync.addSynchronization(new SchemaSynchronization(views)); } return views; }
/** * sync all EntityEnterpriseContext that are involved (and changed) * within a transaction. */ public void synchronizeEntities(Transaction tx) { GlobalTxSynchronization globalSync = (GlobalTxSynchronization) txSynch.get(tx); if(globalSync != null) { globalSync.synchronize(); } }
/** * associate instance with transaction */ private void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = getGlobalSynchronization(tx); //There should be only one thread associated with this tx at a time. //Therefore we should not need to synchronize on entityFifoList to ensure exclusive //access. entityFifoList is correct since it was obtained in a synch block. globalSync.associate(entity); }