本文整理汇总了Java中org.springframework.core.env.PropertyResolver.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyResolver.getProperty方法的具体用法?Java PropertyResolver.getProperty怎么用?Java PropertyResolver.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.env.PropertyResolver
的用法示例。
在下文中一共展示了PropertyResolver.getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTemplateAvailable
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment,
ClassLoader classLoader, ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
"spring.velocity.");
String loaderPath = resolver.getProperty("resource-loader-path",
VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
String prefix = resolver.getProperty("prefix",
VelocityProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix",
VelocityProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(loaderPath + prefix + view + suffix)
.exists();
}
return false;
}
示例2: RedisDatastore
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
public RedisDatastore(MappingContext mappingContext, PropertyResolver configuration,
ConfigurableApplicationContext ctx) {
super(mappingContext, configuration, ctx);
int resourceCount = 10;
if (configuration != null) {
host = configuration.getProperty(CONFIG_HOST, DEFAULT_HOST);
port = configuration.getProperty(CONFIG_PORT, Integer.class, DEFAULT_PORT);
timeout = configuration.getProperty(CONFIG_TIMEOUT, Integer.class, 2000);
pooled = configuration.getProperty(CONFIG_POOLED, Boolean.class, true);
password = configuration.getProperty(CONFIG_PASSWORD, (String)null);
resourceCount = configuration.getProperty(CONFIG_RESOURCE_COUNT, Integer.class, resourceCount);
}
if (pooled && useJedis()) {
this.pool = JedisTemplateFactory.createPool(host, port, timeout, resourceCount, password);
}
initializeConverters(mappingContext);
}
示例3: isTemplateAvailable
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment,
ClassLoader classLoader, ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
"spring.velocity.");
String loaderPath = resolver.getProperty("resource-loader-path",
VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
String prefix = resolver.getProperty("prefix",
VelocityProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix",
VelocityProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(loaderPath + prefix + view + suffix)
.exists();
}
return false;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:VelocityTemplateAvailabilityProvider.java
示例4: getDefaultInstanceId
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
public static String getDefaultInstanceId(PropertyResolver resolver, boolean includeHostname) {
String vcapInstanceId = resolver.getProperty("vcap.application.instance_id");
if (StringUtils.hasText(vcapInstanceId)) {
return vcapInstanceId;
}
String hostname = null;
if (includeHostname) {
hostname = resolver.getProperty("spring.cloud.client.hostname");
}
String appName = resolver.getProperty("spring.application.name");
String namePart = combineParts(hostname, SEPARATOR, appName);
String indexPart = resolver.getProperty("spring.application.instance_id",
resolver.getProperty("server.port"));
return combineParts(namePart, SEPARATOR, indexPart);
}
示例5: newShortLinkRepository
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
public static final ShortLinkRepository newShortLinkRepository(PropertyResolver props) throws PropertyException {
final String repoType;
boolean enabled;
enabled = props.getProperty("shortlink.enabled", Boolean.class, true);
if(!enabled) {
log.info("Shortlinking disabled in config");
return new NoOpRepository();
}
repoType = props.getProperty("shortlink.backend", String.class, "HDFS");
if ("HDFS".equals(repoType)) {
return new HDFSShortLinkRepository(props);
}
if ("S3".equals(repoType)) {
return new S3ShortLinkRepository(props);
}
throw new PropertyException("Unknown cache type (property: shortlink.backend): "
+ repoType);
}
示例6: HDFSShortLinkRepository
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
public HDFSShortLinkRepository(final PropertyResolver props) {
enabled = true;
try {
kerberosLogin(props);
linkPath = new Path(props.getProperty("shortlink.hdfs.path", String.class));
hdfs = linkPath.getFileSystem(new Configuration());
log.info("Short linking will use HDFS path: " + linkPath);
worldWritable = props.getProperty("shortlink.hdfs.worldwritable", Boolean.class, true);
if(!hdfs.exists(linkPath)) {
hdfs.mkdirs(linkPath);
if(worldWritable) {
hdfs.setPermission(linkPath, FsPermission.valueOf("-rwxrwxrwx"));
}
}
log.info("HDFSShortLinkRepository initialized");
} catch (Exception e) {
log.info("Failed to initialize the HDFS client. Shortlinking disabled.", e);
enabled = false;
}
}
示例7: newQueryCache
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
public static final QueryCache newQueryCache(PropertyResolver props) throws PropertyException {
final String cacheType;
boolean enabled;
enabled = props.getProperty("query.cache.enabled", Boolean.class, true);
if(!enabled) {
log.info("Query caching disabled in config");
return new NoOpQueryCache();
}
cacheType = props.getProperty("query.cache.backend", String.class, "HDFS");
if ("HDFS".equals(cacheType)) {
return new HDFSQueryCache(props);
}
if ("S3".equals(cacheType)) {
return new S3QueryCache(props);
}
throw new PropertyException("Unknown cache type (property: query.cache.backend): "
+ cacheType);
}
示例8: HDFSQueryCache
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
public HDFSQueryCache(PropertyResolver props) {
enabled = true;
try {
kerberosLogin(props);
cachePath = new Path(props.getProperty("query.cache.hdfs.path"));
hdfs = cachePath.getFileSystem(new org.apache.hadoop.conf.Configuration());
cacheDirWorldWritable = props.getProperty("query.cache.worldwritable", Boolean.class);
makeSurePathExists(cachePath);
} catch (Exception e) {
log.info("Failed to initialize the HDFS query cache. Caching disabled.", e);
enabled = false;
}
}
示例9: isTemplateAvailable
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("org.thymeleaf.spring4.SpringTemplateEngine", classLoader)
&& ClassUtils.isPresent("org.thymeleaf.Thymeleaf", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.thymeleaf3.");
String prefix = resolver.getProperty("prefix", DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix", DEFAULT_SUFFIX);
return resourceLoader.getResource(prefix + view + suffix).exists();
}
return false;
}
开发者ID:bobxwang,项目名称:springboot-scala-withswagger,代码行数:14,代码来源:Thymeleaf3TemplateAvailabilityProvider.java
示例10: isTemplateAvailable
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("com.mitchellbosecke.pebble.PebbleEngine", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment, "pebble.");
String prefix = resolver.getProperty("prefix", PebbleProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix", PebbleProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(ResourceLoader.CLASSPATH_URL_PREFIX + prefix + view + suffix).exists();
} else {
return false;
}
}
开发者ID:PebbleTemplates,项目名称:pebble-spring-boot-starter,代码行数:13,代码来源:PebbleTemplateAvailabilityProvider.java
示例11: get
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
/**
* Get a {@link LogFile} from the given Spring {@link Environment}.
* @param propertyResolver the {@link PropertyResolver} used to obtain the logging
* properties
* @return a {@link LogFile} or {@code null} if the environment didn't contain any
* suitable properties
*/
public static LogFile get(PropertyResolver propertyResolver) {
String file = propertyResolver.getProperty(FILE_PROPERTY);
String path = propertyResolver.getProperty(PATH_PROPERTY);
if (StringUtils.hasLength(file) || StringUtils.hasLength(path)) {
return new LogFile(file, path);
}
return null;
}
示例12: printBanner
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
private void printBanner(Environment environment, PrintStream out)
throws IOException {
PropertyResolver properties = new RelaxedPropertyResolver(environment,
"banner.image.");
int width = properties.getProperty("width", Integer.class, 76);
int height = properties.getProperty("height", Integer.class, 0);
int margin = properties.getProperty("margin", Integer.class, 2);
boolean invert = properties.getProperty("invert", Boolean.class, false);
BufferedImage image = readImage(width, height);
printBanner(image, margin, invert, out);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:ImageBanner.java
示例13: getResourceName
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
private String getResourceName(String view, Environment environment) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
"spring.mvc.view.");
String prefix = resolver.getProperty("prefix",
WebMvcAutoConfiguration.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix",
WebMvcAutoConfiguration.DEFAULT_SUFFIX);
return prefix + view + suffix;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JspTemplateAvailabilityProvider.java
示例14: getMatchOutcome
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
PropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "security.oauth2.client.");
String clientId = resolver.getProperty("client-id");
return new ConditionOutcome(StringUtils.hasLength(clientId),
"Non empty security.oauth2.client.client-id");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:OAuth2RestOperationsConfiguration.java
示例15: isTemplateAvailable
import org.springframework.core.env.PropertyResolver; //导入方法依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment,
ClassLoader classLoader, ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("groovy.text.TemplateEngine", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
"spring.groovy.template.");
String prefix = resolver.getProperty("prefix",
GroovyTemplateProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix",
GroovyTemplateProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(prefix + view + suffix).exists();
}
return false;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:GroovyTemplateAvailabilityProvider.java