Example usage for org.springframework.core.env PropertiesPropertySource PropertiesPropertySource

List of usage examples for org.springframework.core.env PropertiesPropertySource PropertiesPropertySource

Introduction

In this page you can find the example usage for org.springframework.core.env PropertiesPropertySource PropertiesPropertySource.

Prototype

protected PropertiesPropertySource(String name, Map<String, Object> source) 

Source Link

Usage

From source file:gov.uscis.vis.api.config.SwaggerPropertiesLoader.java

@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    ConfigurableEnvironment env = event.getEnvironment();
    env.getPropertySources().addLast(new PropertiesPropertySource("swagger", createSwaggerProperties(env)));
}

From source file:org.greencheek.utils.environment.propertyplaceholder.examples.spring.profile.AppBootstrap.java

public static void initialise(ConfigurableApplicationContext applicationContext) {
    applicationContext.getEnvironment().getPropertySources()
            .addFirst(new PropertiesPropertySource("p", environmentalProperties));
}

From source file:org.jdal.beans.AppCtx.java

public synchronized static void setProperties(String name, Properties properties) {
    propertySource = new PropertiesPropertySource(name, properties);
}

From source file:com.textocat.textokit.eval.EvaluationLauncher.java

public static void runUsingProperties(Properties configProperties) throws Exception {
    GenericApplicationContext appCtx = new GenericApplicationContext();

    appCtx.getEnvironment().getPropertySources()
            .addLast(new PropertiesPropertySource("configFile", configProperties));

    XmlBeanDefinitionReader xmlBDReader = new XmlBeanDefinitionReader(appCtx);
    xmlBDReader.loadBeanDefinitions(APP_CONTEXT_LOCATION);

    // register listeners
    Map<String, String> listenerImpls = getPrefixedKeyPairs(configProperties, PREFIX_LISTENER_ID);
    for (String listenerId : listenerImpls.keySet()) {
        String listenerClass = listenerImpls.get(listenerId);
        BeanDefinitionBuilder bb = genericBeanDefinition(listenerClass);
        Map<String, String> listenerProperties = getPrefixedKeyPairs(configProperties,
                PREFIX_LISTENER_PROPERTY + listenerId + ".");
        for (String propName : listenerProperties.keySet()) {
            bb.addPropertyValue(propName, listenerProperties.get(propName));
        }/*  w w w .j  a v  a2s  .c o m*/
        appCtx.registerBeanDefinition(listenerId, bb.getBeanDefinition());
    }

    appCtx.refresh();

    appCtx.registerShutdownHook();

    GoldStandardBasedEvaluation eval = appCtx.getBean(GoldStandardBasedEvaluation.class);
    eval.run();
}

From source file:org.greencheek.utils.environment.propertyplaceholder.examples.spring.profile.AppBootstrap.java

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

    MutablePropertySources sources = new MutablePropertySources();
    sources.addFirst(new PropertiesPropertySource("p", environmentalProperties));

    config.setPropertySources(sources);/*w ww .j a v  a2 s .  com*/

    return config;
}

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

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
    ((ConfigurableEnvironment) environment).getPropertySources()
            .addFirst(new PropertiesPropertySource("graviteeConfiguration", properties));
}

From source file:io.gravitee.management.rest.spring.PropertySourceBeanProcessor.java

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    ((ConfigurableEnvironment) environment).getPropertySources()
            .addFirst(new PropertiesPropertySource("graviteeConfiguration", properties));
}

From source file:com.acme.ModuleConfigurationTest.java

@Test
public void test() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    Properties properties = new Properties();
    properties.put("prefix", "foo");
    properties.put("suffix", "bar");
    context.getEnvironment().getPropertySources().addLast(new PropertiesPropertySource("options", properties));
    context.register(TestConfiguration.class);
    context.refresh();/*from  w  w  w  .j a va 2  s  .c  om*/

    MessageChannel input = context.getBean("input", MessageChannel.class);
    SubscribableChannel output = context.getBean("output", SubscribableChannel.class);

    final AtomicBoolean handled = new AtomicBoolean();
    output.subscribe(new MessageHandler() {
        @Override
        public void handleMessage(Message<?> message) throws MessagingException {
            handled.set(true);
            assertEquals("foohellobar", message.getPayload());
        }
    });
    input.send(new GenericMessage<String>("hello"));
    assertTrue(handled.get());
}

From source file:org.alfresco.bm.user.UserEventHandlingTest.java

@Before
public void setUp() {
    Properties props = new Properties();
    props.put("mongoCollection", COLLECTION_BM_USER_DATA_SERVICE);

    ctx = new ClassPathXmlApplicationContext(new String[] { "test-MongoUserDataTest-context.xml" }, false);
    ctx.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("TestProps", props));
    ctx.refresh();/*from  ww w  . jav a 2  s . com*/
    ctx.start();
    userDataService = ctx.getBean(UserDataService.class);
}

From source file:org.alfresco.bm.session.SessionServiceTest.java

@Before
public void setUp() {
    Properties props = new Properties();
    props.put("mongoCollection", COLLECTION_BM_USER_DATA_SERVICE);

    ctx = new ClassPathXmlApplicationContext(new String[] { "test-MongoSessionServiceTest-context.xml" },
            false);/*from   w  w w . j a  v a 2 s  . com*/
    ctx.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("TestProps", props));
    ctx.refresh();
    ctx.start();
    sessionService = ctx.getBean(SessionService.class);
}