/** * 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); }
/** * Stores all of the entities associated with the specified transaction. * As per the spec 9.6.4, entities must be synchronized with the datastore * when an ejbFind<METHOD> is called. * Also, all entities within entire transaction should be synchronized before * a remove, otherwise there may be problems with 'cascade delete'. * * @param tx the transaction that associated entites will be stored */ public static void synchronizeEntitiesWithinTransaction(Transaction tx) { // If there is no transaction, there is nothing to synchronize. if(tx != null) { getGlobalTxEntityMap().synchronizeEntities(tx); } }
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; }