Work on java config

This commit is contained in:
James Agnew 2015-10-15 17:21:20 -04:00
parent e1eed8ce5e
commit febb15b78e
10 changed files with 187 additions and 124 deletions

View File

@ -0,0 +1,43 @@
package ca.uhn.fhir.jpa.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import ca.uhn.fhir.context.FhirContext;
@Configuration
public class BaseConfig {
private static FhirContext ourFhirContextDstu2;
private static FhirContext ourFhirContextDstu1;
private static FhirContext ourFhirContextDstu2Hl7Org;
@Bean(name="myFhirContextDstu2")
@Lazy
public FhirContext fhirContextDstu2() {
if (ourFhirContextDstu2 == null) {
ourFhirContextDstu2 = FhirContext.forDstu2();
}
return ourFhirContextDstu2;
}
@Bean(name="myFhirContextDstu1")
@Lazy
public FhirContext fhirContextDstu1() {
if (ourFhirContextDstu1 == null) {
ourFhirContextDstu1 = FhirContext.forDstu1();
}
return ourFhirContextDstu1;
}
@Bean(name="myFhirContextDstu2Hl7Org")
@Lazy
public FhirContext fhirContextDstu2Hl7Org() {
if (ourFhirContextDstu2Hl7Org == null) {
ourFhirContextDstu2Hl7Org = FhirContext.forDstu2Hl7Org();
}
return ourFhirContextDstu2Hl7Org;
}
}

View File

@ -0,0 +1,27 @@
package ca.uhn.fhir.jpa.config;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ca.uhn.fhir.model.api.IResource;
@Configuration
public class BaseDstu1Config extends BaseConfig {
@Bean(name = "mySystemDaoDstu1", autowire = Autowire.BY_NAME)
public ca.uhn.fhir.jpa.dao.IFhirSystemDao<List<IResource>> fhirSystemDaoDstu1() {
ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu1 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu1();
return retVal;
}
@Bean(name = "mySystemProviderDstu1")
public ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1 systemDaoDstu1() {
ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1 retVal = new ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1();
retVal.setDao(fhirSystemDaoDstu1());
return retVal;
}
}

View File

@ -0,0 +1,67 @@
package ca.uhn.fhir.jpa.config;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.handler.PerConnectionWebSocketHandler;
import ca.uhn.fhir.jpa.dao.FhirSearchDao;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.dao.ISearchDao;
import ca.uhn.fhir.jpa.subscription.SubscriptionWebsocketHandler;
@Configuration
@EnableTransactionManagement
@EnableWebSocket()
@EnableScheduling
public class BaseDstu2Config extends BaseConfig implements WebSocketConfigurer {
@Bean(name = "mySystemDaoDstu2", autowire = Autowire.BY_NAME)
public IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle> fhirSystemDaoDstu2() {
ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2();
return retVal;
}
@Bean(name = "mySystemProviderDstu2")
public ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 systemDaoDstu2() {
ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 retVal = new ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2();
retVal.setDao(fhirSystemDaoDstu2());
return retVal;
}
@Bean(name = "myJpaValidationSupportDstu2", autowire = Autowire.BY_NAME)
public ca.uhn.fhir.jpa.dao.IJpaValidationSupport jpaValidationSupportDstu2() {
ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu2 retVal = new ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu2();
return retVal;
}
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(subscriptionWebSocketHandler(), "/websocket/dstu2").withSockJS();
}
@Bean(autowire = Autowire.BY_TYPE)
public WebSocketHandler subscriptionWebSocketHandler() {
return new PerConnectionWebSocketHandler(SubscriptionWebsocketHandler.class);
}
@Bean(autowire = Autowire.BY_TYPE)
public ISearchDao searchDao() {
return new FhirSearchDao();
}
// <!--
// <bean id="mySubscriptionWebsocketHandler" class="org.springframework.web.socket.handler.PerConnectionWebSocketHandler">
// <constructor-arg value="ca.uhn.fhir.jpa.subscription.SubscriptionWebsocketHandler"/>
// </bean>
//
// <bean id="mySubscriptionSecurityInterceptor" class="ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptor"/>
// -->
}

View File

@ -1,20 +1,16 @@
package ca.uhn.fhir.jpa.config; package ca.uhn.fhir.jpa.config;
import javax.persistence.EntityManager; import java.util.Properties;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSource;
import org.hibernate.dialect.DerbyTenSevenDialect; import org.hibernate.jpa.HibernatePersistenceProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.dao.DaoConfig;
@ -24,14 +20,13 @@ import ca.uhn.fhir.jpa.rp.dstu.BaseJavaConfigDstu1;
@EnableTransactionManagement() @EnableTransactionManagement()
public class TestDstu1Config extends BaseJavaConfigDstu1 { public class TestDstu1Config extends BaseJavaConfigDstu1 {
@Override @Bean()
@Bean(name="myDaoConfigDstu1") public DaoConfig daoConfig() {
public DaoConfig daoConfigDstu1() {
return new DaoConfig(); return new DaoConfig();
} }
@Bean(name="myPersistenceDataSourceDstu1") @Bean()
public DataSource dataSourceDstu1() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();
retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true"); retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true");
@ -40,36 +35,31 @@ public class TestDstu1Config extends BaseJavaConfigDstu1 {
return retVal; return retVal;
} }
@Override @Bean()
@Bean(name="myTransactionManagerDstu1") public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
public JpaTransactionManager platformTransactionManagerDstu1() {
JpaTransactionManager retVal = new JpaTransactionManager(); JpaTransactionManager retVal = new JpaTransactionManager();
retVal.setEntityManagerFactory(entityManagerFactoryDstu1()); retVal.setEntityManagerFactory(entityManagerFactory);
retVal.afterPropertiesSet();
return retVal; return retVal;
} }
@Bean @Bean()
public EntityManagerFactory entityManagerFactoryDstu1() { public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean();
retVal.setDataSource(dataSourceDstu1()); retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu1");
retVal.setDataSource(dataSource());
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
retVal.setJpaVendorAdapter(jpaVendorAdapter()); retVal.setPersistenceProvider(new HibernatePersistenceProvider());
retVal.setJpaProperties(jpaProperties());
retVal.afterPropertiesSet(); retVal.afterPropertiesSet();
return retVal.getNativeEntityManagerFactory();
}
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter retVal = new HibernateJpaVendorAdapter();
retVal.setGenerateDdl(true);
retVal.setDatabasePlatform(DerbyTenSevenDialect.class.getName());
return retVal; return retVal;
} }
@Override private Properties jpaProperties() {
protected EntityManager entityManagerDstu1() { Properties extraProperties = new Properties();
return entityManagerFactoryDstu1().createEntityManager(); extraProperties.put("hibernate.format_sql", "true");
extraProperties.put("hibernate.show_sql", "false");
extraProperties.put("hibernate.hbm2ddl.auto", "update");
return extraProperties;
} }

View File

@ -20,13 +20,13 @@ import ca.uhn.fhir.jpa.rp.dstu2.BaseJavaConfigDstu2;
@EnableTransactionManagement() @EnableTransactionManagement()
public class TestDstu2Config extends BaseJavaConfigDstu2 { public class TestDstu2Config extends BaseJavaConfigDstu2 {
@Bean(name="myDaoConfigDstu2") @Bean()
public DaoConfig daoConfigDstu2() { public DaoConfig daoConfig() {
return new DaoConfig(); return new DaoConfig();
} }
@Bean(name="myPersistenceDataSourceDstu2") @Bean()
public DataSource dataSourceDstu2() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();
retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true"); retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true");
@ -43,10 +43,10 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
} }
@Bean() @Bean()
public LocalContainerEntityManagerFactoryBean entityManagerFactoryDstu2() { public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean();
retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu2"); retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu2");
retVal.setDataSource(dataSourceDstu2()); retVal.setDataSource(dataSource());
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
retVal.setPersistenceProvider(new HibernatePersistenceProvider()); retVal.setPersistenceProvider(new HibernatePersistenceProvider());
retVal.setJpaProperties(jpaProperties()); retVal.setJpaProperties(jpaProperties());
@ -54,12 +54,12 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
return retVal; return retVal;
} }
private Properties jpaProperties() { private Properties jpaProperties() {
Properties extraProperties = new Properties(); Properties extraProperties = new Properties();
extraProperties.put("hibernate.format_sql", "true"); extraProperties.put("hibernate.format_sql", "true");
extraProperties.put("hibernate.show_sql", "false"); extraProperties.put("hibernate.show_sql", "false");
extraProperties.put("hibernate.hbm2ddl.auto", "update"); extraProperties.put("hibernate.hbm2ddl.auto", "update");
return extraProperties; return extraProperties;
} }
} }

View File

@ -13,9 +13,11 @@ import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.config.TestDstu2Config;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt; import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.Device; import ca.uhn.fhir.model.dstu.resource.Device;
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport; import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
@ -34,7 +36,7 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class FhirResourceDaoDstu1Test extends BaseJpaTest { public class FhirResourceDaoDstu1Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourCtx; private static AnnotationConfigApplicationContext ourCtx;
private static IFhirResourceDao<Device> ourDeviceDao; private static IFhirResourceDao<Device> ourDeviceDao;
private static IFhirResourceDao<DiagnosticReport> ourDiagnosticReportDao; private static IFhirResourceDao<DiagnosticReport> ourDiagnosticReportDao;
private static IFhirResourceDao<Encounter> ourEncounterDao; private static IFhirResourceDao<Encounter> ourEncounterDao;
@ -135,7 +137,7 @@ public class FhirResourceDaoDstu1Test extends BaseJpaTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@BeforeClass @BeforeClass
public static void beforeClass() { public static void beforeClass() {
ourCtx = new ClassPathXmlApplicationContext("hapi-fhir-server-resourceproviders-dstu1.xml", "fhir-jpabase-spring-test-config.xml"); ourCtx = new AnnotationConfigApplicationContext(TestDstu2Config.class);
ourPatientDao = ourCtx.getBean("myPatientDaoDstu1", IFhirResourceDao.class); ourPatientDao = ourCtx.getBean("myPatientDaoDstu1", IFhirResourceDao.class);
ourObservationDao = ourCtx.getBean("myObservationDaoDstu1", IFhirResourceDao.class); ourObservationDao = ourCtx.getBean("myObservationDaoDstu1", IFhirResourceDao.class);
ourDiagnosticReportDao = ourCtx.getBean("myDiagnosticReportDaoDstu1", IFhirResourceDao.class); ourDiagnosticReportDao = ourCtx.getBean("myDiagnosticReportDaoDstu1", IFhirResourceDao.class);

View File

@ -22,7 +22,6 @@ import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.Constants; import ca.uhn.fhir.rest.server.Constants;
@ContextConfiguration(locations = { "classpath:fhir-spring-search-config-dstu2.xml" })
public class FhirResourceDaoDstu2SearchFtTest extends BaseJpaDstu2Test { public class FhirResourceDaoDstu2SearchFtTest extends BaseJpaDstu2Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2SearchFtTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2SearchFtTest.class);

View File

@ -22,7 +22,6 @@ import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.Constants; import ca.uhn.fhir.rest.server.Constants;
@ContextConfiguration(locations = { "classpath:fhir-spring-search-config-dstu2.xml" })
public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
@Autowired @Autowired

View File

@ -23,9 +23,11 @@ import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.config.TestDstu1Config;
import ca.uhn.fhir.jpa.entity.TagTypeEnum; import ca.uhn.fhir.jpa.entity.TagTypeEnum;
import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.BundleEntry; import ca.uhn.fhir.model.api.BundleEntry;
@ -45,7 +47,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
public class FhirSystemDaoDstu1Test extends BaseJpaTest { public class FhirSystemDaoDstu1Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourCtx; private static AnnotationConfigApplicationContext ourCtx;
private static FhirContext ourFhirContext; private static FhirContext ourFhirContext;
private static IFhirResourceDao<Location> ourLocationDao; private static IFhirResourceDao<Location> ourLocationDao;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu1Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu1Test.class);
@ -466,8 +468,8 @@ public class FhirSystemDaoDstu1Test extends BaseJpaTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@BeforeClass @BeforeClass
public static void beforeClass() { public static void beforeClass() {
ourCtx = new ClassPathXmlApplicationContext("hapi-fhir-server-resourceproviders-dstu1.xml", "fhir-jpabase-spring-test-config.xml"); ourCtx = new AnnotationConfigApplicationContext(TestDstu1Config.class);
ourFhirContext = ourCtx.getBean(FhirContext.class); ourFhirContext = ourCtx.getBean("myFhirContextDstu1", FhirContext.class);
ourPatientDao = ourCtx.getBean("myPatientDaoDstu1", IFhirResourceDao.class); ourPatientDao = ourCtx.getBean("myPatientDaoDstu1", IFhirResourceDao.class);
ourObservationDao = ourCtx.getBean("myObservationDaoDstu1", IFhirResourceDao.class); ourObservationDao = ourCtx.getBean("myObservationDaoDstu1", IFhirResourceDao.class);
ourLocationDao = ourCtx.getBean("myLocationDaoDstu1", IFhirResourceDao.class); ourLocationDao = ourCtx.getBean("myLocationDaoDstu1", IFhirResourceDao.class);

View File

@ -28,87 +28,21 @@ import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
@Configuration @Configuration
@EnableScheduling() @EnableScheduling()
#if ( ${versionCapitalized} == 'Dstu2' ) #if ( ${versionCapitalized} == 'Dstu2' )
@EnableJpaRepositories(basePackages="ca.uhn.fhir.jpa.dao.data", entityManagerFactoryRef="entityManagerFactoryDstu2", transactionManagerRef="transactionManagerDstu2") @EnableJpaRepositories(basePackages="ca.uhn.fhir.jpa.dao.data")
#end
public abstract class BaseJavaConfig${versionCapitalized} implements SchedulingConfigurer {
private static FhirContext ourFhirContextDstu2;
private static FhirContext ourFhirContextDstu1;
private static FhirContext ourFhirContextDstu2Hl7Org;
@Bean(name="myFhirContextDstu2")
@Lazy
public FhirContext fhirContextDstu2() {
if (ourFhirContextDstu2 == null) {
ourFhirContextDstu2 = FhirContext.forDstu2();
}
return ourFhirContextDstu2;
}
@Bean(name="myFhirContextDstu1")
@Lazy
public FhirContext fhirContextDstu1() {
if (ourFhirContextDstu1 == null) {
ourFhirContextDstu1 = FhirContext.forDstu1();
}
return ourFhirContextDstu1;
}
@Bean(name="myFhirContextDstu2Hl7Org")
@Lazy
public FhirContext fhirContextDstu2Hl7Org() {
if (ourFhirContextDstu2Hl7Org == null) {
ourFhirContextDstu2Hl7Org = FhirContext.forDstu2Hl7Org();
}
return ourFhirContextDstu2Hl7Org;
}
#if ( ${versionCapitalized} == 'Dstu1' )
@Bean(name="mySystemDaoDstu1", autowire=Autowire.BY_NAME)
public ca.uhn.fhir.jpa.dao.IFhirSystemDao<List<IResource>> fhirSystemDaoDstu1() {
ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu1 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu1();
return retVal;
}
@Bean(name="mySystemProviderDstu1")
public ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1 systemDaoDstu1() {
ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1 retVal = new ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1();
retVal.setDao(fhirSystemDaoDstu1());
return retVal;
}
#end
#if ( ${versionCapitalized} == 'Dstu2' )
@Bean(name="mySystemDaoDstu2")
public IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle> fhirSystemDao${versionCapitalized}() {
ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2();
applyDaoConfiguration(retVal);
return retVal;
}
@Bean(name="mySystemProviderDstu2")
public ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 systemDaoDstu2() {
ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 retVal = new ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2();
retVal.setDao(fhirSystemDaoDstu2());
return retVal;
}
#end #end
public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jpa.config.Base${versionCapitalized}Config implements SchedulingConfigurer {
@Bean(destroyMethod="shutdown") @Bean(destroyMethod="shutdown")
public Executor taskScheduler() { public Executor taskScheduler() {
return Executors.newScheduledThreadPool(5); return Executors.newScheduledThreadPool(5);
} }
@Override @Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskScheduler()); taskRegistrar.setScheduler(taskScheduler());
} }
#if ( ${versionCapitalized} == 'Dstu2' )
@Bean(name="myJpaValidationSupportDstu2", autowire=Autowire.BY_NAME)
public ca.uhn.fhir.jpa.dao.IJpaValidationSupport jpaValidationSupportDstu2() {
ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu2 retVal = new ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu2();
return retVal;
}
#end
@Bean(name="myResourceProviders${versionCapitalized}") @Bean(name="myResourceProviders${versionCapitalized}")
public List<IResourceProvider> resourceProviders${versionCapitalized}() { public List<IResourceProvider> resourceProviders${versionCapitalized}() {
List<IResourceProvider> retVal = new ArrayList<IResourceProvider>(); List<IResourceProvider> retVal = new ArrayList<IResourceProvider>();