Java 类org.springframework.core.env.PropertySourcesPropertyResolver 实例源码

项目:rmap    文件:KafkaPropertyUtils.java   
/**
 * Resolves any {@link KafkaPropertyUtils#isNullValue(Object) null} property values in the {@code Map} using the
 * supplied {@code propertyResolver} and {@code Environment}.
 *
 * @param props
 * @param propertyResolver
 * @param env
 */
public static void resolveProperties(Map<String, Object> props, PropertySourcesPropertyResolver propertyResolver,
                                     Environment env) {
    props.entrySet().stream()
            .filter(entry -> isNullValue(entry.getValue()) || entry.getValue().toString().contains("${"))
            .forEach(entry -> {
                String resolvedValue = null;
                if (isNullValue(entry.getValue())) {
                    resolvedValue = env.getProperty(entry.getKey());
                    LOG.debug("Resolved kafka null property key [{}] to [{}]", entry.getKey(), resolvedValue);
                } else {
                    resolvedValue = entry.getValue().toString();
                }

                if (resolvedValue != null && resolvedValue.contains("${")) {
                    String placeholder = resolvedValue;
                    resolvedValue = propertyResolver.resolvePlaceholders(resolvedValue);
                    resolvedValue = env.resolvePlaceholders(resolvedValue);
                    LOG.debug("Resolved kafka property key [{}] with placeholder [{}] to [{}]",
                            entry.getKey(), placeholder, resolvedValue);
                }

                props.put(entry.getKey(), resolvedValue);
            });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private void processNonEnumerablePropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    // We can only do exact matches for non-enumerable property names, but
    // that's better than nothing...
    if (this.nonEnumerableFallbackNames == null) {
        return;
    }
    for (String propertyName : this.nonEnumerableFallbackNames) {
        if (!source.containsProperty(propertyName)) {
            continue;
        }
        Object value = null;
        try {
            value = resolver.getProperty(propertyName, Object.class);
        }
        catch (RuntimeException ex) {
            // Probably could not convert to Object, weird, but ignorable
        }
        if (value == null) {
            value = source.getProperty(propertyName.toUpperCase());
        }
        putIfAbsent(propertyName, value, source);
    }
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
private void processNonEnumerablePropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    // We can only do exact matches for non-enumerable property names, but
    // that's better than nothing...
    if (this.nonEnumerableFallbackNames == null) {
        return;
    }
    for (String propertyName : this.nonEnumerableFallbackNames) {
        if (!source.containsProperty(propertyName)) {
            continue;
        }
        Object value = null;
        try {
            value = resolver.getProperty(propertyName, Object.class);
        }
        catch (RuntimeException ex) {
            // Probably could not convert to Object, weird, but ignorable
        }
        if (value == null) {
            value = source.getProperty(propertyName.toUpperCase());
        }
        putIfAbsent(propertyName, value, source);
    }
}
项目:director-aws-plugin    文件:PropertyResolvers.java   
/**
 * Creates a property resolver that pulls from multiple property resource
 * locations. The first "built-in" location must be successfully loaded, but
 * all other "custom" locations must load only if {code}allowMissing{code} is
 * false.
 *
 * @param allowMissing            true to allow custom resource locations to fail to load
 * @param builtInResourceLocation lowest precedence, required resource
 *                                location for properties
 * @param customResourceLocations additional resource locations for
 *                                properties, in increasing order of precedence
 * @return new property resolver
 * @throws IOException          if the built-in resource location could not be loaded,
 *                              or if {code}allowMissing{code} is false and any custom resource location
 *                              fails to load
 * @throws NullPointerException if any resource location is null
 */
public static PropertyResolver newMultiResourcePropertyResolver(boolean allowMissing,
    String builtInResourceLocation,
    String... customResourceLocations)
    throws IOException {
  MutablePropertySources sources = new MutablePropertySources();
  checkNotNull(builtInResourceLocation, "builtInResourceLocation is null");
  sources.addLast(buildPropertySource(BUILT_IN_NAME, builtInResourceLocation,
      false));
  String lastname = BUILT_IN_NAME;
  int customCtr = 1;
  for (String loc : customResourceLocations) {
    checkNotNull(loc, "customResourceLocations[" + (customCtr - 1) +
        "] is null");
    String thisname = CUSTOM_NAME_PREFIX + customCtr++;
    PropertySource source = buildPropertySource(thisname, loc, allowMissing);
    if (source != null) {
      sources.addBefore(lastname, source);
      lastname = thisname;
    }
  }

  return new PropertySourcesPropertyResolver(sources);
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
private void processNonEnumerablePropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    // We can only do exact matches for non-enumerable property names, but
    // that's better than nothing...
    if (this.nonEnumerableFallbackNames == null) {
        return;
    }
    for (String propertyName : this.nonEnumerableFallbackNames) {
        if (!source.containsProperty(propertyName)) {
            continue;
        }
        Object value = null;
        try {
            value = resolver.getProperty(propertyName, Object.class);
        }
        catch (RuntimeException ex) {
            // Probably could not convert to Object, weird, but ignoreable
        }
        if (value == null) {
            value = source.getProperty(propertyName.toUpperCase());
        }
        putIfAbsent(propertyName, value, source);
    }
}
项目:slurper-configuration    文件:ConfigPlaceholderConfigurer.java   
@Override
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) {
    if (propertySources == null) {
        propertySources = new MutablePropertySources();
        if (environment != null) {
            propertySources.addLast(
                new PropertySource<Environment>(PropertySourcesPlaceholderConfigurer.ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, environment) {
                    @Override
                    public String getProperty(final String key) {
                        return source.getProperty(key);
                    }
                }
            );
        }
        ConfigPropertySource configPropertySource = new ConfigPropertySource(CONFIG_PROPERTY_SOURCE_NAME, config);
        if (localOverride) {
            propertySources.addFirst(configPropertySource);
        }
        else {
            propertySources.addLast(configPropertySource);
        }
    }
    processProperties(beanFactory, new PropertySourcesPropertyResolver(propertySources));
    appliedPropertySources = propertySources;
}
项目:lams    文件:PropertySourcesPlaceholderConfigurer.java   
/**
 * {@inheritDoc}
 * <p>Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
 * against this configurer's set of {@link PropertySources}, which includes:
 * <ul>
 * <li>all {@linkplain org.springframework.core.env.ConfigurableEnvironment#getPropertySources
 * environment property sources}, if an {@code Environment} {@linkplain #setEnvironment is present}
 * <li>{@linkplain #mergeProperties merged local properties}, if {@linkplain #setLocation any}
 * {@linkplain #setLocations have} {@linkplain #setProperties been}
 * {@linkplain #setPropertiesArray specified}
 * <li>any property sources set by calling {@link #setPropertySources}
 * </ul>
 * <p>If {@link #setPropertySources} is called, <strong>environment and local properties will be
 * ignored</strong>. This method is designed to give the user fine-grained control over property
 * sources, and once set, the configurer makes no assumptions about adding additional sources.
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
        this.propertySources = new MutablePropertySources();
        if (this.environment != null) {
            this.propertySources.addLast(
                new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
                    @Override
                    public String getProperty(String key) {
                        return this.source.getProperty(key);
                    }
                }
            );
        }
        try {
            PropertySource<?> localPropertySource =
                new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties());
            if (this.localOverride) {
                this.propertySources.addFirst(localPropertySource);
            }
            else {
                this.propertySources.addLast(localPropertySource);
            }
        }
        catch (IOException ex) {
            throw new BeanInitializationException("Could not load properties", ex);
        }
    }

    processProperties(beanFactory, new PropertySourcesPropertyResolver(this.propertySources));
    this.appliedPropertySources = this.propertySources;
}
项目:rmap    文件:FactoryState.java   
Map<String, Object> getConfigurationProperties() {
    Map<String, Object> props = asMap(sources, prefix, strip);
    PropertySourcesPropertyResolver propertyResolver = new PropertySourcesPropertyResolver(sources);
    resolveProperties(props, propertyResolver, env);

    return props;
}
项目:spring4-understanding    文件:PropertySourcesPlaceholderConfigurer.java   
/**
 * {@inheritDoc}
 * <p>Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
 * against this configurer's set of {@link PropertySources}, which includes:
 * <ul>
 * <li>all {@linkplain org.springframework.core.env.ConfigurableEnvironment#getPropertySources
 * environment property sources}, if an {@code Environment} {@linkplain #setEnvironment is present}
 * <li>{@linkplain #mergeProperties merged local properties}, if {@linkplain #setLocation any}
 * {@linkplain #setLocations have} {@linkplain #setProperties been}
 * {@linkplain #setPropertiesArray specified}
 * <li>any property sources set by calling {@link #setPropertySources}
 * </ul>
 * <p>If {@link #setPropertySources} is called, <strong>environment and local properties will be
 * ignored</strong>. This method is designed to give the user fine-grained control over property
 * sources, and once set, the configurer makes no assumptions about adding additional sources.
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
        this.propertySources = new MutablePropertySources();
        if (this.environment != null) {
            this.propertySources.addLast(
                new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
                    @Override
                    public String getProperty(String key) {
                        return this.source.getProperty(key);
                    }
                }
            );
        }
        try {
            PropertySource<?> localPropertySource =
                    new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties());
            if (this.localOverride) {
                this.propertySources.addFirst(localPropertySource);
            }
            else {
                this.propertySources.addLast(localPropertySource);
            }
        }
        catch (IOException ex) {
            throw new BeanInitializationException("Could not load properties", ex);
        }
    }

    processProperties(beanFactory, new PropertySourcesPropertyResolver(this.propertySources));
    this.appliedPropertySources = this.propertySources;
}
项目:my-spring-cache-redis    文件:PropertySourcesPlaceholderConfigurer.java   
/**
 * {@inheritDoc}
 * <p>Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
 * against this configurer's set of {@link PropertySources}, which includes:
 * <ul>
 * <li>all {@linkplain org.springframework.core.env.ConfigurableEnvironment#getPropertySources
 * environment property sources}, if an {@code Environment} {@linkplain #setEnvironment is present}
 * <li>{@linkplain #mergeProperties merged local properties}, if {@linkplain #setLocation any}
 * {@linkplain #setLocations have} {@linkplain #setProperties been}
 * {@linkplain #setPropertiesArray specified}
 * <li>any property sources set by calling {@link #setPropertySources}
 * </ul>
 * <p>If {@link #setPropertySources} is called, <strong>environment and local properties will be
 * ignored</strong>. This method is designed to give the user fine-grained control over property
 * sources, and once set, the configurer makes no assumptions about adding additional sources.
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
        this.propertySources = new MutablePropertySources();
        if (this.environment != null) {
            this.propertySources.addLast(
                new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
                    @Override
                    public String getProperty(String key) {
                        return this.source.getProperty(key);
                    }
                }
            );
        }
        try {
            PropertySource<?> localPropertySource =
                new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties());
            if (this.localOverride) {
                this.propertySources.addFirst(localPropertySource);
            }
            else {
                this.propertySources.addLast(localPropertySource);
            }
        }
        catch (IOException ex) {
            throw new BeanInitializationException("Could not load properties", ex);
        }
    }

    processProperties(beanFactory, new PropertySourcesPropertyResolver(this.propertySources));
    this.appliedPropertySources = this.propertySources;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBanner.java   
private PropertyResolver getTitleResolver(Class<?> sourceClass) {
    MutablePropertySources sources = new MutablePropertySources();
    String applicationTitle = getApplicationTitle(sourceClass);
    Map<String, Object> titleMap = Collections.<String, Object>singletonMap(
            "application.title", (applicationTitle == null ? "" : applicationTitle));
    sources.addFirst(new MapPropertySource("title", titleMap));
    return new PropertySourcesPropertyResolver(sources);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 * @param includes the property name patterns to include
 */
PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> nonEnumerableFallbackNames,
        PropertyNamePatternsMatcher includes) {
    Assert.notNull(propertySources, "PropertySources must not be null");
    Assert.notNull(includes, "Includes must not be null");
    this.propertySources = propertySources;
    this.nonEnumerableFallbackNames = nonEnumerableFallbackNames;
    this.includes = includes;
    PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
            propertySources);
    for (PropertySource<?> source : propertySources) {
        processPropertySource(source, resolver);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private void processPropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    if (source instanceof CompositePropertySource) {
        processCompositePropertySource((CompositePropertySource) source, resolver);
    }
    else if (source instanceof EnumerablePropertySource) {
        processEnumerablePropertySource((EnumerablePropertySource<?>) source,
                resolver, this.includes);
    }
    else {
        processNonEnumerablePropertySource(source, resolver);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private void processEnumerablePropertySource(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver,
        PropertyNamePatternsMatcher includes) {
    if (source.getPropertyNames().length > 0) {
        for (String propertyName : source.getPropertyNames()) {
            if (includes.matches(propertyName)) {
                Object value = getEnumerableProperty(source, resolver, propertyName);
                putIfAbsent(propertyName, value, source);
            }
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private Object getEnumerableProperty(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver, String propertyName) {
    try {
        return resolver.getProperty(propertyName, Object.class);
    }
    catch (RuntimeException ex) {
        // Probably could not resolve placeholders, ignore it here
        return source.getProperty(propertyName);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LogFileTests.java   
private PropertyResolver getPropertyResolver(String file, String path) {
    Map<String, Object> properties = new LinkedHashMap<String, Object>();
    properties.put("logging.file", file);
    properties.put("logging.path", path);
    PropertySource<?> propertySource = new MapPropertySource("properties",
            properties);
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addFirst(propertySource);
    return new PropertySourcesPropertyResolver(propertySources);
}
项目:spring    文件:PropertySourcesPlaceholderConfigurer.java   
/**
 * {@inheritDoc}
 * <p>Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
 * against this configurer's set of {@link PropertySources}, which includes:
 * <ul>
 * <li>all {@linkplain org.springframework.core.env.ConfigurableEnvironment#getPropertySources
 * environment property sources}, if an {@code Environment} {@linkplain #setEnvironment is present}
 * <li>{@linkplain #mergeProperties merged local properties}, if {@linkplain #setLocation any}
 * {@linkplain #setLocations have} {@linkplain #setProperties been}
 * {@linkplain #setPropertiesArray specified}
 * <li>any property sources set by calling {@link #setPropertySources}
 * </ul>
 * <p>If {@link #setPropertySources} is called, <strong>environment and local properties will be
 * ignored</strong>. This method is designed to give the user fine-grained control over property
 * sources, and once set, the configurer makes no assumptions about adding additional sources.
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
        this.propertySources = new MutablePropertySources();
        if (this.environment != null) {
            this.propertySources.addLast(
                new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
                    @Override
                    public String getProperty(String key) {
                        return this.source.getProperty(key);
                    }
                }
            );
        }
        try {
            PropertySource<?> localPropertySource =
                    new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties());
            if (this.localOverride) {
                this.propertySources.addFirst(localPropertySource);
            }
            else {
                this.propertySources.addLast(localPropertySource);
            }
        }
        catch (IOException ex) {
            throw new BeanInitializationException("Could not load properties", ex);
        }
    }

    processProperties(beanFactory, new PropertySourcesPropertyResolver(this.propertySources));
    this.appliedPropertySources = this.propertySources;
}
项目:java-platform    文件:ConfigurationPropertySourcesPlaceholderConfigurer.java   
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
        this.propertySources = new MutablePropertySources();
        if (this.environment != null) {
            this.propertySources.addLast(
                    new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
                        @Override
                        public String getProperty(String key) {
                            return this.source.getProperty(key);
                        }
                    });
        }
        PropertySource<?> localPropertySource = new PropertySource<Configuration>(
                PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, configuration) {
            @Override
            public Object getProperty(String name) {
                if (name != null && name.indexOf("?:") > 0) {
                    name = name.substring(0, name.indexOf("?:"));
                }
                return this.source.getProperty(name);
            }
        };
        propertySources.addFirst(localPropertySource);
    }

    processProperties(beanFactory, new PropertySourcesPropertyResolver(this.propertySources));
    this.appliedPropertySources = this.propertySources;
}
项目:spring-boot-concourse    文件:ResourceBanner.java   
private PropertyResolver getTitleResolver(Class<?> sourceClass) {
    MutablePropertySources sources = new MutablePropertySources();
    String applicationTitle = getApplicationTitle(sourceClass);
    Map<String, Object> titleMap = Collections.<String, Object>singletonMap(
            "application.title", (applicationTitle == null ? "" : applicationTitle));
    sources.addFirst(new MapPropertySource("title", titleMap));
    return new PropertySourcesPropertyResolver(sources);
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 * @param includes the property name patterns to include
 */
PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> nonEnumerableFallbackNames,
        PropertyNamePatternsMatcher includes) {
    Assert.notNull(propertySources, "PropertySources must not be null");
    Assert.notNull(includes, "Includes must not be null");
    this.propertySources = propertySources;
    this.nonEnumerableFallbackNames = nonEnumerableFallbackNames;
    this.includes = includes;
    PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
            propertySources);
    for (PropertySource<?> source : propertySources) {
        processPropertySource(source, resolver);
    }
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
private void processPropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    if (source instanceof CompositePropertySource) {
        processCompositePropertySource((CompositePropertySource) source, resolver);
    }
    else if (source instanceof EnumerablePropertySource) {
        processEnumerablePropertySource((EnumerablePropertySource<?>) source,
                resolver, this.includes);
    }
    else {
        processNonEnumerablePropertySource(source, resolver);
    }
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
private void processEnumerablePropertySource(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver,
        PropertyNamePatternsMatcher includes) {
    if (source.getPropertyNames().length > 0) {
        for (String propertyName : source.getPropertyNames()) {
            if (includes.matches(propertyName)) {
                Object value = getEnumerableProperty(source, resolver, propertyName);
                putIfAbsent(propertyName, value, source);
            }
        }
    }
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
private Object getEnumerableProperty(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver, String propertyName) {
    try {
        return resolver.getProperty(propertyName, Object.class);
    }
    catch (RuntimeException ex) {
        // Probably could not resolve placeholders, ignore it here
        return source.getProperty(propertyName);
    }
}
项目:spring-boot-concourse    文件:LogFileTests.java   
private PropertyResolver getPropertyResolver(String file, String path) {
    Map<String, Object> properties = new LinkedHashMap<String, Object>();
    properties.put("logging.file", file);
    properties.put("logging.path", path);
    PropertySource<?> propertySource = new MapPropertySource("properties",
            properties);
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addFirst(propertySource);
    return new PropertySourcesPropertyResolver(propertySources);
}
项目:director-aws-plugin    文件:PropertyResolvers.java   
/**
 * Creates a new property resolver that gets properties from the given map.
 *
 * @param m property map
 * @return new property resolver
 * @throws NullPointerException if the map is null
 */
public static PropertyResolver newMapPropertyResolver(Map<String, String> m) {
  checkNotNull(m, "map is null");
  MutablePropertySources sources = new MutablePropertySources();
  sources.addFirst(new MapPropertySource("map",
      ImmutableMap.<String, Object>copyOf(m)));
  return new PropertySourcesPropertyResolver(sources);
}
项目:trenurbanoapp    文件:ContextAttributesListener.java   
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
    ServletContext servletContext = contextEvent.getServletContext();
    WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    PropertySourcesPlaceholderConfigurer bean = webApplicationContext.getBean(PropertySourcesPlaceholderConfigurer.class);
    PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(bean.getAppliedPropertySources());
    servletContext.setAttribute("gps.enabled", Boolean.valueOf(resolver.resolvePlaceholders("${gps.enabled:false}")));
    servletContext.setAttribute("appCache.disabled", Boolean.valueOf(resolver.resolvePlaceholders("${appCache.disabled:false}")));
    servletContext.setAttribute("javascript.useSource", Boolean.valueOf(resolver.resolvePlaceholders("${javascript.useSource:false}")));
    servletContext.setAttribute("routeAlgorithm.useRoutes", Boolean.valueOf(resolver.resolvePlaceholders("${routeAlgorithm.useRoutes:false}")));
    servletContext.setAttribute("alert.message", resolver.resolvePlaceholders("${alert.message:}"));

    servletContext.setAttribute("app.name", resolver.resolvePlaceholders("${app.name:Tren Urbano App}"));
    servletContext.setAttribute("report.phone", resolver.resolvePlaceholders("${report.phone:311}"));
    servletContext.setAttribute("map.center.lat", resolver.resolvePlaceholders("${map.center.lat:18.430189}"));
    servletContext.setAttribute("map.center.lng", resolver.resolvePlaceholders("${map.center.lng:-66.060061}"));
    servletContext.setAttribute("map.bounds.southwest.lat", resolver.resolvePlaceholders("${map.bounds.southwest.lat:18.352687}"));
    servletContext.setAttribute("map.bounds.southwest.lng", resolver.resolvePlaceholders("${map.bounds.southwest.lng:-66.179752}"));
    servletContext.setAttribute("map.bounds.northeast.lat", resolver.resolvePlaceholders("${map.bounds.northeast.lat:18.477284}"));
    servletContext.setAttribute("map.bounds.northeast.lng", resolver.resolvePlaceholders("${map.bounds.northeast.lng:-65.928097}"));
    servletContext.setAttribute("links.ios", resolver.resolvePlaceholders("${links.ios:http://itunes.apple.com/us/app/tren-urbano-app/id484781635}"));
    servletContext.setAttribute("links.android", resolver.resolvePlaceholders("${links.android:https://market.android.com/details?id=com.trenurbanoapp}"));


    servletContext.setAttribute("logo.16", resolver.resolvePlaceholders("${logo.16:/images/trenurbano_icon16.png}"));
    servletContext.setAttribute("logo.48", resolver.resolvePlaceholders("${logo.48:/images/trenurbano_icon48.png}"));
    servletContext.setAttribute("logo.57", resolver.resolvePlaceholders("${logo.57:/images/trenurbano_icon57.png}"));

    servletContext.setAttribute("banner.231", resolver.resolvePlaceholders("${banner.231:/images/trenurbano_icon_banner231.png}"));
    servletContext.setAttribute("banner.468", resolver.resolvePlaceholders("${banner.468:/images/trenurbano_icon_banner468.png}"));

    servletContext.setAttribute("content.aboutus", resolver.resolvePlaceholders("${content.aboutus:/html/about_us.html}"));
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 * @param includes the property name patterns to include
 */
PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> nonEnumerableFallbackNames,
        PropertyNamePatternsMatcher includes) {
    Assert.notNull(propertySources, "PropertySources must not be null");
    Assert.notNull(includes, "Includes must not be null");
    this.propertySources = propertySources;
    this.nonEnumerableFallbackNames = nonEnumerableFallbackNames;
    this.includes = includes;
    PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
            propertySources);
    for (PropertySource<?> source : propertySources) {
        processPropertySource(source, resolver);
    }
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
private void processPropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    if (source instanceof CompositePropertySource) {
        processCompositePropertySource((CompositePropertySource) source, resolver);
    }
    else if (source instanceof EnumerablePropertySource) {
        processEnumerablePropertySource((EnumerablePropertySource<?>) source,
                resolver, this.includes);
    }
    else {
        processNonEnumerablePropertySource(source, resolver);
    }
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
private void processEnumerablePropertySource(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver,
        PropertyNamePatternsMatcher includes) {
    if (source.getPropertyNames().length > 0) {
        for (String propertyName : source.getPropertyNames()) {
            if (includes.matches(propertyName)) {
                Object value = getEnumerableProperty(source, resolver, propertyName);
                putIfAbsent(propertyName, value, source);
            }
        }
    }
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
private Object getEnumerableProperty(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver, String propertyName) {
    try {
        return resolver.getProperty(propertyName, Object.class);
    }
    catch (RuntimeException ex) {
        // Probably could not resolve placeholders, ignore it here
        return source.getProperty(propertyName);
    }
}
项目:contestparser    文件:LogFileTests.java   
private PropertyResolver getPropertyResolver(String file, String path) {
    Map<String, Object> properties = new LinkedHashMap<String, Object>();
    properties.put("logging.file", file);
    properties.put("logging.path", path);
    PropertySource<?> propertySource = new MapPropertySource("properties",
            properties);
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addFirst(propertySource);
    return new PropertySourcesPropertyResolver(propertySources);
}
项目:class-guard    文件:PropertySourcesPlaceholderConfigurer.java   
/**
 * {@inheritDoc}
 * <p>Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
 * against this configurer's set of {@link PropertySources}, which includes:
 * <ul>
 * <li>all {@linkplain org.springframework.core.env.ConfigurableEnvironment#getPropertySources
 * environment property sources}, if an {@code Environment} {@linkplain #setEnvironment is present}
 * <li>{@linkplain #mergeProperties merged local properties}, if {@linkplain #setLocation any}
 * {@linkplain #setLocations have} {@linkplain #setProperties been}
 * {@linkplain #setPropertiesArray specified}
 * <li>any property sources set by calling {@link #setPropertySources}
 * </ul>
 * <p>If {@link #setPropertySources} is called, <strong>environment and local properties will be
 * ignored</strong>. This method is designed to give the user fine-grained control over property
 * sources, and once set, the configurer makes no assumptions about adding additional sources.
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertySources == null) {
        this.propertySources = new MutablePropertySources();
        if (this.environment != null) {
            this.propertySources.addLast(
                new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
                    @Override
                    public String getProperty(String key) {
                        return this.source.getProperty(key);
                    }
                }
            );
        }
        try {
            PropertySource<?> localPropertySource =
                new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties());
            if (this.localOverride) {
                this.propertySources.addFirst(localPropertySource);
            }
            else {
                this.propertySources.addLast(localPropertySource);
            }
        }
        catch (IOException ex) {
            throw new BeanInitializationException("Could not load properties", ex);
        }
    }

    processProperties(beanFactory, new PropertySourcesPropertyResolver(this.propertySources));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DefaultLogbackConfiguration.java   
private PropertyResolver getPatternsResolver(Environment environment) {
    if (environment == null) {
        return new PropertySourcesPropertyResolver(null);
    }
    return new RelaxedPropertyResolver(environment, "logging.pattern.");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBanner.java   
private PropertyResolver getVersionResolver(Class<?> sourceClass) {
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources
            .addLast(new MapPropertySource("version", getVersionsMap(sourceClass)));
    return new PropertySourcesPropertyResolver(propertySources);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBanner.java   
private PropertyResolver getAnsiResolver() {
    MutablePropertySources sources = new MutablePropertySources();
    sources.addFirst(new AnsiPropertySource("ansi", true));
    return new PropertySourcesPropertyResolver(sources);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private void processCompositePropertySource(CompositePropertySource source,
        PropertySourcesPropertyResolver resolver) {
    for (PropertySource<?> nested : source.getPropertySources()) {
        processPropertySource(nested, resolver);
    }
}
项目:elastic-jobx    文件:PlaceholderResolved.java   
private PropertySourcesPropertyResolver getPropertyResolverBeforeSpring4(final PropertySourcesPlaceholderConfigurer placeholderConfigurer) 
        throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    Field field = placeholderConfigurer.getClass().getDeclaredField("propertySources");
    field.setAccessible(true);
    return new PropertySourcesPropertyResolver((PropertySources) field.get(placeholderConfigurer));
}
项目:ElasticJob    文件:PlaceholderResolved.java   
private PropertySourcesPropertyResolver getPropertyResolverBeforeSpring4(final PropertySourcesPlaceholderConfigurer placeholderConfigurer) throws ReflectiveOperationException {
    return new PropertySourcesPropertyResolver((PropertySources) PropertySourcesPlaceholderConfigurer.class.getField("propertySources").get(placeholderConfigurer));
}
项目:spring-boot-concourse    文件:DefaultLogbackConfiguration.java   
private PropertyResolver getPatternsResolver(Environment environment) {
    if (environment == null) {
        return new PropertySourcesPropertyResolver(null);
    }
    return new RelaxedPropertyResolver(environment, "logging.pattern.");
}
项目:spring-boot-concourse    文件:ResourceBanner.java   
private PropertyResolver getVersionResolver(Class<?> sourceClass) {
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources
            .addLast(new MapPropertySource("version", getVersionsMap(sourceClass)));
    return new PropertySourcesPropertyResolver(propertySources);
}