org.springframework.boot.bind.RelaxedPropertyResolver Java Examples
The following examples show how to use
org.springframework.boot.bind.RelaxedPropertyResolver.
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: RelaxedPropertyResolverBootstrap.java From thinking-in-spring-boot-samples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { ConfigurableApplicationContext context = new SpringApplicationBuilder( RelaxedPropertyResolverBootstrap.class) .properties("user.city.postCode=0571") .web(false) // 非 Web 应用 .run(args); // 获取 Environment,也是 PropertyResolver 对象 PropertyResolver environment = context.getEnvironment(); // 属性名称前缀 String prefix = "user.city."; // 创建 RelaxedPropertyResolver 实例 RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(environment, prefix); // 获取松散化配置属性 String postCode = propertyResolver.getProperty("post-code"); System.out.println("postCode = " + postCode); // 关闭上下文 context.close(); }
Example #2
Source File: SpringPropertyAction.java From super-cloudops with Apache License 2.0 | 6 votes |
private String getValue(String source, String defaultValue) { if (this.environment == null) { addWarn("No Spring Environment available to resolve " + source); return defaultValue; } String value = this.environment.getProperty(source); if (value != null) { return value; } int lastDot = source.lastIndexOf("."); if (lastDot > 0) { String prefix = source.substring(0, lastDot + 1); RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(this.environment, prefix); return resolver.getProperty(source.substring(lastDot + 1), defaultValue); } return defaultValue; }
Example #3
Source File: DataSourceConfig.java From tinyid with Apache License 2.0 | 6 votes |
@Bean public DataSource getDynamicDataSource() { DynamicDataSource routingDataSource = new DynamicDataSource(); List<String> dataSourceKeys = new ArrayList<>(); RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(environment, "datasource.tinyid."); String names = propertyResolver.getProperty("names"); String dataSourceType = propertyResolver.getProperty("type"); Map<Object, Object> targetDataSources = new HashMap<>(4); routingDataSource.setTargetDataSources(targetDataSources); routingDataSource.setDataSourceKeys(dataSourceKeys); // 多个数据源 for (String name : names.split(SEP)) { Map<String, Object> dsMap = propertyResolver.getSubProperties(name + "."); DataSource dataSource = buildDataSource(dataSourceType, dsMap); buildDataSourceProperties(dataSource, dsMap); targetDataSources.put(name, dataSource); dataSourceKeys.add(name); } return routingDataSource; }
Example #4
Source File: TrimouTemplateAvailabilityProvider.java From trimou with Apache License 2.0 | 5 votes |
public boolean isTemplateAvailable(final String view, final Environment environment, final ClassLoader classLoader, final ResourceLoader resourceLoader) { if (ClassUtils.isPresent("org.trimou.Mustache", classLoader)) { final PropertyResolver resolver = new RelaxedPropertyResolver(environment, TrimouProperties.PROPERTY_PREFIX + '.'); final String prefix = resolver.getProperty("prefix", SpringResourceTemplateLocator.DEFAULT_PREFIX); final String suffix = resolver.getProperty("suffix", SpringResourceTemplateLocator.DEFAULT_SUFFIX); final String resourceLocation = prefix + view + suffix; return resourceLoader.getResource(resourceLocation).exists(); } return false; }
Example #5
Source File: AbstractProxyTargetResolver.java From spring-cloud-netflix-zuul-websocket with Apache License 2.0 | 5 votes |
protected URI resolveUri(ServiceInstance serviceInstance) { Map<String, Object> metadata = new HashMap<>(); for (Map.Entry<String, String> entry : serviceInstance.getMetadata().entrySet()) { metadata.put(entry.getKey(), entry.getValue()); } UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUri(serviceInstance.getUri()); RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(new MapPropertyResolver(metadata)); String configPath = propertyResolver.getProperty("configPath"); if (configPath != null) { uriBuilder.path(configPath); } return uriBuilder.build().toUri(); }
Example #6
Source File: MetricsConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_METRICS_GRAPHITE); }
Example #7
Source File: OAuth2ServerConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_OAUTH); }
Example #8
Source File: MetricsConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_METRICS); }
Example #9
Source File: SwaggerConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "swagger."); }
Example #10
Source File: AsyncConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "async."); }
Example #11
Source File: MailConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_SPRING_MAIL); }
Example #12
Source File: LocaleConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.messageSource."); }
Example #13
Source File: DatabaseConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment env) { this.env = env; this.dataSourcePropertyResolver = new RelaxedPropertyResolver(env, "spring.datasource."); this.liquiBasePropertyResolver = new RelaxedPropertyResolver(env, "liquiBase."); }
Example #14
Source File: MetricsConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_METRICS_GRAPHITE); }
Example #15
Source File: MetricsConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_METRICS); }
Example #16
Source File: SwaggerConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "swagger."); }
Example #17
Source File: AsyncConfiguration.java From angularjs-springboot-bookstore with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "async."); }
Example #18
Source File: OAuth2ServerConfiguration.java From todo-spring-angular with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "authentication.oauth."); }
Example #19
Source File: MetricsConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_METRICS_SPARK); }
Example #20
Source File: DatabaseConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(final Environment env) { this.env = env; this.dataSourcePropertyResolver = new RelaxedPropertyResolver(env, "spring.datasource."); this.liquiBasePropertyResolver = new RelaxedPropertyResolver(env, "liquiBase."); }
Example #21
Source File: LocaleConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.messageSource."); }
Example #22
Source File: MailConfiguration.java From ServiceCutter with Apache License 2.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, ENV_SPRING_MAIL); }
Example #23
Source File: SampleLatticeApplication.java From spring-cloud-lattice with Apache License 2.0 | 4 votes |
@RequestMapping("/myenv") public String env(@RequestParam("prop") String prop) { String property = new RelaxedPropertyResolver(env).getProperty(prop, "Not Found"); return property; }
Example #24
Source File: EnhanceSpringMvcContract.java From onetwo with Apache License 2.0 | 4 votes |
@Override public void afterPropertiesSet() throws Exception { relaxedPropertyResolver = new RelaxedPropertyResolver(applicationContext.getEnvironment()); }
Example #25
Source File: EnabledKeyCondition.java From onetwo with Apache License 2.0 | 4 votes |
protected boolean isEnabled(Environment environment, String key){ return new RelaxedPropertyResolver(environment).getProperty(key, Boolean.class, defaultEnabledValue); }
Example #26
Source File: SampleEtcdApplication.java From spring-cloud-etcd with Apache License 2.0 | 4 votes |
@RequestMapping("/myenv") public String env(@RequestParam("prop") String prop) { String property = new RelaxedPropertyResolver(env).getProperty(prop, "Not Found"); return property; }
Example #27
Source File: WicketDevToolsPropertyDefaultsPostProcessor.java From wicket-spring-boot with Apache License 2.0 | 4 votes |
private boolean isRemoteRestartEnabled(Environment environment) { RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.devtools.remote."); return resolver.containsProperty("secret"); }
Example #28
Source File: VelocityConfiguration.java From DCMonitor with MIT License | 4 votes |
@Override public void setEnvironment(Environment environment) { this.environment = new RelaxedPropertyResolver(environment, "spring.velocity."); }
Example #29
Source File: LocaleConfiguration.java From expper with GNU General Public License v3.0 | 4 votes |
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.messages."); }
Example #30
Source File: CrossOriginFilter.java From demo-spring-security-cas with Apache License 2.0 | 4 votes |
public CrossOriginFilter(Environment environment) throws ServletException { String origins = new RelaxedPropertyResolver(environment, ENV_APP_CORS).getRequiredProperty("allowed.origins", String.class); this.setAllowedOrigins(origins); }