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

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

Introduction

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

Prototype

public void setProperties(Properties properties) 

Source Link

Document

Set local properties, e.g.

Usage

From source file:it.reply.orchestrator.config.Application.java

/**
 * Resolves Alien4Cloud ${...} placeholders within bean definition property values and @Value
 * annotations./*from   w w  w.j a  v a  2  s  .c  om*/
 *
 */
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer(ResourceLoader resourceLoader)
        throws IOException {

    PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertyPlaceholderConfigurer.setProperties(Alien4CloudConfig.alienConfig(resourceLoader).getObject());
    return propertyPlaceholderConfigurer;
}

From source file:io.gravitee.gateway.env.EnvironmentConfiguration.java

@Bean
public static PropertySourcesPlaceholderConfigurer properties(
        @Qualifier("graviteeProperties") Properties graviteeProperties) {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertySourcesPlaceholderConfigurer.setProperties(graviteeProperties);
    propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);

    return propertySourcesPlaceholderConfigurer;
}

From source file:io.gravitee.repository.jdbc.config.JdbcRepositoryConfigurationTest.java

@Bean
public static PropertySourcesPlaceholderConfigurer graviteePropertyPlaceholderConfigurer() {
    final PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();

    propertySourcesPlaceholderConfigurer.setProperties(graviteeProperties());
    propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);

    return propertySourcesPlaceholderConfigurer;
}

From source file:fr.norad.jaxrs.oauth2.core.tck.spring.SpringConfiguration.java

@Bean
static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
    PropertySourcesPlaceholderConfigurer props = new PropertySourcesPlaceholderConfigurer();
    Properties properties = new Properties();
    properties.setProperty("token.lifetime.second.default", "42");
    properties.setProperty("refresh_token.lifetime.second.default", "42");
    props.setProperties(properties);
    return props;
}

From source file:ru.elcor.mis.scheduler.config.AppConfig.java

@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
    Properties Props = new Properties();
    Props.setProperty("cron", "0-59/2 * * * * *");
    properties.setProperties(Props);
    properties.setLocation(new ClassPathResource("scheduler.properties"));
    properties.setIgnoreResourceNotFound(false);

    return properties;
}

From source file:de.thischwa.pmcms.conf.BasicConfigurator.java

private void init() {
    if (System.getProperty("data.dir") == null)
        throw new IllegalArgumentException("No data directory set!");
    dataDir = new File(System.getProperty("data.dir"));
    if (!dataDir.exists())
        throw new IllegalArgumentException(
                String.format("Data directory not found: %s", dataDir.getAbsolutePath()));

    // load and merge the properties 
    loadProperties();/* w ww.  j  a  va  2s.c o m*/

    // build special props
    String baseUrl = String.format("http://%s:%s/", props.get("pmcms.jetty.host"),
            props.get("pmcms.jetty.port"));
    props.setProperty("baseurl", baseUrl);
    props.setProperty("data.dir", dataDir.getAbsolutePath());
    System.setProperty("content.types.user.table",
            new File(Constants.APPLICATION_DIR, "lib/content-types.properties").getAbsolutePath());

    // init log4j
    LogManager.resetConfiguration();
    PropertyConfigurator.configure(PropertiesTool.getProperties(props, "log4j"));
    Logger logger = Logger.getLogger(BasicConfigurator.class);
    logger.info("*** log4j initialized!");

    // init the spring framework
    try {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.scan("de.thischwa.pmcms");
        PropertySourcesPlaceholderConfigurer config = new PropertySourcesPlaceholderConfigurer();
        config.setProperties(props);
        config.postProcessBeanFactory(ctx.getDefaultListableBeanFactory());
        ctx.refresh();
        context = ctx;
        logger.info("*** Spring initialized!");
        PropertiesManager pm = context.getBean(PropertiesManager.class);
        pm.setProperties(props);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    logger.info("*** Basic configuration successful done.");
}

From source file:de.hoegertn.demo.cxfsimple.SpringStarter.java

public final void doStart() throws Exception {
    try {//from   w w w  . j ava 2s  .c  om
        this.doBeforeSpringStart();
    } catch (Exception e) {
        throw new RuntimeException("Before spring failed", e);
    }

    Lock writeLock = this.rwLock.writeLock();
    AbstractXmlApplicationContext ctx = null;
    try {
        writeLock.lock();
        if (this.context.get() != null) {
            throw new RuntimeException("Already started");
        }
        ctx = this.createSpringContext();

        final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        configurer.setProperties(System.getProperties());
        ctx.addBeanFactoryPostProcessor(configurer);

        ctx.setConfigLocation(this.getSpringResource());
        ctx.refresh();
    } catch (Exception e) {
        if (ctx != null) {
            try {
                ctx.close();
            } catch (Exception e1) {
                this.logger.warn("Failed to close context", e1);
            }
            ctx = null;
        }
        throw new RuntimeException("Spring context failed", e);
    } finally {
        if (ctx != null) {
            this.context.set(ctx);
        }
        writeLock.unlock();
    }

    try {
        this.doAfterSpringStart();
    } catch (Exception e) {
        throw new RuntimeException("After spring failed", e);
    }
}

From source file:de.taimos.daemon.spring.SpringDaemonAdapter.java

@Override
public final void doStart() throws Exception {
    super.doStart();
    try {//from  w  w w  . j  a  v a  2s  . c  o  m
        this.doBeforeSpringStart();
    } catch (Exception e) {
        throw new RuntimeException("Before spring failed", e);
    }

    Lock writeLock = this.rwLock.writeLock();
    AbstractXmlApplicationContext ctx = null;
    try {
        writeLock.lock();
        if (this.context.get() != null) {
            throw new RuntimeException("Already started");
        }
        ctx = this.createSpringContext();
        String[] profiles = System.getProperty(Configuration.PROFILES, Configuration.PROFILES_PRODUCTION)
                .split(",");
        ctx.getEnvironment().setActiveProfiles(profiles);

        final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        configurer.setProperties(DaemonStarter.getDaemonProperties());
        ctx.addBeanFactoryPostProcessor(configurer);

        ctx.setConfigLocation(this.getSpringResource());
        ctx.refresh();
    } catch (Exception e) {
        if (ctx != null) {
            try {
                ctx.close();
            } catch (Exception e1) {
                this.logger.warn("Failed to close context", e1);
            }
            ctx = null;
        }
        throw new RuntimeException("Spring context failed", e);
    } finally {
        if (ctx != null) {
            this.context.set(ctx);
        }
        writeLock.unlock();
    }

    try {
        this.doAfterSpringStart();
    } catch (Exception e) {
        throw new RuntimeException("After spring failed", e);
    }
}

From source file:uk.ac.ebi.eva.pipeline.configuration.CommonConfiguration.java

@Bean
private static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();

    Properties properties = new Properties();
    properties.put("input.vcf", "");
    properties.put("input.vcf.id", "1");
    properties.put("input.vcf.aggregation", "NONE");
    properties.put("input.study.type", "COLLECTION");
    properties.put("input.study.name", "input.study.name");
    properties.put("input.study.id", "1");
    properties.put("input.pedigree", "");
    properties.put("input.gtf", "");
    properties.put("input.fasta", "");

    properties.put("output.dir", "/tmp");
    properties.put("output.dir.annotation", "");
    properties.put("output.dir.statistics", "/tmp");

    properties.put("statistics.overwrite", "false");

    properties.put("db.hosts", "localhost:27017");
    //        properties.put("dbName", null);
    properties.put("db.collection.variants.name", "variants");
    properties.put("db.collection.files.name", "files");
    properties.put("db.collections.features.name", "features");
    properties.put("config.db.read-preference", "primary");

    properties.put("app.opencga.path", opencgaHome);
    properties.put("app.vep.path", "");
    properties.put("app.vep.cache.path", "");
    properties.put("app.vep.cache.version", "");
    properties.put("app.vep.cache.species", "");
    properties.put("app.vep.num-forks", "3");

    properties.put("config.restartability.allow", false);

    configurer.setProperties(properties);

    return configurer;
}