热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.springframework.core.env.MapPropertySource.getSource()方法的使用及代码示例

本文整理了Java中org.springframework.core.env.MapPropertySource.getSource()方法的一些代码示例,展示了

本文整理了Java中org.springframework.core.env.MapPropertySource.getSource()方法的一些代码示例,展示了MapPropertySource.getSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MapPropertySource.getSource()方法的具体详情如下:
包路径:org.springframework.core.env.MapPropertySource
类名称:MapPropertySource
方法名:getSource

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 s1 = mp1.getSource();
Map s2 = mp2.getSource();
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 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 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 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 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 s1 = mp1.getSource();
Map s2 = mp2.getSource();
return s1 == null ? s2 != null : !s1.equals(s2);
}

代码示例来源:origin: Teradata/kylo

/**
* get All properties
*/
public Map getAllProperties() {
if (properties == null || properties.isEmpty()) {
synchronized (SpringEnvironmentProperties.class) {
if (properties == null || properties.isEmpty()) {
Map map = new HashMap();
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 decryptedMap = new HashMap();
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 targetMap = ((MapPropertySource) target)
.getSource();
if (target != source) {
if (source instanceof MapPropertySource) {
Map map = ((MapPropertySource) source)
.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 s1 = mp1.getSource();
Map s2 = mp2.getSource();
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 s1 = mp1.getSource();
Map s2 = mp2.getSource();
return s1 == null ? s2 != null : !s1.equals(s2);
}

代码示例来源:origin: com.atlassian.connect/ac-spring-boot-autoconfigure

@Override
public Set getDescriptors() {
final ImmutableSet.Builder builder = ImmutableSet.builder();
builder.add(new HostNameScopeDescriptor());
for (final PropertySource propertySource : env.getPropertySources()) {
if (propertySource instanceof MapPropertySource) {
final Map source = ((MapPropertySource) propertySource).getSource();
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 source = ((MapPropertySource) propertySources
.get(STUBRUNNER_PREFIX)).getSource();
for (Map.Entry entry : runStubs.validNamesAndPorts()
.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 map = null;
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);
}
}
}

推荐阅读
author-avatar
小彩菜
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有