当前位置: 首页>>代码示例>>Java>>正文


Java PropertySource.getProperty方法代码示例

本文整理汇总了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));

}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:24,代码来源:MvcLoader.java

示例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());
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:8,代码来源:SolrLauncher.java

示例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);
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:28,代码来源:EnvironmentHelper.java

示例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


注:本文中的org.springframework.core.env.PropertySource.getProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。