@Override public Object get(String identifier) { return txm.getResource(identifier); }
@Override public void beforeCompletion() { EventCollection collection = (EventCollection) tm.getResource(EVENT_COLLECTION); logger.debug("About to deliver {} to emitter {}", collection, emitter); Collection<InstanceView<?>> data = collection.getEvents(); this.events = data.stream() .map(event -> { event.copyFromSource(); return event; }) .collect(Collectors.toSet()); emitter.deliver(events); logger.debug("Collection {} delivered to {}", collection, emitter); }
protected EntityManager getEntityManager(Command<?> command) { EntityManager em = (EntityManager) txm.getResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER); if (em != null && em.isOpen() && em.getEntityManagerFactory().equals(emf)) { return em; } return null; }
protected EntityManager getEntityManagerFromTransaction(Environment env) { if (env.get(EnvironmentName.TRANSACTION_MANAGER) instanceof TransactionManager) { TransactionManager txm = (TransactionManager) env.get(EnvironmentName.TRANSACTION_MANAGER); EntityManager em = (EntityManager) txm.getResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER); return em; } return null; }
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 Object get(String identifier) { return txm.getResource(identifier); }
protected EntityManager getInternalCommandScopedEntityManager() { return (EntityManager) txm.getResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER); }
@SuppressWarnings("unchecked") public static void removeFromUpdatableSet(TransactionManager txm, Transformable transformable) { Set<Transformable> toBeUpdated = (Set<Transformable>) txm.getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { return; } toBeUpdated.remove(transformable); }
@SuppressWarnings("unchecked") public static Set<Transformable> getUpdateableSet(TransactionManager txm) { Set<Transformable> toBeUpdated = (Set<Transformable>) txm.getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { return Collections.emptySet(); } return new LinkedHashSet<Transformable>(toBeUpdated); } }
@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); }
protected EntityManager getEntityManager(Command<?> command) { EntityManager em = (EntityManager) txm.getResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER); if (em != null && em.isOpen() && em.getEntityManagerFactory().equals(emf)) { return em; } return null; }
@Override public void beforeCompletion() { EventCollection collection = (EventCollection) tm.getResource(EVENT_COLLECTION); logger.debug("About to deliver {} to emitter {}", collection, emitter); Collection<InstanceView<?>> data = collection.getEvents(); this.events = data.stream() .map(event -> { event.copyFromSource(); return event; }) .collect(Collectors.toSet()); emitter.deliver(events); logger.debug("Collection {} delivered to {}", collection, emitter); }
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); } }
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 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); }
appScopedEM = (EntityManager) txm.getResource(EnvironmentName.APP_SCOPED_ENTITY_MANAGER); EntityManager cmdScopedEM = (EntityManager) txm.getResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER); if (cmdScopedEM == null) { cmdScopedEM = ((EntityManager)environment.get(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER));