List of usage examples for org.springframework.core.env MutablePropertySources MutablePropertySources
public MutablePropertySources()
From source file:com.dangdang.config.service.support.spring.ConfigGroupSourceFactory.java
public static PropertySources create(ConfigGroup... configGroups) { Preconditions.checkNotNull(configGroups); final MutablePropertySources sources = new MutablePropertySources(); for (ConfigGroup configGroup : configGroups) { sources.addLast(new ConfigGroupResource(configGroup)); }/*w ww . jav a 2 s . co m*/ return sources; }
From source file:com.dangdang.config.service.easyzk.support.spring.ZookeeperSourceFactory.java
public static PropertySources create(ConfigGroup... configGroups) { Preconditions.checkNotNull(configGroups); final MutablePropertySources sources = new MutablePropertySources(); for (ConfigGroup configGroup : configGroups) { sources.addLast(new ZookeeperResource(configGroup)); }// ww w . j av a 2 s . c o m return sources; }
From source file:com.cloudera.director.aws.common.PropertyResolvers.java
/** * Creates a new property resolver with no properties. * * @return new property resolver//from w w w. ja va2 s. co m */ public static PropertyResolver newEmptyPropertyResolver() { return new PropertySourcesPropertyResolver(new MutablePropertySources()); }
From source file:com.cloudera.director.aws.common.PropertyResolvers.java
/** * Creates a new property resolver that gets properties from the given map. * * @param m property map//from w ww . j a va 2 s . com * @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); }
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 w w . j a va 2 s . co m return config; }
From source file:org.greencheek.utils.environment.propertyplaceholder.spring.EnvironmentalPropertySourcesPlaceholderConfigurerWithSpringValueResolution.java
@Override public void afterPropertiesSet() { if (mergerBuilder == null) { throw new IllegalStateException("The PropertyMergerBuilder must not be null."); }/*w w w . j a v a 2 s .c om*/ Properties p = mergerBuilder.build().getMergedProperties(); StandardEnvironment env = new StandardEnvironment(); MutablePropertySources sources = new MutablePropertySources(); if (isSystemPropertiesResolutionEnabled()) sources.addLast(new MapPropertySource(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, env.getSystemProperties())); if (isEnvironmentPropertiesResolutionEnabled()) sources.addLast(new SystemEnvironmentPropertySource( StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, env.getSystemEnvironment())); sources.addFirst(new PropertiesPropertySource(ENVIRONMENT_SPECIFIC_PROPERTIES, p)); super.setPropertySources(sources); }
From source file:com.cloudera.director.aws.common.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./*from www.j a v a 2 s.c o m*/ * * @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); }
From source file:com.careerly.common.support.ReloadablePropertySourcesPlaceholderConfigurer.java
private void reload() throws IOException { logger.info("properties changed, reloading.."); // Properties? Properties properties = super.mergeProperties(); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addLast(new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, properties)); ConfigurablePropertyResolver propertyResolver = new PropertySourcesPropertyResolver(propertySources); // BeanFactory??removeEmbeddedValueResolver??Resolver? valueResolver.expire();/*from w w w . j av a2s . com*/ valueResolver = new PropertyStringValueResolver(propertyResolver); beanFactory.addEmbeddedValueResolver(valueResolver); // ?? for (String beanName : beanNames) { Object bean = beanFactory.getBean(beanName); autowiredAnnotationBeanPostProcessor.processInjection(bean); } }
From source file:com.alibaba.dubbo.config.spring.context.annotation.DubboConfigBindingRegistrar.java
private MutablePropertyValues resolveBeanPropertyValues(String beanName, boolean multiple, Map<String, String> properties) { MutablePropertyValues propertyValues = new MutablePropertyValues(); if (multiple) { // For Multiple Beans MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MapPropertySource(beanName, new TreeMap<String, Object>(properties))); Map<String, String> subProperties = getSubProperties(propertySources, beanName); propertyValues.addPropertyValues(subProperties); } else { // For Single Bean for (Map.Entry<String, String> entry : properties.entrySet()) { String propertyName = entry.getKey(); if (!propertyName.contains(".")) { // ignore property name with "." propertyValues.addPropertyValue(propertyName, entry.getValue()); }//from w ww . j av a2 s.c o m } } return propertyValues; }
From source file:com.textocat.textokit.eval.matching.MatchingConfigurationInitializerTest.java
private PropertyResolver makePropertyResolver(Map<String, Object> properties) { MutablePropertySources propSources = new MutablePropertySources(); propSources.addFirst(new MapPropertySource("default", properties)); PropertyResolver result = new PropertySourcesPropertyResolver(propSources); return result; }