From febb15b78ed734dac4458eb95f1b2a3fd9e3f11f Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 15 Oct 2015 17:21:20 -0400 Subject: [PATCH] Work on java config --- .../ca/uhn/fhir/jpa/config/BaseConfig.java | 43 +++++++++++ .../uhn/fhir/jpa/config/BaseDstu1Config.java | 27 +++++++ .../uhn/fhir/jpa/config/BaseDstu2Config.java | 67 +++++++++++++++++ .../uhn/fhir/jpa/config/TestDstu1Config.java | 56 ++++++--------- .../uhn/fhir/jpa/config/TestDstu2Config.java | 30 ++++---- .../jpa/dao/FhirResourceDaoDstu1Test.java | 6 +- .../dao/FhirResourceDaoDstu2SearchFtTest.java | 1 - .../fhir/jpa/dao/FhirSearchDaoDstu2Test.java | 1 - .../fhir/jpa/dao/FhirSystemDaoDstu1Test.java | 8 ++- .../resources/vm/jpa_spring_beans_java.vm | 72 +------------------ 10 files changed, 187 insertions(+), 124 deletions(-) create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java new file mode 100644 index 00000000000..8fca233bfc8 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java @@ -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; + } + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java new file mode 100644 index 00000000000..1746a491d1c --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java @@ -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> 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; + } + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java new file mode 100644 index 00000000000..1a8202ec4f3 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java @@ -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 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(); + } + + // + +} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu1Config.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu1Config.java index 545838a88a5..dbb145e239d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu1Config.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu1Config.java @@ -1,20 +1,16 @@ package ca.uhn.fhir.jpa.config; -import javax.persistence.EntityManager; +import java.util.Properties; + import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.apache.commons.dbcp2.BasicDataSource; -import org.hibernate.dialect.DerbyTenSevenDialect; -import org.springframework.beans.factory.annotation.Autowired; +import org.hibernate.jpa.HibernatePersistenceProvider; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.JpaVendorAdapter; 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 ca.uhn.fhir.jpa.dao.DaoConfig; @@ -24,14 +20,13 @@ import ca.uhn.fhir.jpa.rp.dstu.BaseJavaConfigDstu1; @EnableTransactionManagement() public class TestDstu1Config extends BaseJavaConfigDstu1 { - @Override - @Bean(name="myDaoConfigDstu1") - public DaoConfig daoConfigDstu1() { + @Bean() + public DaoConfig daoConfig() { return new DaoConfig(); } - - @Bean(name="myPersistenceDataSourceDstu1") - public DataSource dataSourceDstu1() { + + @Bean() + public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true"); @@ -40,36 +35,31 @@ public class TestDstu1Config extends BaseJavaConfigDstu1 { return retVal; } - @Override - @Bean(name="myTransactionManagerDstu1") - public JpaTransactionManager platformTransactionManagerDstu1() { + @Bean() + public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { JpaTransactionManager retVal = new JpaTransactionManager(); - retVal.setEntityManagerFactory(entityManagerFactoryDstu1()); - retVal.afterPropertiesSet(); + retVal.setEntityManagerFactory(entityManagerFactory); return retVal; } - @Bean - public EntityManagerFactory entityManagerFactoryDstu1() { + @Bean() + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); - retVal.setDataSource(dataSourceDstu1()); + retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu1"); + retVal.setDataSource(dataSource()); retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); - retVal.setJpaVendorAdapter(jpaVendorAdapter()); + retVal.setPersistenceProvider(new HibernatePersistenceProvider()); + retVal.setJpaProperties(jpaProperties()); retVal.afterPropertiesSet(); - return retVal.getNativeEntityManagerFactory(); - } - - @Bean - public JpaVendorAdapter jpaVendorAdapter() { - HibernateJpaVendorAdapter retVal = new HibernateJpaVendorAdapter(); - retVal.setGenerateDdl(true); - retVal.setDatabasePlatform(DerbyTenSevenDialect.class.getName()); return retVal; } - @Override - protected EntityManager entityManagerDstu1() { - return entityManagerFactoryDstu1().createEntityManager(); + private Properties jpaProperties() { + Properties extraProperties = new Properties(); + extraProperties.put("hibernate.format_sql", "true"); + extraProperties.put("hibernate.show_sql", "false"); + extraProperties.put("hibernate.hbm2ddl.auto", "update"); + return extraProperties; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java index 3b7979e9efb..518c5fb7802 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java @@ -20,13 +20,13 @@ import ca.uhn.fhir.jpa.rp.dstu2.BaseJavaConfigDstu2; @EnableTransactionManagement() public class TestDstu2Config extends BaseJavaConfigDstu2 { - @Bean(name="myDaoConfigDstu2") - public DaoConfig daoConfigDstu2() { + @Bean() + public DaoConfig daoConfig() { return new DaoConfig(); } - - @Bean(name="myPersistenceDataSourceDstu2") - public DataSource dataSourceDstu2() { + + @Bean() + public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true"); @@ -43,23 +43,23 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 { } @Bean() - public LocalContainerEntityManagerFactoryBean entityManagerFactoryDstu2() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu2"); - retVal.setDataSource(dataSourceDstu2()); + retVal.setDataSource(dataSource()); retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); retVal.setPersistenceProvider(new HibernatePersistenceProvider()); retVal.setJpaProperties(jpaProperties()); retVal.afterPropertiesSet(); return retVal; } - - private Properties jpaProperties() { - Properties extraProperties = new Properties(); - extraProperties.put("hibernate.format_sql", "true"); - extraProperties.put("hibernate.show_sql", "false"); - extraProperties.put("hibernate.hbm2ddl.auto", "update"); - return extraProperties; - } + + private Properties jpaProperties() { + Properties extraProperties = new Properties(); + extraProperties.put("hibernate.format_sql", "true"); + extraProperties.put("hibernate.show_sql", "false"); + extraProperties.put("hibernate.hbm2ddl.auto", "update"); + return extraProperties; + } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java index 3989928906a..e36c3e5acce 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java @@ -13,9 +13,11 @@ import org.hl7.fhir.instance.model.api.IIdType; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; 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.resource.Device; import ca.uhn.fhir.model.dstu.resource.DiagnosticReport; @@ -34,7 +36,7 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; @SuppressWarnings("unused") public class FhirResourceDaoDstu1Test extends BaseJpaTest { - private static ClassPathXmlApplicationContext ourCtx; + private static AnnotationConfigApplicationContext ourCtx; private static IFhirResourceDao ourDeviceDao; private static IFhirResourceDao ourDiagnosticReportDao; private static IFhirResourceDao ourEncounterDao; @@ -135,7 +137,7 @@ public class FhirResourceDaoDstu1Test extends BaseJpaTest { @SuppressWarnings("unchecked") @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); ourObservationDao = ourCtx.getBean("myObservationDaoDstu1", IFhirResourceDao.class); ourDiagnosticReportDao = ourCtx.getBean("myDiagnosticReportDaoDstu1", IFhirResourceDao.class); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2SearchFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2SearchFtTest.java index 9337e4c082c..2c6b7c9bdf9 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2SearchFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2SearchFtTest.java @@ -22,7 +22,6 @@ import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.Constants; -@ContextConfiguration(locations = { "classpath:fhir-spring-search-config-dstu2.xml" }) public class FhirResourceDaoDstu2SearchFtTest extends BaseJpaDstu2Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2SearchFtTest.class); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSearchDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSearchDaoDstu2Test.java index 55d9975b61d..891c3381053 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSearchDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSearchDaoDstu2Test.java @@ -22,7 +22,6 @@ import ca.uhn.fhir.rest.param.StringOrListParam; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.Constants; -@ContextConfiguration(locations = { "classpath:fhir-spring-search-config-dstu2.xml" }) public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { @Autowired diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java index 38d2f69887e..6fc5146a06c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java @@ -23,9 +23,11 @@ import org.hl7.fhir.instance.model.api.IIdType; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.config.TestDstu1Config; import ca.uhn.fhir.jpa.entity.TagTypeEnum; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.BundleEntry; @@ -45,7 +47,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; public class FhirSystemDaoDstu1Test extends BaseJpaTest { - private static ClassPathXmlApplicationContext ourCtx; + private static AnnotationConfigApplicationContext ourCtx; private static FhirContext ourFhirContext; private static IFhirResourceDao ourLocationDao; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu1Test.class); @@ -466,8 +468,8 @@ public class FhirSystemDaoDstu1Test extends BaseJpaTest { @SuppressWarnings("unchecked") @BeforeClass public static void beforeClass() { - ourCtx = new ClassPathXmlApplicationContext("hapi-fhir-server-resourceproviders-dstu1.xml", "fhir-jpabase-spring-test-config.xml"); - ourFhirContext = ourCtx.getBean(FhirContext.class); + ourCtx = new AnnotationConfigApplicationContext(TestDstu1Config.class); + ourFhirContext = ourCtx.getBean("myFhirContextDstu1", FhirContext.class); ourPatientDao = ourCtx.getBean("myPatientDaoDstu1", IFhirResourceDao.class); ourObservationDao = ourCtx.getBean("myObservationDaoDstu1", IFhirResourceDao.class); ourLocationDao = ourCtx.getBean("myLocationDaoDstu1", IFhirResourceDao.class); diff --git a/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm b/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm index cc82463f0e6..b1cd48829aa 100644 --- a/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm +++ b/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm @@ -28,87 +28,21 @@ import ca.uhn.fhir.jpa.dao.IFhirSystemDao; @Configuration @EnableScheduling() #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 { +public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jpa.config.Base${versionCapitalized}Config 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> 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 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 - @Bean(destroyMethod="shutdown") public Executor taskScheduler() { return Executors.newScheduledThreadPool(5); } + @Override public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { 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}") public List resourceProviders${versionCapitalized}() { List retVal = new ArrayList();