Improve multiversion support
This commit is contained in:
@@ -1,29 +1,16 @@
|
||||
package ca.uhn.fhir.jpa.demo;
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.Driver;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
|
||||
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.hl7.fhir.instance.model.Subscription;
|
||||
import org.springframework.beans.factory.annotation.Autowire;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu3;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
@@ -35,7 +22,7 @@ import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableTransactionManagement()
|
||||
public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
public class FhirServerConfigCommon {
|
||||
|
||||
/**
|
||||
* Configure FHIR properties around the the JPA server via this bean
|
||||
@@ -63,19 +50,6 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
return new ModelConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* We override the paging provider definition so that we can customize
|
||||
* the default/max page sizes for search results. You can set these however
|
||||
* you want, although very large page sizes will require a lot of RAM.
|
||||
*/
|
||||
@Override
|
||||
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
|
||||
DatabaseBackedPagingProvider pagingProvider = super.databaseBackedPagingProvider();
|
||||
pagingProvider.setDefaultPageSize(HapiProperties.getDefaultPageSize());
|
||||
pagingProvider.setMaximumPageSize(HapiProperties.getMaximumPageSize());
|
||||
return pagingProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a
|
||||
* directory called "jpaserver_derby_files".
|
||||
@@ -93,31 +67,6 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
|
||||
try {
|
||||
retVal.setDataSource(dataSource());
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private Properties jpaProperties() {
|
||||
Properties extraProperties = HapiProperties.getProperties();
|
||||
|
||||
if (extraProperties == null) {
|
||||
extraProperties = new Properties();
|
||||
}
|
||||
|
||||
return extraProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do some fancy logging to create a nice access log that has details about each incoming request.
|
||||
@@ -140,16 +89,4 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean(autowire = Autowire.BY_TYPE)
|
||||
public IServerInterceptor subscriptionSecurityInterceptor() {
|
||||
SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
|
||||
JpaTransactionManager retVal = new JpaTransactionManager();
|
||||
retVal.setEntityManagerFactory(entityManagerFactory);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class FhirServerConfigDstu2 extends BaseJavaConfigDstu2 {
|
||||
|
||||
@Autowired
|
||||
private DataSource myDataSource;
|
||||
|
||||
/**
|
||||
* We override the paging provider definition so that we can customize
|
||||
* the default/max page sizes for search results. You can set these however
|
||||
* you want, although very large page sizes will require a lot of RAM.
|
||||
*/
|
||||
@Override
|
||||
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
|
||||
DatabaseBackedPagingProvider pagingProvider = super.databaseBackedPagingProvider();
|
||||
pagingProvider.setDefaultPageSize(HapiProperties.getDefaultPageSize());
|
||||
pagingProvider.setMaximumPageSize(HapiProperties.getMaximumPageSize());
|
||||
return pagingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
|
||||
try {
|
||||
retVal.setDataSource(myDataSource);
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(HapiProperties.getProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
|
||||
JpaTransactionManager retVal = new JpaTransactionManager();
|
||||
retVal.setEntityManagerFactory(entityManagerFactory);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 {
|
||||
|
||||
@Autowired
|
||||
private DataSource myDataSource;
|
||||
|
||||
/**
|
||||
* We override the paging provider definition so that we can customize
|
||||
* the default/max page sizes for search results. You can set these however
|
||||
* you want, although very large page sizes will require a lot of RAM.
|
||||
*/
|
||||
@Override
|
||||
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
|
||||
DatabaseBackedPagingProvider pagingProvider = super.databaseBackedPagingProvider();
|
||||
pagingProvider.setDefaultPageSize(HapiProperties.getDefaultPageSize());
|
||||
pagingProvider.setMaximumPageSize(HapiProperties.getMaximumPageSize());
|
||||
return pagingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
|
||||
try {
|
||||
retVal.setDataSource(myDataSource);
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(HapiProperties.getProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
|
||||
JpaTransactionManager retVal = new JpaTransactionManager();
|
||||
retVal.setEntityManagerFactory(entityManagerFactory);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class FhirServerConfigR4 extends BaseJavaConfigR4 {
|
||||
|
||||
@Autowired
|
||||
private DataSource myDataSource;
|
||||
|
||||
/**
|
||||
* We override the paging provider definition so that we can customize
|
||||
* the default/max page sizes for search results. You can set these however
|
||||
* you want, although very large page sizes will require a lot of RAM.
|
||||
*/
|
||||
@Override
|
||||
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
|
||||
DatabaseBackedPagingProvider pagingProvider = super.databaseBackedPagingProvider();
|
||||
pagingProvider.setDefaultPageSize(HapiProperties.getDefaultPageSize());
|
||||
pagingProvider.setMaximumPageSize(HapiProperties.getMaximumPageSize());
|
||||
return pagingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
|
||||
try {
|
||||
retVal.setDataSource(myDataSource);
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(HapiProperties.getProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
|
||||
JpaTransactionManager retVal = new JpaTransactionManager();
|
||||
retVal.setEntityManagerFactory(entityManagerFactory);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ca.uhn.fhir.jpa.demo;
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -1,12 +1,11 @@
|
||||
package ca.uhn.fhir.jpa.demo;
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.ETagSupportEnum;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -30,22 +29,35 @@ public class HapiProperties {
|
||||
public static final String TEST_PORT = "test.port";
|
||||
public static final String SERVER_NAME = "server.name";
|
||||
public static final String SERVER_ID = "server.id";
|
||||
private static Properties properties;
|
||||
private static final String HAPI_PROPERTIES = "hapi.properties";
|
||||
private static final String FHIR_VERSION = "fhir_version";
|
||||
static final String FHIR_VERSION = "fhir_version";
|
||||
private static final String DEFAULT_ENCODING = "default_encoding";
|
||||
private static final String ETAG_SUPPORT = "etag_support";
|
||||
private static Properties properties;
|
||||
|
||||
/**
|
||||
* Force the configuration to be reloaded
|
||||
*/
|
||||
public static void forceReload() {
|
||||
properties = null;
|
||||
getProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is mostly here for unit tests. Use the actual properties file
|
||||
* to set values
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static void setProperty(String theKey, String theValue) {
|
||||
getProperties().setProperty(theKey, theValue);
|
||||
}
|
||||
|
||||
public static Properties getProperties() {
|
||||
if (properties == null) {
|
||||
// Load the configurable properties file
|
||||
InputStream in = null;
|
||||
|
||||
try {
|
||||
in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES);
|
||||
try (InputStream in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES)){
|
||||
HapiProperties.properties = new Properties();
|
||||
HapiProperties.properties.load(in);
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Could not load HAPI properties", e);
|
||||
}
|
||||
@@ -197,7 +209,7 @@ public class HapiProperties {
|
||||
}
|
||||
|
||||
public static String getServerBase() {
|
||||
return HapiProperties.getProperty(SERVER_BASE, "/baseDstu3");
|
||||
return HapiProperties.getProperty(SERVER_BASE, "/fhir");
|
||||
}
|
||||
|
||||
public static String getServerName() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package ca.uhn.fhir.jpa.demo;
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
@@ -10,6 +10,7 @@ import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider;
|
||||
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
|
||||
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3;
|
||||
import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3;
|
||||
import ca.uhn.fhir.jpa.provider.r4.JpaConformanceProviderR4;
|
||||
import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4;
|
||||
import ca.uhn.fhir.jpa.provider.r4.TerminologyUploaderProviderR4;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
@@ -21,21 +22,20 @@ import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Meta;
|
||||
import org.hl7.fhir.instance.model.Subscription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.context.ContextLoaderListener;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.util.List;
|
||||
|
||||
public class JpaServerDemo extends RestfulServer {
|
||||
public class JpaRestfulServer extends RestfulServer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(JpaServerDemo.class);
|
||||
private AnnotationConfigApplicationContext appCtx;
|
||||
|
||||
private WebApplicationContext myAppCtx;
|
||||
@Override
|
||||
public void destroy() {
|
||||
appCtx.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@@ -43,69 +43,61 @@ public class JpaServerDemo extends RestfulServer {
|
||||
super.initialize();
|
||||
|
||||
/*
|
||||
* We want to support FHIR DSTU2 format. This means that the server
|
||||
* will use the DSTU2 bundle format and other DSTU2 encoding changes.
|
||||
*
|
||||
* If you want to use DSTU1 instead, change the following line, and change the 2 occurrences of dstu2 in web.xml to dstu1
|
||||
* Create a FhirContext object that uses the version of FHIR
|
||||
* specified in the properties file.
|
||||
*/
|
||||
FhirVersionEnum fhirVersion = HapiProperties.getFhirVersion();
|
||||
setFhirContext(new FhirContext(fhirVersion));
|
||||
|
||||
// Get the spring context from the web container (it's declared in web.xml)
|
||||
myAppCtx = ContextLoaderListener.getCurrentWebApplicationContext();
|
||||
appCtx = new AnnotationConfigApplicationContext();
|
||||
|
||||
/*
|
||||
* The BaseJavaConfigDstu2.java class is a spring configuration
|
||||
* file which is automatically generated as a part of hapi-fhir-jpaserver-base and
|
||||
* contains bean definitions for a resource provider for each resource type
|
||||
*/
|
||||
String resourceProviderBeanName;
|
||||
if (fhirVersion == FhirVersionEnum.DSTU2) {
|
||||
resourceProviderBeanName = "myResourceProvidersDstu2";
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
resourceProviderBeanName = "myResourceProvidersDstu3";
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
resourceProviderBeanName = "myResourceProviderR4";
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
List<IResourceProvider> beans = myAppCtx.getBean(resourceProviderBeanName, List.class);
|
||||
setResourceProviders(beans);
|
||||
|
||||
/*
|
||||
* The system provider implements non-resource-type methods, such as
|
||||
* transaction, and global history.
|
||||
* ResourceProviders are fetched from the Spring context
|
||||
*/
|
||||
List<IResourceProvider> resourceProviders;
|
||||
Object systemProvider;
|
||||
if (fhirVersion == FhirVersionEnum.DSTU2) {
|
||||
systemProvider = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
|
||||
appCtx.register(FhirServerConfigDstu2.class, FhirServerConfigCommon.class);
|
||||
appCtx.refresh();
|
||||
resourceProviders = appCtx.getBean("myResourceProvidersDstu2", List.class);
|
||||
systemProvider = appCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
systemProvider = myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class);
|
||||
appCtx.register(FhirServerConfigDstu3.class, FhirServerConfigCommon.class);
|
||||
appCtx.refresh();
|
||||
resourceProviders = appCtx.getBean("myResourceProvidersDstu3", List.class);
|
||||
systemProvider = appCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class);
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
systemProvider = myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class);
|
||||
appCtx.register(FhirServerConfigR4.class, FhirServerConfigCommon.class);
|
||||
appCtx.refresh();
|
||||
resourceProviders = appCtx.getBean("myResourceProvidersR4", List.class);
|
||||
systemProvider = appCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
setPlainProviders(systemProvider);
|
||||
registerProviders(resourceProviders);
|
||||
registerProvider(systemProvider);
|
||||
|
||||
/*
|
||||
* The conformance provider exports the supported resources, search parameters, etc for
|
||||
* this server. The JPA version adds resource counts to the exported statement, so it
|
||||
* this server. The JPA version adds resourceProviders counts to the exported statement, so it
|
||||
* is a nice addition.
|
||||
*
|
||||
* You can also create your own subclass of the conformance provider if you need to
|
||||
* provide further customization of your server's CapabilityStatement
|
||||
*/
|
||||
if (fhirVersion == FhirVersionEnum.DSTU2) {
|
||||
IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle, MetaDt> systemDao = appCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, appCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("HAPI FHIR DSTU2 Server");
|
||||
setServerConformanceProvider(confProvider);
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
IFhirSystemDao<Bundle, Meta> systemDao = appCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, appCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("HAPI FHIR DSTU3 Server");
|
||||
setServerConformanceProvider(confProvider);
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
IFhirSystemDao<org.hl7.fhir.r4.model.Bundle, org.hl7.fhir.r4.model.Meta> systemDao = appCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
|
||||
JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao, appCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("HAPI FHIR R4 Server");
|
||||
setServerConformanceProvider(confProvider);
|
||||
} else {
|
||||
@@ -134,20 +126,19 @@ public class JpaServerDemo extends RestfulServer {
|
||||
setDefaultResponseEncoding(HapiProperties.getDefaultEncoding());
|
||||
|
||||
/*
|
||||
* -- New in HAPI FHIR 1.5 --
|
||||
* This configures the server to page search results to and from
|
||||
* the database, instead of only paging them to memory. This may mean
|
||||
* a performance hit when performing searches that return lots of results,
|
||||
* but makes the server much more scalable.
|
||||
*/
|
||||
setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class));
|
||||
setPagingProvider(appCtx.getBean(DatabaseBackedPagingProvider.class));
|
||||
|
||||
/*
|
||||
* This interceptor formats the output using nice colourful
|
||||
* HTML output when the request is detected to come from a
|
||||
* browser.
|
||||
*/
|
||||
ResponseHighlighterInterceptor responseHighlighterInterceptor = myAppCtx.getBean(ResponseHighlighterInterceptor.class);
|
||||
ResponseHighlighterInterceptor responseHighlighterInterceptor = appCtx.getBean(ResponseHighlighterInterceptor.class);
|
||||
this.registerInterceptor(responseHighlighterInterceptor);
|
||||
|
||||
/*
|
||||
@@ -170,16 +161,16 @@ public class JpaServerDemo extends RestfulServer {
|
||||
*/
|
||||
if (false) { // <-- DISABLED RIGHT NOW
|
||||
if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
registerProvider(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
|
||||
registerProvider(appCtx.getBean(TerminologyUploaderProviderDstu3.class));
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
registerProvider(myAppCtx.getBean(TerminologyUploaderProviderR4.class));
|
||||
registerProvider(appCtx.getBean(TerminologyUploaderProviderR4.class));
|
||||
}
|
||||
}
|
||||
|
||||
// If you want to enable the $trigger-subscription operation to allow
|
||||
// manual triggering of a subscription delivery, enable this provider
|
||||
if (false) { // <-- DISABLED RIGHT NOW
|
||||
SubscriptionTriggeringProvider retriggeringProvider = myAppCtx.getBean(SubscriptionTriggeringProvider.class);
|
||||
SubscriptionTriggeringProvider retriggeringProvider = appCtx.getBean(SubscriptionTriggeringProvider.class);
|
||||
registerProvider(retriggeringProvider);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user