public void afterPropertiesSet() throws Exception { environment = EnvironmentFactory.newEnvironment(); if ( entityManagerFactory != null ) { environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, entityManagerFactory); } if ( transactionManager != null ){ environment.set(EnvironmentName.TRANSACTION_MANAGER, transactionManager); } if ( globals != null ) { environment.set(EnvironmentName.GLOBALS, globals); } if ( dateFormats != null ) { environment.set(EnvironmentName.DATE_FORMATS, dateFormats); } if ( calendars != null ) { environment.set(EnvironmentName.CALENDARS, calendars); } if ( objectMarshallersOrder != null && objectMarshallersOrder.size() > 0 ) { List<ObjectMarshallingStrategy> strategies = getStrategies(); environment.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,strategies.toArray(new ObjectMarshallingStrategy[]{})); } if ( appScopedEntityManager != null ) { environment.set(EnvironmentName.APP_SCOPED_ENTITY_MANAGER, appScopedEntityManager); } if ( cmdScopedEntityManager != null ) { environment.set(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, cmdScopedEntityManager); } }
public void afterPropertiesSet() throws Exception { environment = EnvironmentFactory.newEnvironment(); if ( entityManagerFactory != null ) { environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, entityManagerFactory); } if ( transactionManager != null ){ environment.set(EnvironmentName.TRANSACTION_MANAGER, transactionManager); } if ( globals != null ) { environment.set(EnvironmentName.GLOBALS, globals); } if ( dateFormats != null ) { environment.set(EnvironmentName.DATE_FORMATS, dateFormats); } if ( calendars != null ) { environment.set(EnvironmentName.CALENDARS, calendars); } if ( objectMarshallersOrder != null && objectMarshallersOrder.size() > 0 ) { List<ObjectMarshallingStrategy> strategies = getStrategies(); environment.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,strategies.toArray(new ObjectMarshallingStrategy[]{})); } if ( appScopedEntityManager != null ) { environment.set(EnvironmentName.APP_SCOPED_ENTITY_MANAGER, appScopedEntityManager); } if ( cmdScopedEntityManager != null ) { environment.set(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, cmdScopedEntityManager); } }
/** * Creates a new Environment with the specified overrides. * @param overrides the specified overrides * @return the environment */ public static Environment getEnvironment(Map<String, Object> overrides) { Environment env = EnvironmentFactory.newEnvironment(); // set the default global resolver env.set(EnvironmentName.GLOBALS, new MapGlobalResolver()); // apply any overrides if (overrides != null) { for (Map.Entry<String, Object> entry : overrides.entrySet()) { env.set(entry.getKey(), entry.getValue()); } } return env; }
public static Environment newEnvironment() { Environment env = new EnvironmentImpl(); env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{new SerializablePlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT)}); return env; // Environment environment = EnvironmentFactory.environment.get(); // if (environment == null) { // environment = new EnvironmentImpl(); // EnvironmentFactory.environment.set(environment); // } // return environment; }
public void dispose() { logger.trace( "Disposing DroolsSpringJpaManager" ); if ( internalAppScopedEntityManager ) { //TransactionSynchronizationManager.unbindResource( "appEM" ); TransactionSynchronizationManager.unbindResource( this.emf ); if ( this.appScopedEntityManager != null && this.appScopedEntityManager.isOpen() ) { this.appScopedEntityManager.close(); this.internalAppScopedEntityManager = false; this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER, null ); this.appScopedEntityManager = null; } this.endCommandScopedEntityManager(); } }
public void dispose() { logger.trace( "Disposing DroolsSpringJpaManager" ); if ( internalAppScopedEntityManager ) { //TransactionSynchronizationManager.unbindResource( "appEM" ); TransactionSynchronizationManager.unbindResource( this.emf ); if ( this.appScopedEntityManager != null && this.appScopedEntityManager.isOpen() ) { this.appScopedEntityManager.close(); this.internalAppScopedEntityManager = false; this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER, null ); this.appScopedEntityManager = null; } this.endCommandScopedEntityManager(); } }
public void dispose() { logger.trace( "Disposing DroolsSpringJpaManager" ); if ( internalAppScopedEntityManager ) { //TransactionSynchronizationManager.unbindResource( "appEM" ); TransactionSynchronizationManager.unbindResource( this.emf ); if ( this.appScopedEntityManager != null && this.appScopedEntityManager.isOpen() ) { this.appScopedEntityManager.close(); this.internalAppScopedEntityManager = false; this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER, null ); this.appScopedEntityManager = null; } this.endCommandScopedEntityManager(); } }
public PersistenceContext getApplicationScopedPersistenceContext() { 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 ) { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( this.emf ); if ( emHolder == null ) { this.appScopedEntityManager = this.emf.createEntityManager(); emHolder = new EntityManagerHolder( this.appScopedEntityManager ); TransactionSynchronizationManager.bindResource( this.emf, emHolder ); internalAppScopedEntityManager = true; } else { this.appScopedEntityManager = emHolder.getEntityManager(); } this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER, emHolder.getEntityManager() ); } } if ( TransactionSynchronizationManager.isActualTransactionActive() && isJTA) { this.appScopedEntityManager.joinTransaction(); } return new JpaPersistenceContext( this.appScopedEntityManager, isJTA ); }
public PersistenceContext getApplicationScopedPersistenceContext() { 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 ) { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( this.emf ); if ( emHolder == null ) { this.appScopedEntityManager = this.emf.createEntityManager(); emHolder = new EntityManagerHolder( this.appScopedEntityManager ); TransactionSynchronizationManager.bindResource( this.emf, emHolder ); internalAppScopedEntityManager = true; } else { this.appScopedEntityManager = emHolder.getEntityManager(); } this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER, emHolder.getEntityManager() ); } } if ( TransactionSynchronizationManager.isActualTransactionActive() && isJTA) { this.appScopedEntityManager.joinTransaction(); } return new JpaPersistenceContext( this.appScopedEntityManager, isJTA ); }
public PersistenceContext getApplicationScopedPersistenceContext() { 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 ) { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( this.emf ); if ( emHolder == null ) { this.appScopedEntityManager = this.emf.createEntityManager(); emHolder = new EntityManagerHolder( this.appScopedEntityManager ); TransactionSynchronizationManager.bindResource( this.emf, emHolder ); internalAppScopedEntityManager = true; } else { this.appScopedEntityManager = emHolder.getEntityManager(); } this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER, emHolder.getEntityManager() ); } } if ( TransactionSynchronizationManager.isActualTransactionActive() && isJTA) { this.appScopedEntityManager.joinTransaction(); } return new JpaPersistenceContext( this.appScopedEntityManager, isJTA ); }
public void beginCommandScopedEntityManager() { EntityManager cmdScopedEntityManager = (EntityManager) env.get( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER ); if ( cmdScopedEntityManager == null || !cmdScopedEntityManager.isOpen() ) { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( "cmdEM" ); EntityManager em = null; if ( emHolder == null ) { em = this.emf.createEntityManager(); emHolder = new EntityManagerHolder( em ); TransactionSynchronizationManager.bindResource( "cmdEM", emHolder ); } else { em = emHolder.getEntityManager(); } this.env.set( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, em ); } if (isJTA) { this.getCommandScopedPersistenceContext().joinTransaction(); this.appScopedEntityManager.joinTransaction(); } }
public void beginCommandScopedEntityManager() { EntityManager cmdScopedEntityManager = (EntityManager) env.get( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER ); if ( cmdScopedEntityManager == null || !cmdScopedEntityManager.isOpen() ) { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( "cmdEM" ); EntityManager em = null; if ( emHolder == null ) { em = this.emf.createEntityManager(); emHolder = new EntityManagerHolder( em ); TransactionSynchronizationManager.bindResource( "cmdEM", emHolder ); } else { em = emHolder.getEntityManager(); } this.env.set( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, em ); } if (isJTA) { this.getCommandScopedPersistenceContext().joinTransaction(); this.appScopedEntityManager.joinTransaction(); } }
public void beginCommandScopedEntityManager() { EntityManager cmdScopedEntityManager = (EntityManager) env.get( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER ); if ( cmdScopedEntityManager == null || !cmdScopedEntityManager.isOpen() ) { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( "cmdEM" ); EntityManager em = null; if ( emHolder == null ) { em = this.emf.createEntityManager(); emHolder = new EntityManagerHolder( em ); TransactionSynchronizationManager.bindResource( "cmdEM", emHolder ); } else { em = emHolder.getEntityManager(); } this.env.set( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, em ); } if (isJTA) { this.getCommandScopedPersistenceContext().joinTransaction(); this.appScopedEntityManager.joinTransaction(); } }
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, jpaConfiguration.getEntityManagerFactory() ); env.set( EnvironmentName.TRANSACTION_MANAGER, jpaConfiguration.getPlatformTransactionManager() ); env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, jpaConfiguration.getEntityManagerFactory() ); env.set( EnvironmentName.TRANSACTION_MANAGER, jpaConfiguration.getPlatformTransactionManager() ); env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );
if ( this.dateFormats == null ) { this.dateFormats = new DateFormatsImpl(); this.environment.set( EnvironmentName.DATE_FORMATS, this.dateFormats );