Update for new style of container bean
This commit is contained in:
@@ -14,6 +14,7 @@ import org.hibernate.search.engine.cfg.BackendSettings;
|
|||||||
import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategyNames;
|
import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategyNames;
|
||||||
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
|
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
|
||||||
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName;
|
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
|
import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
|
||||||
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
|
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
|
||||||
import org.springframework.core.env.CompositePropertySource;
|
import org.springframework.core.env.CompositePropertySource;
|
||||||
@@ -25,7 +26,7 @@ import java.util.*;
|
|||||||
|
|
||||||
public class EnvironmentHelper {
|
public class EnvironmentHelper {
|
||||||
|
|
||||||
public static Properties getHibernateProperties(ConfigurableEnvironment environment) {
|
public static Properties getHibernateProperties(ConfigurableEnvironment environment, ConfigurableListableBeanFactory theBeanFactory) {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
Map<String, Object> jpaProps = getPropertiesStartingWith(environment, "spring.jpa.properties");
|
Map<String, Object> jpaProps = getPropertiesStartingWith(environment, "spring.jpa.properties");
|
||||||
for (Map.Entry<String, Object> entry : jpaProps.entrySet()) {
|
for (Map.Entry<String, Object> entry : jpaProps.entrySet()) {
|
||||||
@@ -41,7 +42,7 @@ public class EnvironmentHelper {
|
|||||||
//properties.putIfAbsent(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory));
|
//properties.putIfAbsent(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory));
|
||||||
|
|
||||||
//hapi-fhir-jpaserver-base "sensible defaults"
|
//hapi-fhir-jpaserver-base "sensible defaults"
|
||||||
Map<String, Object> hapiJpaPropertyMap = new HapiFhirLocalContainerEntityManagerFactoryBean().getJpaPropertyMap();
|
Map<String, Object> hapiJpaPropertyMap = new HapiFhirLocalContainerEntityManagerFactoryBean(theBeanFactory).getJpaPropertyMap();
|
||||||
hapiJpaPropertyMap.forEach(properties::putIfAbsent);
|
hapiJpaPropertyMap.forEach(properties::putIfAbsent);
|
||||||
|
|
||||||
//hapi-fhir-jpaserver-starter defaults
|
//hapi-fhir-jpaserver-starter defaults
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2;
|
|||||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||||
import ca.uhn.fhir.jpa.starter.annotations.OnDSTU2Condition;
|
import ca.uhn.fhir.jpa.starter.annotations.OnDSTU2Condition;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -58,8 +59,8 @@ public class FhirServerConfigDstu2 extends BaseJavaConfigDstu2 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Bean()
|
@Bean()
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theBeanFactory) {
|
||||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theBeanFactory);
|
||||||
retVal.setPersistenceUnitName("HAPI_PU");
|
retVal.setPersistenceUnitName("HAPI_PU");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -67,7 +68,7 @@ public class FhirServerConfigDstu2 extends BaseJavaConfigDstu2 {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||||
}
|
}
|
||||||
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment));
|
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment, theBeanFactory));
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.annotation.PostConstruct;
|
|||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -62,8 +63,8 @@ public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Bean
|
@Bean
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theBeanFactory) {
|
||||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theBeanFactory);
|
||||||
retVal.setPersistenceUnitName("HAPI_PU");
|
retVal.setPersistenceUnitName("HAPI_PU");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -72,7 +73,7 @@ public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 {
|
|||||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment));
|
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment, theBeanFactory));
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
|||||||
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
|
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
|
||||||
import ca.uhn.fhir.jpa.starter.cql.StarterCqlR4Config;
|
import ca.uhn.fhir.jpa.starter.cql.StarterCqlR4Config;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.*;
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||||
@@ -58,8 +59,8 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Bean()
|
@Bean()
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theBeanFactory) {
|
||||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theBeanFactory);
|
||||||
retVal.setPersistenceUnitName("HAPI_PU");
|
retVal.setPersistenceUnitName("HAPI_PU");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -68,7 +69,7 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 {
|
|||||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment));
|
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment, theBeanFactory));
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
|||||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||||
import ca.uhn.fhir.jpa.starter.annotations.OnR5Condition;
|
import ca.uhn.fhir.jpa.starter.annotations.OnR5Condition;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -59,8 +60,8 @@ public class FhirServerConfigR5 extends BaseJavaConfigR5 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Bean()
|
@Bean()
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theBeanFactory) {
|
||||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theBeanFactory);
|
||||||
retVal.setPersistenceUnitName("HAPI_PU");
|
retVal.setPersistenceUnitName("HAPI_PU");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -69,7 +70,7 @@ public class FhirServerConfigR5 extends BaseJavaConfigR5 {
|
|||||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment));
|
retVal.setJpaProperties(EnvironmentHelper.getHibernateProperties(configurableEnvironment, theBeanFactory));
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user