Java Code Examples for org.springframework.core.env.PropertySource#containsProperty()
The following examples show how to use
org.springframework.core.env.PropertySource#containsProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvironmentPropertiesPostProcessor.java From teiid-spring-boot with Apache License 2.0 | 6 votes |
@Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { PropertySource<?> system = environment.getPropertySources().get(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME); Map<String, Object> prefixed = new LinkedHashMap<>(); for (String property: PROPERTIES) { if (system.containsProperty(property)) { if (property.startsWith(LOG_PREFIX)) { prefixed.put("logging.level.org.teiid." + property.substring(LOG_PREFIX.length()), system.getProperty(property)); } else if (property.equals("LOGGING_LEVEL_ORG_TEIID")) { prefixed.put("logging.level.org.teiid", system.getProperty(property)); } } } environment.getPropertySources().addAfter(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, new MapPropertySource("prefixer", prefixed)); }
Example 2
Source File: BootstrapApplicationListener.java From spring-cloud-commons with Apache License 2.0 | 6 votes |
private void mergeDefaultProperties(MutablePropertySources environment, MutablePropertySources bootstrap) { String name = DEFAULT_PROPERTIES; if (bootstrap.contains(name)) { PropertySource<?> source = bootstrap.get(name); if (!environment.contains(name)) { environment.addLast(source); } else { PropertySource<?> target = environment.get(name); if (target instanceof MapPropertySource && target != source && source instanceof MapPropertySource) { Map<String, Object> targetMap = ((MapPropertySource) target) .getSource(); Map<String, Object> map = ((MapPropertySource) source).getSource(); for (String key : map.keySet()) { if (!target.containsProperty(key)) { targetMap.put(key, map.get(key)); } } } } } mergeAdditionalPropertySources(environment, bootstrap); }
Example 3
Source File: PriceCalculationEnvironmentPostProcessor.java From tutorials with MIT License | 4 votes |
private boolean hasOurPriceProperties(PropertySource<?> system) { if (system.containsProperty(CALCUATION_MODE) && system.containsProperty(GROSS_CALCULATION_TAX_RATE)) { return true; } else return false; }