Example usage for org.springframework.beans.factory.config PropertyPlaceholderConfigurer PropertyPlaceholderConfigurer

List of usage examples for org.springframework.beans.factory.config PropertyPlaceholderConfigurer PropertyPlaceholderConfigurer

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config PropertyPlaceholderConfigurer PropertyPlaceholderConfigurer.

Prototype

PropertyPlaceholderConfigurer

Source Link

Usage

From source file:stormy.pythian.service.spring.PyhtianProperties.java

@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
    PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
    propertyPlaceholderConfigurer.setLocations(new Resource[] { //
            new ClassPathResource("redis-config.properties"), //
            new ClassPathResource("pythian-config.properties") //
    });//  w  w  w.j  a v a  2  s . c om
    propertyPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(false);
    return propertyPlaceholderConfigurer;
}

From source file:org.trustedanalytics.platformcontext.unit.TestConfiguration.java

@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {

    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setIgnoreResourceNotFound(true);
    final Properties properties = new Properties();
    properties.setProperty("cf.resource", ApiControllerTest.CF_RESOURCE);
    properties.setProperty("cf.cli.version", "");
    properties.setProperty("cf.cli.url", "");
    properties.setProperty("platform.version", "0.1");
    properties.setProperty("platform.coreorg", "coreOrg");
    ppc.setProperties(properties);/*  w  w  w. ja  v a2 s  .c om*/

    return ppc;
}

From source file:com.zekke.webapp.config.TestConfig.java

@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer(ResourceLoader resourceLoader)
        throws IOException {
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setProperties(configProperties(resourceLoader).getObject());
    return ppc;/*from  w  ww .  j  ava  2s  .co  m*/
}

From source file:com.kixeye.chassis.support.test.config.ChassisConfigTestConfiguration.java

@Bean
static public PropertyPlaceholderConfigurer archaiusPropertyPlaceholderConfigurer()
        throws IOException, ConfigurationException {

    ConfigurationManager.loadPropertiesFromResources("chassis-test.properties");
    ConfigurationManager.loadPropertiesFromResources("chassis-default.properties");

    // force disable eureka
    ConfigurationManager.getConfigInstance().setProperty("chassis.eureka.disable", true);

    return new PropertyPlaceholderConfigurer() {
        @Override/*  w  w w .ja  v  a2s  .  co m*/
        protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) {
            return DynamicPropertyFactory.getInstance().getStringProperty(placeholder, "null").get();
        }
    };
}

From source file:com.iopr.DBResource.java

@Bean
public static PropertyPlaceholderConfigurer properties() {
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    Resource[] resources = new ClassPathResource[] { new ClassPathResource("db.properties") };
    ppc.setLocations(resources);//www. j a  v  a2 s  . c  o  m
    ppc.setIgnoreUnresolvablePlaceholders(true);
    return ppc;
}

From source file:com.aspose.showcase.qrcodegen.web.config.AppConfigProperties.java

@Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
    PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
    propertyPlaceholderConfigurer.setLocation(new ClassPathResource("config.properties"));
    // Allow for other PropertyPlaceholderConfigurer instances.
    propertyPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
    return propertyPlaceholderConfigurer;
}

From source file:com.zekke.webapp.config.MainConfig.java

/**
 * Creates a new PropertyPlaceholderConfigurer.
 *
 * @param resourceLoader any ResourceLoader.
 * @return a PropertyPlaceholderConfigurer.
 * @throws IOException if the properties file is not found in
 * {@link #CONFIG_PROPERTIES_URI}.//from  w  ww  . ja v  a 2s.c  om
 */
@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer(ResourceLoader resourceLoader)
        throws IOException {
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setProperties(configProperties(resourceLoader).getObject());
    return ppc;
}

From source file:edu.chalmers.dat076.moviefinder.config.ApplicationConfig.java

@Bean
public static PropertyPlaceholderConfigurer getPropertyPlaceholderConfigurer() {
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setLocation(new ClassPathResource("application.properties"));
    ppc.setIgnoreUnresolvablePlaceholders(true);
    return ppc;/*from  w w  w.  j a va2 s.c  o  m*/
}

From source file:edu.berkeley.compbio.ncbitaxonomy.service.NcbiTaxonomyServicesContextFactory.java

public static ApplicationContext makeNcbiTaxonomyServicesContext() throws IOException {

    File propsFile = PropertiesUtils.findPropertiesFile("NCBI_TAXONOMY_SERVICE_PROPERTIES", ".ncbitaxonomy",
            "service.properties");

    logger.debug("Using properties file: " + propsFile);
    Properties p = new Properties();
    FileInputStream is = null;//from  w  w  w.  j  a va2  s  .c o  m
    try {
        is = new FileInputStream(propsFile);
        p.load(is);
    } finally {
        is.close();
    }
    String dbName = (String) p.get("default");

    Map<String, Properties> databases = PropertiesUtils.splitPeriodDelimitedProperties(p);

    GenericApplicationContext ctx = new GenericApplicationContext();
    XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
    xmlReader.loadBeanDefinitions(new ClassPathResource("ncbitaxonomyclient.xml"));

    PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
    Properties properties = databases.get(dbName);

    if (properties == null) {
        logger.error("Service definition not found: " + dbName);
        logger.error("Valid names: " + StringUtils.join(databases.keySet().iterator(), ", "));
        throw new NcbiTaxonomyRuntimeException("Database definition not found: " + dbName);
    }

    cfg.setProperties(properties);
    ctx.addBeanFactoryPostProcessor(cfg);

    ctx.refresh();

    // add a shutdown hook for the above context...
    ctx.registerShutdownHook();

    return ctx;
}

From source file:dk.nsi.minlog.export.config.ApplicationRootConfig.java

@Bean
public static PropertyPlaceholderConfigurer configuration() {
    final PropertyPlaceholderConfigurer props = new PropertyPlaceholderConfigurer();
    props.setLocations(new Resource[] { new ClassPathResource("default.properties"),
            new FileSystemResource(getProperty("jboss.server.config.url") + "minlog." + getProperty("user.name")
                    + ".properties"),
            new ClassPathResource("minlog." + getProperty("user.name") + ".properties"),
            new ClassPathResource("jdbc.default.properties"),
            new FileSystemResource(getProperty("jboss.server.config.url") + "jdbc." + getProperty("user.name")
                    + ".properties"),
            new ClassPathResource("jdbc." + getProperty("user.name") + ".properties"),
            new FileSystemResource(getProperty("user.home") + "/.minlog/passwords.properties") });
    props.setIgnoreResourceNotFound(true);
    props.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);

    return props;
}