etl表达式解析
if (rawValue != null && rawValue.startsWith("#{") && entryValue.endsWith("}")) {
// assume it's spel
StandardEvaluationContext context = new StandardEvaluationContext();
context.setBeanResolver(new BeanFactoryResolver(beanFactory));
Expression expression = parser.parseExpression(entryValue,
new TemplateParserContext());
value = expression.getValue(context);
}
Bindablebindable = Bindable.of(this.configurable.getConfigClass());T t =new Binder(propertySources, null, conversionService) .bindOrCreate(configurationPropertyName, bindable, handler);
ApplicationContext context = SpringApplication.run(Application.class, args);
Binder binder = Binder.get(context.getEnvironment());
FooProperties foo = binder.bind("com.didispace", Bindable.of(FooProperties.class)).get();
System.out.println(foo.getFoo());
List
System.out.println(post);
List
System.out.println(posts);
// 读取配置 System.out.println(context.getEnvironment().containsProperty("com.didispace.database-platform"));
System.out.println(context.getEnvironment().containsProperty("com.didispace.databasePlatform"));
MapdsMap = binder.bind("demo.dynamic", Bindable.mapOf(String.class, DsConfig.class)).get(); System.out.println("Map Config: " + dsMap);
String decPwd = binder.bind("demo.enc.pwd", Bindable.of(String.class)) .map(s -> new String(Base64Utils.decodeFromString(s))).get(); System.out.println("解码之后的数据是: " + decPwd);
String dec = binder.bindOrCreate("demo.enc.pwd", Bindable.of(String.class), new BindHandler() {
@Override
public
System.out.println("开始绑定: " + name);
return BindHandler.super.onStart(name, target, context);
}
@Override
public Object onSuccess(ConfigurationPropertyName name, Bindable> target, BindContext context, Object result) {
System.out.println("绑定成功!" + name + " val:" + target.getValue() + " res: " + result);
return new String(Base64Utils.decodeFromString((String) result));
}
@Override
public Object onCreate(ConfigurationPropertyName name, Bindable> target, BindContext context, Object result) {
System.out.println("创建: " + name + " val:" + target.getValue() + " res: " + result);
return BindHandler.super.onCreate(name, target, context, result);
}
@Override
public Object onFailure(ConfigurationPropertyName name, Bindable> target, BindContext context, Exception error) throws Exception {
System.out.println("绑定失败! " + name + " " + error.getMessage());
return BindHandler.super.onFailure(name, target, context, error);
}
@Override
public void onFinish(ConfigurationPropertyName name, Bindable> target, BindContext context, Object result) throws Exception {
System.out.println("绑定结束: " + name + " val:" + target.getValue() + " res: " + result);
BindHandler.super.onFinish(name, target, context, result);
}
});
System.out.println("绑定回调: " + dec);