當前位置: 首頁>>代碼示例>>Java>>正文


Java MutablePropertySources.addBefore方法代碼示例

本文整理匯總了Java中org.springframework.core.env.MutablePropertySources.addBefore方法的典型用法代碼示例。如果您正苦於以下問題:Java MutablePropertySources.addBefore方法的具體用法?Java MutablePropertySources.addBefore怎麽用?Java MutablePropertySources.addBefore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.core.env.MutablePropertySources的用法示例。


在下文中一共展示了MutablePropertySources.addBefore方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addPropertySource

import org.springframework.core.env.MutablePropertySources; //導入方法依賴的package包/類
private void addPropertySource(ResourcePropertySource propertySource) {
	String name = propertySource.getName();
	MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment).getPropertySources();
	if (propertySources.contains(name) && this.propertySourceNames.contains(name)) {
		// We've already added a version, we need to extend it
		PropertySource<?> existing = propertySources.get(name);
		if (existing instanceof CompositePropertySource) {
			((CompositePropertySource) existing).addFirstPropertySource(propertySource.withResourceName());
		}
		else {
			if (existing instanceof ResourcePropertySource) {
				existing = ((ResourcePropertySource) existing).withResourceName();
			}
			CompositePropertySource composite = new CompositePropertySource(name);
			composite.addPropertySource(propertySource.withResourceName());
			composite.addPropertySource(existing);
			propertySources.replace(name, composite);
		}
	}
	else {
		if (this.propertySourceNames.isEmpty()) {
			propertySources.addLast(propertySource);
		}
		else {
			String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size() - 1);
			propertySources.addBefore(firstProcessed, propertySource);
		}
	}
	this.propertySourceNames.add(name);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:31,代碼來源:ConfigurationClassParser.java

示例2: addJsonPropertySource

import org.springframework.core.env.MutablePropertySources; //導入方法依賴的package包/類
private void addJsonPropertySource(ConfigurableEnvironment environment,
		PropertySource<?> source) {
	MutablePropertySources sources = environment.getPropertySources();
	String name = findPropertySource(sources);
	if (sources.contains(name)) {
		sources.addBefore(name, source);
	}
	else {
		sources.addFirst(source);
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:SpringApplicationJsonEnvironmentPostProcessor.java

示例3: addConfigurationProperties

import org.springframework.core.env.MutablePropertySources; //導入方法依賴的package包/類
private void addConfigurationProperties(
		ConfigurationPropertySources configurationSources) {
	MutablePropertySources existingSources = this.environment
			.getPropertySources();
	if (existingSources.contains(DEFAULT_PROPERTIES)) {
		existingSources.addBefore(DEFAULT_PROPERTIES, configurationSources);
	}
	else {
		existingSources.addLast(configurationSources);
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:ConfigFileApplicationListener.java

示例4: addPropertySource

import org.springframework.core.env.MutablePropertySources; //導入方法依賴的package包/類
private void addPropertySource(PropertySource<?> propertySource) {
	String name = propertySource.getName();
	MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment).getPropertySources();
	if (propertySources.contains(name) && this.propertySourceNames.contains(name)) {
		// We've already added a version, we need to extend it
		PropertySource<?> existing = propertySources.get(name);
		PropertySource<?> newSource = (propertySource instanceof ResourcePropertySource ?
				((ResourcePropertySource) propertySource).withResourceName() : propertySource);
		if (existing instanceof CompositePropertySource) {
			((CompositePropertySource) existing).addFirstPropertySource(newSource);
		}
		else {
			if (existing instanceof ResourcePropertySource) {
				existing = ((ResourcePropertySource) existing).withResourceName();
			}
			CompositePropertySource composite = new CompositePropertySource(name);
			composite.addPropertySource(newSource);
			composite.addPropertySource(existing);
			propertySources.replace(name, composite);
		}
	}
	else {
		if (this.propertySourceNames.isEmpty()) {
			propertySources.addLast(propertySource);
		}
		else {
			String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size() - 1);
			propertySources.addBefore(firstProcessed, propertySource);
		}
	}
	this.propertySourceNames.add(name);
}
 
開發者ID:txazo,項目名稱:spring,代碼行數:33,代碼來源:ConfigurationClassParser.java


注:本文中的org.springframework.core.env.MutablePropertySources.addBefore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。