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);
猜你喜欢
- 5天前(大理悦云雅阁酒店电话)雅阁酒店集团|端午佳节礼遇,大理悦云雅阁度假酒店
- 5天前(哈弗h9优惠9万是真的吗)热浪来袭,哈弗H9超值补贴火热加码
- 5天前(兵团猛进秦剧团持续开展“戏曲进校园”活动)兵团猛进秦剧团持续开展“戏曲进校园”活动
- 5天前(“为人民绽放——国家艺术基金优秀剧目展演”在合肥开幕)“为人民绽放——国家艺术基金优秀剧目展演”在合肥开幕
- 5天前(苏梅岛普吉岛哪个好玩)苏梅岛金普顿基塔蕾度假酒店推出家庭度假套餐
- 5天前(上海迪士尼 夏天)酷爽夏日,奇妙相伴!来上海迪士尼度假区清凉入夏
- 5天前(大黄山景区高质量发展联盟成立多少年)大黄山景区高质量发展联盟成立
- 5天前(殷建祥简历)全国十大牛商解码:殷建祥如何用178天技术突围打造星空梦星空房
- 5天前(新西兰登陆《我的世界》!全球首个目的地游戏模组震撼上线)新西兰登陆《我的世界》!全球首个目的地游戏模组震撼上线
- 5天前(内蒙古冬季旅游攻略)内蒙古冬日奇遇:携程租车带你策马踏雪
网友评论
- 搜索
- 最新文章
- (2020广州车展哈弗)你的猛龙 独一无二 哈弗猛龙广州车展闪耀登场
- (哈弗新能源suv2019款)智能科技颠覆出行体验 哈弗重塑新能源越野SUV价值认知
- (2021款全新哈弗h5自动四驱报价)新哈弗H5再赴保障之旅,无惧冰雪护航哈弗全民电四驱挑战赛
- (海南航空现况怎样)用一场直播找到市场扩张新渠道,海南航空做对了什么?
- (visa jcb 日本)优惠面面俱到 JCB信用卡邀您畅玩日本冰雪季
- (第三届“堡里有年味·回村过大年”民俗花灯会活动)第三届“堡里有年味·回村过大年”民俗花灯会活动
- (展示非遗魅力 长安启源助力铜梁龙舞出征)展示非遗魅力 长安启源助力铜梁龙舞出征
- (阿斯塔纳航空公司)阿斯塔纳航空机队飞机数量增至50架
- (北京香港航班动态查询)香港快运航空北京大兴新航线今日首航
- (我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉)我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉
- 热门文章