本文整理了Java中org.springframework.core.env.MapPropertySource.getSource()
方法的一些代码示例,展示了MapPropertySource.getSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MapPropertySource.getSource()
方法的具体详情如下:
包路径:org.springframework.core.env.MapPropertySource
类名称:MapPropertySource
方法名:getSource
暂无
代码示例来源:origin: spring-cloud/spring-cloud-kubernetes
/**
* Determines if two property sources are different.
*/
protected boolean changed(MapPropertySource mp1, MapPropertySource mp2) {
if (mp1 == mp2)
return false;
if (mp1 == null && mp2 != null || mp1 != null && mp2 == null)
return true;
Map
Map
return s1 == null ? s2 != null : !s1.equals(s2);
}
代码示例来源:origin: spring-projects/spring-framework
environment.getPropertySources().addFirst(ps);
ps.getSource().putAll(convertInlinedPropertiesToMap(inlinedProperties));
代码示例来源:origin: org.springframework.boot/spring-boot
private void assertEnumerablePropertySource() {
if (getPropertySource() instanceof MapPropertySource) {
try {
((MapPropertySource) getPropertySource()).getSource().size();
}
catch (UnsupportedOperationException ex) {
throw new IllegalArgumentException(
"PropertySource must be fully enumerable");
}
}
}
代码示例来源:origin: org.springframework.boot/spring-boot
public static CacheKey get(EnumerablePropertySource> source) {
if (source instanceof MapPropertySource) {
return new CacheKey(((MapPropertySource) source).getSource().keySet());
}
return new CacheKey(source.getPropertyNames());
}
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
/**
* Copy from {@link BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)}
*
* @param propertySources {@link MutablePropertySources}
* @param map Default RocketMQ Bus Properties
*/
private void addOrReplace(MutablePropertySources propertySources,
Map
MapPropertySource target = null;
if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
PropertySource> source = propertySources.get(PROPERTY_SOURCE_NAME);
if (source instanceof MapPropertySource) {
target = (MapPropertySource) source;
for (String key : map.keySet()) {
if (!target.containsProperty(key)) {
target.getSource().put(key, map.get(key));
}
}
}
}
if (target == null) {
target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
}
if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
propertySources.addLast(target);
}
}
代码示例来源:origin: apache/incubator-dubbo-spring-boot-project
/**
* Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)
*
* @param propertySources {@link MutablePropertySources}
* @param map Default Dubbo Properties
*/
private void addOrReplace(MutablePropertySources propertySources,
Map
MapPropertySource target = null;
if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
PropertySource> source = propertySources.get(PROPERTY_SOURCE_NAME);
if (source instanceof MapPropertySource) {
target = (MapPropertySource) source;
for (String key : map.keySet()) {
if (!target.containsProperty(key)) {
target.getSource().put(key, map.get(key));
}
}
}
}
if (target == null) {
target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
}
if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
propertySources.addLast(target);
}
}
}
代码示例来源:origin: spring-io/initializr
private static void addOrReplace(MutablePropertySources propertySources,
Map
MapPropertySource target = null;
if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
PropertySource> source = propertySources.get(PROPERTY_SOURCE_NAME);
if (source instanceof MapPropertySource) {
target = (MapPropertySource) source;
for (String key : map.keySet()) {
if (!target.containsProperty(key)) {
target.getSource().put(key, map.get(key));
}
}
}
}
if (target == null) {
target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
}
if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
propertySources.addLast(target);
}
}
代码示例来源:origin: spring-cloud/spring-cloud-sleuth
private void addOrReplace(MutablePropertySources propertySources,
Map
MapPropertySource target = null;
if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
PropertySource> source = propertySources.get(PROPERTY_SOURCE_NAME);
if (source instanceof MapPropertySource) {
target = (MapPropertySource) source;
for (String key : map.keySet()) {
if (!target.containsProperty(key)) {
target.getSource().put(key, map.get(key));
}
}
}
}
if (target == null) {
target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
}
if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
propertySources.addLast(target);
}
}
代码示例来源:origin: fabric8io/spring-cloud-kubernetes
/**
* Determines if two property sources are different.
*/
protected boolean changed(MapPropertySource mp1, MapPropertySource mp2) {
if (mp1 == mp2) return false;
if (mp1 == null && mp2 != null || mp1 != null && mp2 == null) return true;
Map
Map
return s1 == null ? s2 != null : !s1.equals(s2);
}
代码示例来源:origin: Teradata/kylo
/**
* get All properties
*/
public Map
if (properties == null || properties.isEmpty()) {
synchronized (SpringEnvironmentProperties.class) {
if (properties == null || properties.isEmpty()) {
Map
for (Iterator it = ((AbstractEnvironment) env).getPropertySources().iterator(); it.hasNext(); ) {
PropertySource propertySource = (PropertySource) it.next();
if (propertySource instanceof MapPropertySource) {
map.putAll(((MapPropertySource) propertySource).getSource());
}
}
//decrypt
Map
for (String k : map.keySet()) {
decryptedMap.put(k, env.getProperty(k));
}
properties = decryptedMap;
}
}
}
return properties;
}
代码示例来源:origin: ulisesbocchio/jasypt-spring-boot
public EncryptableMapPropertySourceWrapper(MapPropertySource delegate, EncryptablePropertyResolver resolver, EncryptablePropertyFilter filter) {
super(delegate.getName(), delegate.getSource());
encryptableDelegate = new CachingDelegateEncryptablePropertySource<>(delegate, resolver, filter);
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-context
private void mergeDefaultProperties(MutablePropertySources environment,
MutablePropertySources bootstrap) {
String name = DEFAULT_PROPERTIES;
if (bootstrap.contains(name)) {
PropertySource> source = bootstrap.get(name);
if (!environment.contains(name)) {
environment.addLast(source);
}
else {
PropertySource> target = environment.get(name);
if (target instanceof MapPropertySource) {
Map
.getSource();
if (target != source) {
if (source instanceof MapPropertySource) {
Map
.getSource();
for (String key : map.keySet()) {
if (!target.containsProperty(key)) {
targetMap.put(key, map.get(key));
}
}
}
}
}
}
}
mergeAdditionalPropertySources(environment, bootstrap);
}
代码示例来源:origin: io.fabric8/spring-cloud-kubernetes-core
/**
* Determines if two property sources are different.
*/
protected boolean changed(MapPropertySource mp1, MapPropertySource mp2) {
if (mp1 == mp2) return false;
if (mp1 == null && mp2 != null || mp1 != null && mp2 == null) return true;
Map
Map
return s1 == null ? s2 != null : !s1.equals(s2);
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-kubernetes-config
/**
* Determines if two property sources are different.
*/
protected boolean changed(MapPropertySource mp1, MapPropertySource mp2) {
if (mp1 == mp2)
return false;
if (mp1 == null && mp2 != null || mp1 != null && mp2 == null)
return true;
Map
Map
return s1 == null ? s2 != null : !s1.equals(s2);
}
代码示例来源:origin: com.atlassian.connect/ac-spring-boot-autoconfigure
@Override
public Set
final ImmutableSet.Builder
builder.add(new HostNameScopeDescriptor());
for (final PropertySource> propertySource : env.getPropertySources()) {
if (propertySource instanceof MapPropertySource) {
final Map
for (Map.Entry entry : source.entrySet()) {
builder.add(new StaticDescriptorScope(entry.getKey().toString(), entry.getValue()));
}
}
}
return builder.build();
}
}
代码示例来源:origin: com.alipay.sofa/infra-sofa-boot-starter
/**
* config log settings
*/
private void assemblyLogSetting(ConfigurableEnvironment environment) {
StreamSupport.stream(environment.getPropertySources().spliterator(), false)
.filter(propertySource -> propertySource instanceof EnumerablePropertySource)
.map(propertySource -> Arrays
.asList(((MapPropertySource) propertySource).getPropertyNames()))
.flatMap(Collection::stream).filter(LogEnvUtils::filterAllLogConfig)
.forEach((key) -> HIGH_PRIORITY_CONFIG.getSource().put(key, environment.getProperty(key)));
}
代码示例来源:origin: com.alipay.sofa/infra-sofa-boot-starter
/**
* config required properties
* @param environment
*/
private void assemblyRequireProperties(ConfigurableEnvironment environment) {
if (StringUtils.hasText(environment.getProperty(SofaBootInfraConstants.APP_NAME_KEY))) {
HIGH_PRIORITY_CONFIG.getSource().put(SofaBootInfraConstants.APP_NAME_KEY,
environment.getProperty(SofaBootInfraConstants.APP_NAME_KEY));
}
}
代码示例来源:origin: com.github.ulisesbocchio/jasypt-spring-boot
public EncryptableMapPropertySourceWrapper(MapPropertySource delegate, EncryptablePropertyResolver resolver, EncryptablePropertyFilter filter) {
super(delegate.getName(), delegate.getSource());
encryptableDelegate = new CachingDelegateEncryptablePropertySource<>(delegate, resolver, filter);
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-contract-stub-runner
private void registerPort(RunningStubs runStubs) {
MutablePropertySources propertySources = this.environment.getPropertySources();
if (!propertySources.contains(STUBRUNNER_PREFIX)) {
propertySources.addFirst(new MapPropertySource(STUBRUNNER_PREFIX,
new HashMap
}
Map
.get(STUBRUNNER_PREFIX)).getSource();
for (Map.Entry
.entrySet()) {
source.put(STUBRUNNER_PREFIX + "." + entry.getKey().getArtifactId() + ".port",
entry.getValue());
// there are projects where artifact id is the same, what differs is the group
// id
source.put(STUBRUNNER_PREFIX + "." + entry.getKey().getGroupId() + "."
+ entry.getKey().getArtifactId() + ".port", entry.getValue());
}
}
代码示例来源:origin: io.micrometer/micrometer-spring-legacy
private void addDefaultProperty(ConfigurableEnvironment environment, String name,
String value) {
MutablePropertySources sources = environment.getPropertySources();
Map
if (sources.contains("defaultProperties")) {
PropertySource> source = sources.get("defaultProperties");
if (source instanceof MapPropertySource) {
map = ((MapPropertySource) source).getSource();
}
} else {
map = new LinkedHashMap<>();
sources.addLast(new MapPropertySource("defaultProperties", map));
}
if (map != null) {
map.put(name, value);
}
}
}