Merge branch 'master' of https://github.com/hapifhir/hapi-fhir-jpaserver-starter into more_properties

# Conflicts:
#	src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java
This commit is contained in:
Sean McIlvenna
2019-02-13 11:39:15 -08:00
2 changed files with 42 additions and 0 deletions

View File

@@ -86,6 +86,10 @@ public class FhirServerConfigCommon {
retVal.setAutoCreatePlaceholderReferenceTargets(this.allowPlaceholderReferences);
retVal.setEmailFromAddress(this.emailFrom);
Integer maxFetchSize = HapiProperties.getMaximumFetchSize();
retVal.setFetchSizeDefaultMaximum(maxFetchSize);
ourLog.info("Server configured to have a maximum fetch size of " + (maxFetchSize == Integer.MAX_VALUE? "'unlimited'": maxFetchSize));
// You can enable these if you want to support Subscriptions from your server
if (this.subscriptionRestHookEnabled) {
retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.RESTHOOK);
@@ -132,6 +136,7 @@ public class FhirServerConfigCommon {
retVal.setUrl(HapiProperties.getDataSourceUrl());
retVal.setUsername(HapiProperties.getDataSourceUsername());
retVal.setPassword(HapiProperties.getDataSourcePassword());
retVal.setMaxTotal(HapiProperties.getDataSourceMaxPoolSize());
return retVal;
}

View File

@@ -7,6 +7,7 @@ import ca.uhn.fhir.rest.server.ETagSupportEnum;
import com.google.common.annotations.VisibleForTesting;
import java.io.InputStream;
import java.io.FileInputStream;
import java.util.Properties;
public class HapiProperties {
@@ -14,6 +15,7 @@ public class HapiProperties {
static final String ALLOW_MULTIPLE_DELETE = "allow_multiple_delete";
static final String ALLOW_PLACEHOLDER_REFERENCES = "allow_placeholder_references";
static final String DATASOURCE_DRIVER = "datasource.driver";
static final String DATASOURCE_MAX_POOL_SIZE = "datasource.max_pool_size";
static final String DATASOURCE_PASSWORD = "datasource.password";
static final String DATASOURCE_URL = "datasource.url";
static final String DATASOURCE_USERNAME = "datasource.username";
@@ -27,6 +29,7 @@ public class HapiProperties {
static final String LOGGER_FORMAT = "logger.format";
static final String LOGGER_LOG_EXCEPTIONS = "logger.log_exceptions";
static final String LOGGER_NAME = "logger.name";
static final String MAX_FETCH_SIZE = "max_fetch_size";
static final String MAX_PAGE_SIZE = "max_page_size";
static final String PERSISTENCE_UNIT_NAME = "persistence_unit_name";
static final String SERVER_ADDRESS = "server_address";
@@ -68,11 +71,37 @@ public class HapiProperties {
} catch (Exception e) {
throw new ConfigurationException("Could not load HAPI properties", e);
}
Properties overrideProps = loadOverrideProperties();
if(overrideProps != null) {
properties.putAll(overrideProps);
}
}
return properties;
}
/**
* If a configuration file path is explicitly specified via -Dhapi.properties=<path>, the properties there will
* be used to override the entries in the default hapi.properties file (currently under WEB-INF/classes)
* @return properties loaded from the explicitly specified configuraiton file if there is one, or null otherwise.
*/
private static Properties loadOverrideProperties() {
String confFile = System.getProperty(HAPI_PROPERTIES);
if(confFile != null) {
try {
Properties props = new Properties();
props.load(new FileInputStream(confFile));
return props;
}
catch (Exception e) {
throw new ConfigurationException("Could not load HAPI properties file: " + confFile, e);
}
}
return null;
}
private static String getProperty(String propertyName) {
Properties properties = HapiProperties.getProperties();
@@ -163,6 +192,10 @@ public class HapiProperties {
return HapiProperties.getIntegerProperty(MAX_PAGE_SIZE, 200);
}
public static Integer getMaximumFetchSize() {
return HapiProperties.getIntegerProperty(MAX_FETCH_SIZE, Integer.MAX_VALUE);
}
public static String getPersistenceUnitName() {
return HapiProperties.getProperty(PERSISTENCE_UNIT_NAME, "HAPI_PU");
}
@@ -187,6 +220,10 @@ public class HapiProperties {
return HapiProperties.getProperty(DATASOURCE_DRIVER, "org.apache.derby.jdbc.EmbeddedDriver");
}
public static Integer getDataSourceMaxPoolSize() {
return HapiProperties.getIntegerProperty(DATASOURCE_MAX_POOL_SIZE, 10);
}
public static String getDataSourceUrl() {
return HapiProperties.getProperty(DATASOURCE_URL, "jdbc:derby:directory:target/jpaserver_derby_files;create=true");
}