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

ContextNamespaceHandlerTests.java 文件源码 项目:spring4-understanding 阅读 24 收藏 0 点赞 0 评论 0
@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"));
}
ContextNamespaceHandlerTests.java 文件源码 项目:spring4-understanding 阅读 24 收藏 0 点赞 0 评论 0
@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"));
}
ContextNamespaceHandlerTests.java 文件源码 项目:spring4-understanding 阅读 19 收藏 0 点赞 0 评论 0
@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"));
}
EmbeddedPlaceholderResolver.java 文件源码 项目:sdcct 阅读 20 收藏 0 点赞 0 评论 0
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);
}
ContextNamespaceHandlerTests.java 文件源码 项目:class-guard 阅读 19 收藏 0 点赞 0 评论 0
@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);
}
ContextNamespaceHandlerTests.java 文件源码 项目:class-guard 阅读 30 收藏 0 点赞 0 评论 0
@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);
}
ContextNamespaceHandlerTests.java 文件源码 项目:class-guard 阅读 23 收藏 0 点赞 0 评论 0
@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);
}
FrameworkBeanFactory.java 文件源码 项目:carewebframework-core 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
SpringPropertyReplacer.java 文件源码 项目:gen-sbconfigurator 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Default constructor
 */
public SpringPropertyReplacer() {
    phHelper = new PropertyPlaceholderHelper(
            PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX,
            PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX,
            PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR, true);
}
StompSupportConfiguration.java 文件源码 项目:stomp 阅读 22 收藏 0 点赞 0 评论 0
@Override
public boolean matches(
        final ConditionContext context, final AnnotatedTypeMetadata metadata
) {
    return context.getBeanFactory().getBeansOfType(PlaceholderConfigurerSupport.class).isEmpty();
}
ServletConfiguration.java 文件源码 项目:java-platform 阅读 28 收藏 0 点赞 0 评论 0
@Bean
public static PlaceholderConfigurerSupport placeholderConfigurer() {
    return new ConfigurationPropertySourcesPlaceholderConfigurer(StaticConfigurationSupplier.getConfiguration());
}
ConfigConfiguration.java 文件源码 项目:java-platform 阅读 20 收藏 0 点赞 0 评论 0
@Bean
public static PlaceholderConfigurerSupport placeholderConfigurer() {
    return new ConfigurationPropertySourcesPlaceholderConfigurer(StaticConfigurationSupplier.getConfiguration());
}
DefaultTokenReplacer.java 文件源码 项目:ml-javaclient-util 阅读 19 收藏 0 点赞 0 评论 0
protected void initializeHelper() {
    helper = new PropertyPlaceholderHelper(PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX,
        PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX,
        PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR, true);
}
MongoGridFsApplication.java 文件源码 项目:socialDocumentLibrary 阅读 26 收藏 0 点赞 0 评论 0
@Bean
public static PlaceholderConfigurerSupport propertyPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}


问题


面经


文章

微信
公众号

扫码关注公众号