List of usage examples for org.springframework.core.env Environment resolvePlaceholders
String resolvePlaceholders(String text);
From source file:com.github.kpavlov.commons.spring.annotations.BooleanValueCondition.java
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { final Environment environment = context.getEnvironment(); if (environment != null) { Map<String, Object> attributes = metadata.getAnnotationAttributes(Enabled.class.getName()); if (attributes != null) { String expression = (String) attributes.get("value"); final String value = environment.resolvePlaceholders(expression); return (Boolean.parseBoolean(value)); }/*ww w .j a va 2 s . co m*/ } return true; }
From source file:com.bose.aem.spring.config.ConfigClientProperties.java
public ConfigClientProperties override(Environment environment) { ConfigClientProperties override = new ConfigClientProperties(); BeanUtils.copyProperties(this, override); override.setName(environment.resolvePlaceholders( "${" + ConfigClientProperties.PREFIX + ".name:${spring.application.name:application}}")); if (environment.containsProperty(ConfigClientProperties.PREFIX + ".profile")) { override.setProfile(environment.getProperty(ConfigClientProperties.PREFIX + ".profile")); }// ww w . j a va 2s. co m if (environment.containsProperty(ConfigClientProperties.PREFIX + ".label")) { override.setLabel(environment.getProperty(ConfigClientProperties.PREFIX + ".label")); } return override; }
From source file:org.apache.dubbo.config.spring.beans.factory.annotation.CompatibleReferenceAnnotationBeanPostProcessor.java
/** * Generate a cache key of {@link ReferenceBean} * * @param reference {@link Reference}/* ww w .j ava2s. c o m*/ * @param beanClass {@link Class} * @return */ private String generateReferenceBeanCacheKey(Reference reference, Class<?> beanClass) { String interfaceName = resolveInterfaceName(reference, beanClass); String key = reference.url() + "/" + interfaceName + "/" + reference.version() + "/" + reference.group(); Environment environment = applicationContext.getEnvironment(); key = environment.resolvePlaceholders(key); return key; }
From source file:org.springframework.boot.logging.LoggingApplicationListener.java
private void setLogLevel(LoggingSystem system, Environment environment, String name, String level) { try {//from ww w .j ava 2 s .c o m if (name.equalsIgnoreCase("root")) { name = null; } level = environment.resolvePlaceholders(level); system.setLogLevel(name, coerceLogLevel(level)); } catch (RuntimeException ex) { this.logger.error("Cannot set level: " + level + " for '" + name + "'"); } }
From source file:org.springframework.cloud.function.web.function.FunctionEndpointInitializer.java
FunctionEndpointFactory(FunctionCatalog functionCatalog, FunctionInspector inspector, RequestProcessor processor, Environment environment) { String handler = environment.resolvePlaceholders("${function.handler}"); if (handler.startsWith("$")) { handler = null;// w w w .ja v a 2 s.c o m } this.processor = processor; this.inspector = inspector; this.functionCatalog = functionCatalog; this.handler = handler; }
From source file:org.springframework.cloud.logging.LoggingRebinder.java
private void setLogLevel(LoggingSystem system, Environment environment, String name, String level) { try {/*from w w w . jav a 2 s . c om*/ if (name.equalsIgnoreCase("root")) { name = null; } level = environment.resolvePlaceholders(level); system.setLogLevel(name, LogLevel.valueOf(level)); } catch (RuntimeException ex) { this.logger.error("Cannot set level: " + level + " for '" + name + "'"); } }
From source file:org.springframework.xd.dirt.plugins.spark.streaming.SparkStreamingPlugin.java
/** * Get the list of jars that this spark module requires. * * @return the list of spark application jars *///from ww w.j a va2 s.com private List<String> getApplicationJars(Module module) { // Get jars from module classpath URLClassLoader classLoader = (URLClassLoader) ((SimpleModule) module).getClassLoader(); List<String> jars = new ArrayList<String>(); for (URL url : classLoader.getURLs()) { String file = url.getFile().split("\\!", 2)[0]; if (file.endsWith(".jar")) { jars.add(file); } } // Get message bus libraries Environment env = this.getApplicationContext().getEnvironment(); String jarsLocation = env.resolvePlaceholders(MessageBusClassLoaderFactory.MESSAGE_BUS_JARS_LOCATION); try { Resource[] resources = resolver.getResources(jarsLocation); for (Resource resource : resources) { URL url = resource.getURL(); jars.add(url.getFile()); } } catch (IOException ioe) { throw new RuntimeException(ioe); } // Get necessary dependencies from XD DIRT. URLClassLoader parentClassLoader = (URLClassLoader) classLoader.getParent(); URL[] urls = parentClassLoader.getURLs(); for (URL url : urls) { String file = FilenameUtils.getName(url.getFile()); String fileToAdd = url.getFile().split("\\!", 2)[0]; if (file.endsWith(".jar") && (// Add spark jars file.contains("spark") || // Add SpringXD dependencies file.contains("spring-xd-") || // Add Spring dependencies file.contains("spring-core") || file.contains("spring-integration-core") || file.contains("spring-beans") || file.contains("spring-context") || file.contains("spring-boot") || file.contains("spring-aop") || file.contains("spring-expression") || file.contains("spring-messaging") || file.contains("spring-retry") || file.contains("spring-tx") || file.contains("spring-data-commons") || file.contains("spring-data-redis") || file.contains("commons-pool") || file.contains("jedis") || // Add codec dependency file.contains("kryo") || file.contains("gs-collections"))) { jars.add(fileToAdd); } } return jars; }