ca.uhn.fhir.context.ConfigurationException Java Examples

The following examples show how to use ca.uhn.fhir.context.ConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HapiProperties.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
public static Properties getProperties() {
    if (properties == null) {
        // Load the configurable properties file
        try (InputStream in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES)){
            HapiProperties.properties = new Properties();
            HapiProperties.properties.load(in);
        } catch (Exception e) {
            throw new ConfigurationException("Could not load HAPI properties", e);
        }

        Properties overrideProps = loadOverrideProperties();
        if(overrideProps != null) {
            properties.putAll(overrideProps);
        }
    }

    return properties;
}
 
Example #2
Source File: HapiProperties.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: HapiProperties.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
public static Properties getProperties() {
    if (properties == null) {
        // Load the configurable properties file
        try (InputStream in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES)){
            HapiProperties.properties = new Properties();
            HapiProperties.properties.load(in);
        } catch (Exception e) {
            throw new ConfigurationException("Could not load HAPI properties", e);
        }

        Properties overrideProps = loadOverrideProperties();
        if(overrideProps != null) {
          properties.putAll(overrideProps);
        }
    }

    return properties;
}
 
Example #4
Source File: HapiProperties.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
/**
 * 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 + "." + HapiProperties.getProperty(FHIR_VERSION));
    if (confFile == null) {
        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;
}
 
Example #5
Source File: FhirServerConfigDstu3.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@Override
@Bean()
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
    retVal.setPersistenceUnitName("HAPI_PU");

    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.getJpaProperties());
    return retVal;
}
 
Example #6
Source File: FhirServerConfigR5.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@Override
@Bean()
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
    retVal.setPersistenceUnitName("HAPI_PU");

    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.getJpaProperties());
    return retVal;
}
 
Example #7
Source File: FhirServerConfigDstu2.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@Override
@Bean()
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
    retVal.setPersistenceUnitName("HAPI_PU");

    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.getJpaProperties());
    return retVal;
}
 
Example #8
Source File: FhirServerConfigR4.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@Override
@Bean()
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
    retVal.setPersistenceUnitName("HAPI_PU");

    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.getJpaProperties());
    return retVal;
}
 
Example #9
Source File: HapiProperties.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: FhirServerConfigDstu3.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #11
Source File: FhirServerConfigR4.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
@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;
}