Example usage for org.springframework.context.support PropertySourcesPlaceholderConfigurer setLocations

List of usage examples for org.springframework.context.support PropertySourcesPlaceholderConfigurer setLocations

Introduction

In this page you can find the example usage for org.springframework.context.support PropertySourcesPlaceholderConfigurer setLocations.

Prototype

public void setLocations(Resource... locations) 

Source Link

Document

Set locations of properties files to be loaded.

Usage

From source file:com.clicktravel.cheddar.server.runtime.config.PropertiesConfigurationBuilder.java

public static PropertySourcesPlaceholderConfigurer configurer(final boolean isDevProfileActive,
        final String servicePropertiesPath) {
    final String environmentPropertiesPath = "com.clicktravel.services.env.properties";
    FeatureRegistry.init(environmentPropertiesPath);
    final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(true);

    // Note : Later property resources in this list override earlier ones
    final List<Resource> resources = new LinkedList<>();
    if (isDevProfileActive) {
        addResource(resources, "local-" + servicePropertiesPath); // TODO Remove when migrated to dev
        addResource(resources, "dev-" + servicePropertiesPath);
    } else {/*from   www .  ja va 2 s .c o m*/
        addResource(resources, servicePropertiesPath);
    }
    addResource(resources, "com.clicktravel.cheddar.server.properties");
    addResource(resources, environmentPropertiesPath);

    configurer.setLocations(resources.toArray(new Resource[0]));
    return configurer;
}

From source file:fr.treeptik.cloudunit.initializer.CloudUnitApplicationContext.java

@Bean
@Profile("production")
public static PropertySourcesPlaceholderConfigurer propertiesForProduction() throws Exception {
    PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
    File customFile = new File(System.getProperty("user.home") + "/.cloudunit/configuration.properties");
    Resource[] resources = null;//from   w w w.  ja  v  a2 s  .  com
    if (customFile.exists()) {
        resources = new Resource[] { new ClassPathResource("application-production.properties"),
                new FileSystemResource(
                        new File(System.getProperty("user.home") + "/.cloudunit/configuration.properties")) };
    } else {
        logger.error(customFile.getAbsolutePath() + " is missing. It could generate configuration error");
        resources = new Resource[] { new ClassPathResource("application-production.properties"), };
    }
    pspc.setLocations(resources);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}

From source file:org.openhims.oauth2.configuration.PropertiesConfiguration.java

public PropertySourcesPlaceholderConfigurer getProperties() {
    PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
    Resource[] resources = new Resource[] { new ClassPathResource("properties/application.properties"),
            new ClassPathResource("properties/server.properties") };
    pspc.setLocations(resources);
    pspc.setIgnoreUnresolvablePlaceholders(IGNORE_UNRESOLVABLE_PLACEHOLDERS);
    pspc.setIgnoreResourceNotFound(true);
    return pspc;//from  w  ww.ja va  2 s .  co m
}

From source file:org.shaigor.rest.retro.service.impl.WordsSereviceTestConfig.java

@Bean
public PropertySourcesPlaceholderConfigurer properties() {
    PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
    ppc.setLocalOverride(true);/* www.  j a  v  a2  s .  com*/
    String filenamePrefix = determineFilename("words").startsWith(SRC_PATH) ? "src." : "classes.";
    org.springframework.core.io.Resource[] resources = new ClassPathResource[] {
            new ClassPathResource(filenamePrefix + WORDS_SERVICE_PROPERTIES) };
    ppc.setLocations(resources);
    return ppc;
}