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配置
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"));
配置绑定到Map对象
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);
猜你喜欢
- 4天前(a级景区评定机构)全国A级旅游景区创建与提升培训班在敦煌市举办
- 4天前(香港航空三亚航线复航了吗)香港航空三亚航线复航
- 4天前(哈弗h9优惠9万是真的吗)热浪来袭,哈弗H9超值补贴火热加码
- 4天前(杭州西湖区万怡酒店正式开业了吗)杭州西湖区万怡酒店正式开业
- 4天前(花王伴你乐享五一好“趣”处)花王伴你乐享五一好“趣”处
- 4天前(曼谷丽思卡尔顿公寓价格)曼谷丽思卡尔顿酒店盛大启幕,开创泰国奢华雅致新纪元
- 4天前(万豪旅享家活动2021)精彩上新,漫享夏日----跟随万豪旅享家新开酒店解锁夏日旅行灵感
- 4天前(星级饭店的发展困境)星级饭店转型之路:从市场逻辑到行业实践的深度探索
- 4天前(“三天跨两城”催生租车新需求,神州租车清明跨城订单同比增长416%)“三天跨两城”催生租车新需求,神州租车清明跨城订单同比增长416%
- 4天前(芜宣机场国际航班)新华丝路:芜宣机场开通至越南首都河内的国际货运航线
网友评论
- 搜索
- 最新文章
- (2020广州车展哈弗)你的猛龙 独一无二 哈弗猛龙广州车展闪耀登场
- (哈弗新能源suv2019款)智能科技颠覆出行体验 哈弗重塑新能源越野SUV价值认知
- (2021款全新哈弗h5自动四驱报价)新哈弗H5再赴保障之旅,无惧冰雪护航哈弗全民电四驱挑战赛
- (海南航空现况怎样)用一场直播找到市场扩张新渠道,海南航空做对了什么?
- (visa jcb 日本)优惠面面俱到 JCB信用卡邀您畅玩日本冰雪季
- (第三届“堡里有年味·回村过大年”民俗花灯会活动)第三届“堡里有年味·回村过大年”民俗花灯会活动
- (展示非遗魅力 长安启源助力铜梁龙舞出征)展示非遗魅力 长安启源助力铜梁龙舞出征
- (阿斯塔纳航空公司)阿斯塔纳航空机队飞机数量增至50架
- (北京香港航班动态查询)香港快运航空北京大兴新航线今日首航
- (我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉)我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉
- 热门文章