@Override public void set(String identifier, Object value) { txm.putResource(identifier, value); }
protected EventCollection getCollection() { EventCollection collection = (EventCollection) this.tm.getResource(EVENT_COLLECTION); if (collection == null) { collection = emitter.newCollection(); this.tm.putResource(EVENT_COLLECTION, collection); registerSync(); } return collection; }
@Override public void set(String identifier, Object value) { txm.putResource(identifier, value); }
@SuppressWarnings("unchecked") public static void addToUpdatableSet(TransactionManager txm, Transformable transformable) { if (transformable == null) { return; } Set<Transformable> toBeUpdated = (Set<Transformable>) txm.getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { toBeUpdated = new LinkedHashSet<Transformable>(); txm.putResource(APP_UPDETEABLE_RESOURCE, toBeUpdated); } toBeUpdated.add(transformable); }
private void registerUpdateSync() { if (this.txm.getResource("TriggerUpdateTransactionSynchronization-"+this.toString()) == null) { this.txm.registerTransactionSynchronization(new TriggerUpdateTransactionSynchronization(txm, env)); this.txm.putResource("TriggerUpdateTransactionSynchronization-"+this.toString(), true); } }
public void dispose() { resetApplicationScopedPersistenceContext(); if ( this.internalCmdScopedEntityManagerFlag ) { EntityManager cmdScopedEntityManager = getInternalCommandScopedEntityManager(); if ( cmdScopedEntityManager != null && cmdScopedEntityManager.isOpen() ) { cmdScopedEntityManager.close(); } this.env.set( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, null ); this.txm.putResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, null ); this.internalCmdScopedEntityManagerFlag = false; } }
protected EventCollection getCollection() { EventCollection collection = (EventCollection) this.tm.getResource(EVENT_COLLECTION); if (collection == null) { collection = emitter.newCollection(); this.tm.putResource(EVENT_COLLECTION, collection); registerSync(); } return collection; }
public EntityManager getCommandScopedEntityManager() { // first check if there is already cmd scoped entity manager as transactional resource EntityManager cmdScopedEntityManager = getInternalCommandScopedEntityManager(); if ( cmdScopedEntityManager == null) { cmdScopedEntityManager = (EntityManager) env.get( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER ); if (cmdScopedEntityManager != null) { this.txm.putResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, cmdScopedEntityManager ); } if ( cmdScopedEntityManager == null) { internalCmdScopedEntityManagerFlag = true; cmdScopedEntityManager = this.emf.createEntityManager(); // no need to call joinTransaction as it will do so if one already exists this.env.set( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, cmdScopedEntityManager ); this.txm.putResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, cmdScopedEntityManager ); } else { internalCmdScopedEntityManagerFlag = false; } } cmdScopedEntityManager.joinTransaction(); if (this.appScopedEntityManager != null) { this.appScopedEntityManager.joinTransaction(); } return cmdScopedEntityManager; }
public EntityManager getApplicationScopedEntityManager() { if ( this.appScopedEntityManager == null ) { // Use the App scoped EntityManager if the user has provided it, and it is open. this.appScopedEntityManager = (EntityManager) this.env.get( EnvironmentName.APP_SCOPED_ENTITY_MANAGER ); if ( this.appScopedEntityManager != null && !this.appScopedEntityManager.isOpen() ) { throw new RuntimeException("Provided APP_SCOPED_ENTITY_MANAGER is not open"); } if ( this.appScopedEntityManager == null ) { internalAppScopedEntityManagerFlag = true; this.appScopedEntityManager = this.emf.createEntityManager(); this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER, this.appScopedEntityManager ); if (txm.getStatus() == TransactionManager.STATUS_ACTIVE) { this.txm.putResource(EnvironmentName.APP_SCOPED_ENTITY_MANAGER, this.appScopedEntityManager ); } } else { internalAppScopedEntityManagerFlag = false; } } return appScopedEntityManager; }
public static void registerTransactionSyncInContainer(TransactionManager txm, OrderedTransactionSynchronization synchronization) { TransactionSynchronizationContainer container = (TransactionSynchronizationContainer)txm.getResource(TransactionSynchronizationContainer.RESOURCE_KEY); if (container == null) { container = new TransactionSynchronizationContainer(); txm.registerTransactionSynchronization( container ); txm.putResource(TransactionSynchronizationContainer.RESOURCE_KEY, container); } container.addTransactionSynchronization(synchronization); }