Search in sources :

Example 1 with PlaceholderResolvingStringValueResolver

use of com.revolsys.spring.util.PlaceholderResolvingStringValueResolver in project com.revolsys.open by revolsys.

the class BeanConfigurrer method processPlaceholderAttributes.

protected void processPlaceholderAttributes(final ConfigurableListableBeanFactory beanFactory, final String beanName, final Map<String, Object> attributes) throws BeansException {
    final StringValueResolver valueResolver = new PlaceholderResolvingStringValueResolver("${", "}", this.ignoreUnresolvablePlaceholders, null, attributes);
    final BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver);
    // locations.
    if (!(beanName.equals(this.beanName) && beanFactory.equals(this.applicationContext))) {
        final BeanDefinition bd = beanFactory.getBeanDefinition(beanName);
        try {
            visitor.visitBeanDefinition(bd);
        } catch (final BeanDefinitionStoreException ex) {
            throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanName, ex.getMessage());
        }
    }
    // NEW in Spring 2.5: resolve placeholders in alias target names and aliases
    // as well.
    beanFactory.resolveAliases(valueResolver);
}
Also used : StringValueResolver(org.springframework.util.StringValueResolver) PlaceholderResolvingStringValueResolver(com.revolsys.spring.util.PlaceholderResolvingStringValueResolver) PlaceholderResolvingStringValueResolver(com.revolsys.spring.util.PlaceholderResolvingStringValueResolver) BeanDefinitionVisitor(org.springframework.beans.factory.config.BeanDefinitionVisitor) BeanDefinitionStoreException(org.springframework.beans.factory.BeanDefinitionStoreException) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) GenericBeanDefinition(org.springframework.beans.factory.support.GenericBeanDefinition)

Example 2 with PlaceholderResolvingStringValueResolver

use of com.revolsys.spring.util.PlaceholderResolvingStringValueResolver in project com.revolsys.open by revolsys.

the class BeanConfigurrer method processPlaceholderAttributes.

protected void processPlaceholderAttributes(final ConfigurableListableBeanFactory beanFactory, final Map<String, Object> attributes) throws BeansException {
    final Map<String, Object> attributeMap = new LinkedHashMap<>();
    for (final Entry<String, Object> entry : attributes.entrySet()) {
        final String key = entry.getKey();
        final Object value = entry.getValue();
        if (!(value instanceof BeanReference)) {
            attributeMap.put(key, value);
        }
    }
    final StringValueResolver valueResolver = new PlaceholderResolvingStringValueResolver("${", "}", this.ignoreUnresolvablePlaceholders, null, attributeMap);
    final BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver);
    final String[] beanNames = beanFactory.getBeanDefinitionNames();
    for (int i = 0; i < beanNames.length; i++) {
        // locations.
        if (!(beanNames[i].equals(this.beanName) && beanFactory.equals(this.applicationContext))) {
            final BeanDefinition bd = beanFactory.getBeanDefinition(beanNames[i]);
            try {
                visitor.visitBeanDefinition(bd);
            } catch (final BeanDefinitionStoreException ex) {
                throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanNames[i], ex.getMessage());
            }
        }
    }
    // NEW in Spring 2.5: resolve placeholders in alias target names and aliases
    // as well.
    beanFactory.resolveAliases(valueResolver);
}
Also used : PlaceholderResolvingStringValueResolver(com.revolsys.spring.util.PlaceholderResolvingStringValueResolver) BeanDefinitionStoreException(org.springframework.beans.factory.BeanDefinitionStoreException) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) GenericBeanDefinition(org.springframework.beans.factory.support.GenericBeanDefinition) LinkedHashMap(java.util.LinkedHashMap) StringValueResolver(org.springframework.util.StringValueResolver) PlaceholderResolvingStringValueResolver(com.revolsys.spring.util.PlaceholderResolvingStringValueResolver) BeanDefinitionVisitor(org.springframework.beans.factory.config.BeanDefinitionVisitor) BeanReference(com.revolsys.spring.BeanReference)

Aggregations

PlaceholderResolvingStringValueResolver (com.revolsys.spring.util.PlaceholderResolvingStringValueResolver)2 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)2 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)2 BeanDefinitionVisitor (org.springframework.beans.factory.config.BeanDefinitionVisitor)2 GenericBeanDefinition (org.springframework.beans.factory.support.GenericBeanDefinition)2 StringValueResolver (org.springframework.util.StringValueResolver)2 BeanReference (com.revolsys.spring.BeanReference)1 LinkedHashMap (java.util.LinkedHashMap)1