本文整理匯總了Java中org.springframework.core.env.PropertySource.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java PropertySource.getProperty方法的具體用法?Java PropertySource.getProperty怎麽用?Java PropertySource.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.core.env.PropertySource
的用法示例。
在下文中一共展示了PropertySource.getProperty方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.springframework.core.env.PropertySource; //導入方法依賴的package包/類
@Override
public void run(String... args) throws Exception {
StringBuilder sb = new StringBuilder();
for (String option : args) {
sb.append(" ").append(option);
}
sb = sb.length() == 0 ? sb.append("No Options Specified") : sb;
logger.info(String.format("App launched with following arguments: %s", sb.toString()));
PropertySource<?> ps = new SimpleCommandLinePropertySource(args);
String appUrl = (String) ps.getProperty("appurl");
if (appUrl != null)
logger.info(String.format("Command-line appurl is %s", appUrl));
String applicationPropertyUrl = environment.getProperty("spring.application.url");
logger.info(String.format("Current Spring Social ApplicationUrl is %s", applicationPropertyUrl));
String applicationVersion = environment.getProperty("nixmash.blog.mvc.version");
logger.info(String.format("NixMash MVC Application Version: %s", applicationVersion));
}
示例2: processNonEnumerablePropertySource
import org.springframework.core.env.PropertySource; //導入方法依賴的package包/類
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);
}
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:25,代碼來源:PropertySourcesPropertyValues.java
示例3: doReIndex
import org.springframework.core.env.PropertySource; //導入方法依賴的package包/類
private static boolean doReIndex(String[] args) {
PropertySource ps = new SimpleCommandLinePropertySource(args);
if (ps.getProperty("reindex") == null)
return false;
else
return Boolean.valueOf(ps.getProperty("reindex").toString());
}
示例4: getAllProperties
import org.springframework.core.env.PropertySource; //導入方法依賴的package包/類
public static Map<String, Object> getAllProperties(String prefix){
init();
if(environment == null)return null;
MutablePropertySources propertySources = ((ConfigurableEnvironment)environment).getPropertySources();
Map<String, Object> properties = new LinkedHashMap<String, Object>();
for (PropertySource<?> source : propertySources) {
if(source.getName().startsWith("servlet") || source.getName().startsWith("system")){
continue;
}
if (source instanceof EnumerablePropertySource) {
for (String name : ((EnumerablePropertySource<?>) source) .getPropertyNames()) {
boolean match = StringUtils.isEmpty(prefix);
if(!match){
match = name.startsWith(prefix);
}
if(match){
Object value = source.getProperty(name);
if(value != null){
properties.put(name, value);
}
}
}
}
}
return Collections.unmodifiableMap(properties);
}
示例5: getProperty
import org.springframework.core.env.PropertySource; //導入方法依賴的package包/類
@Override
public Object getProperty(String name) {
for (PropertySource<?> propertySource : getSource()) {
Object value = propertySource.getProperty(name);
if (value != null) {
return value;
}
}
return null;
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:EnumerableCompositePropertySource.java
示例6: getProperty
import org.springframework.core.env.PropertySource; //導入方法依賴的package包/類
@Override
public Object getProperty(String name) {
for (PropertySource<?> propertySource : this.sources) {
Object value = propertySource.getProperty(name);
if (value != null) {
return value;
}
}
return null;
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:ConfigFileApplicationListener.java
示例7: getPropertyValue
import org.springframework.core.env.PropertySource; //導入方法依賴的package包/類
@Override
public PropertyValue getPropertyValue(String propertyName) {
PropertyValue propertyValue = this.propertyValues.get(propertyName);
if (propertyValue != null) {
return propertyValue;
}
for (PropertySource<?> source : this.propertySources) {
Object value = source.getProperty(propertyName);
propertyValue = putIfAbsent(propertyName, value, source);
if (propertyValue != null) {
return propertyValue;
}
}
return null;
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:16,代碼來源:PropertySourcesPropertyValues.java