Java 类org.springframework.beans.factory.config.PlaceholderConfigurerSupport 实例源码

项目:spring4-understanding    文件:ContextNamespaceHandlerTests.java   
@Test
public void propertyPlaceholder() throws Exception {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "contextNamespaceHandlerTests-replace.xml", getClass());
    Map<String, PlaceholderConfigurerSupport> beans = applicationContext
            .getBeansOfType(PlaceholderConfigurerSupport.class);
    assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
    assertEquals("bar", applicationContext.getBean("string"));
    assertEquals("null", applicationContext.getBean("nullString"));
}
项目:spring4-understanding    文件:ContextNamespaceHandlerTests.java   
@Test
public void propertyPlaceholderEnvironmentProperties() throws Exception {
    MockEnvironment env = new MockEnvironment().withProperty("foo", "spam");
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
    applicationContext.setEnvironment(env);
    applicationContext.load(new ClassPathResource("contextNamespaceHandlerTests-simple.xml", getClass()));
    applicationContext.refresh();
    Map<String, PlaceholderConfigurerSupport> beans = applicationContext
            .getBeansOfType(PlaceholderConfigurerSupport.class);
    assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
    assertEquals("spam", applicationContext.getBean("string"));
    assertEquals("none", applicationContext.getBean("fallback"));
}
项目:spring4-understanding    文件:ContextNamespaceHandlerTests.java   
@Test
public void propertyPlaceholderIgnored() throws Exception {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "contextNamespaceHandlerTests-replace-ignore.xml", getClass());
    Map<String, PlaceholderConfigurerSupport> beans = applicationContext
            .getBeansOfType(PlaceholderConfigurerSupport.class);
    assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
    assertEquals("${bar}", applicationContext.getBean("string"));
    assertEquals("null", applicationContext.getBean("nullString"));
}
项目:sdcct    文件:EmbeddedPlaceholderResolver.java   
public String resolvePlaceholders(String str, boolean asPropName) {
    if (asPropName) {
        String strResolving = PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX + str + PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX,
            strResolved = this.beanFactory.resolveEmbeddedValue(strResolving);

        if (!strResolved.equals(strResolving)) {
            str = strResolved;
        }
    } else {
        str = this.beanFactory.resolveEmbeddedValue(str);
    }

    return Objects.toString(this.beanExprResolver.evaluate(str, this.beanExprContext), null);
}
项目:class-guard    文件:ContextNamespaceHandlerTests.java   
@Test
public void propertyPlaceholder() throws Exception {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "contextNamespaceHandlerTests-replace.xml", getClass());
    Map<String, PlaceholderConfigurerSupport> beans = applicationContext
            .getBeansOfType(PlaceholderConfigurerSupport.class);
    assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
    String s = (String) applicationContext.getBean("string");
    assertEquals("No properties replaced", "bar", s);
}
项目:class-guard    文件:ContextNamespaceHandlerTests.java   
@Test
public void propertyPlaceholderEnvironmentProperties() throws Exception {
    MockEnvironment env = new MockEnvironment().withProperty("foo", "spam");
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
    applicationContext.setEnvironment(env);
    applicationContext.load(new ClassPathResource("contextNamespaceHandlerTests-simple.xml", getClass()));
    applicationContext.refresh();
    Map<String, PlaceholderConfigurerSupport> beans = applicationContext
            .getBeansOfType(PlaceholderConfigurerSupport.class);
    assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
    String s = (String) applicationContext.getBean("string");
    assertEquals("No properties replaced", "spam", s);
}
项目:class-guard    文件:ContextNamespaceHandlerTests.java   
@Test
public void propertyPlaceholderIgnored() throws Exception {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "contextNamespaceHandlerTests-replace-ignore.xml", getClass());
    Map<String, PlaceholderConfigurerSupport> beans = applicationContext
            .getBeansOfType(PlaceholderConfigurerSupport.class);
    assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
    String s = (String) applicationContext.getBean("string");
    assertEquals("Properties replaced", "${bar}", s);
}
项目:carewebframework-core    文件:FrameworkBeanFactory.java   
/**
 * Creates a bean factory.
 *
 * @param parentContext Parent application context, if any. When specified, any placeholder
 *            configurers found in the parent context will be registered in this bean factory.
 * @param parentBeanFactory The parent bean factory, if any.
 */
public FrameworkBeanFactory(ApplicationContext parentContext, BeanFactory parentBeanFactory) {
    super(parentBeanFactory);
    int i = 0;

    if (parentContext != null) {
        for (PlaceholderConfigurerSupport configurer : parentContext
                .getBeansOfType(PlaceholderConfigurerSupport.class, false, false).values()) {
            registerSingleton("_placeholderconfigurer" + ++i, configurer);
        }
    }
}
项目:gen-sbconfigurator    文件:SpringPropertyReplacer.java   
/**
 * Default constructor
 */
public SpringPropertyReplacer() {
    phHelper = new PropertyPlaceholderHelper(
            PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX,
            PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX,
            PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR, true);
}
项目:stomp    文件:StompSupportConfiguration.java   
@Override
public boolean matches(
        final ConditionContext context, final AnnotatedTypeMetadata metadata
) {
    return context.getBeanFactory().getBeansOfType(PlaceholderConfigurerSupport.class).isEmpty();
}
项目:java-platform    文件:ServletConfiguration.java   
@Bean
public static PlaceholderConfigurerSupport placeholderConfigurer() {
    return new ConfigurationPropertySourcesPlaceholderConfigurer(StaticConfigurationSupplier.getConfiguration());
}
项目:java-platform    文件:ConfigConfiguration.java   
@Bean
public static PlaceholderConfigurerSupport placeholderConfigurer() {
    return new ConfigurationPropertySourcesPlaceholderConfigurer(StaticConfigurationSupplier.getConfiguration());
}
项目:ml-javaclient-util    文件:DefaultTokenReplacer.java   
protected void initializeHelper() {
    helper = new PropertyPlaceholderHelper(PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX,
        PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX,
        PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR, true);
}
项目:socialDocumentLibrary    文件:MongoGridFsApplication.java   
@Bean
public static PlaceholderConfigurerSupport propertyPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}