Gratry-1.1.0 釋出, Spring Aop 之外的新選擇
簡介:
Gadtry 是一個構建於java8之上的工具庫, 涵蓋了Ioc
Aop
exec
graph
等等工具庫,幾乎涵蓋了日常開發中非常多工具類,當然它還在不斷豐富中.
Gadtry 1.1.0 穩定版已釋出,主要新增Aop功能,特點如下:
* 新增完備 Aop功能, 支援介面代理和非介面類代理(非final)
* 支援和Gadtry-Ioc容器進行結合代理
* 支援非容器場景代理(注意應對 沒有使用任何ioc容器的專案)
* 已支援Spring-Aop所有概念和語義
演示:
* 結合Gadtry-Ioc:
IocFactory iocFactory = GadTry.create(binder -> { binder.bind(Map.class).byCreator(HashMap::new).withSingle(); binder.bind(HashSet.class).by(HashSet.class).withSingle(); }).aop(binder -> { binder.bind("point1") .withPackage("com.github.harbby") //.subclassOf(Map.class) .classAnnotated() .classes(HashMap.class, HashSet.class) .whereMethod(methodInfo -> methodInfo.getName().startsWith("add")) .build() .before((info) -> { Assert.assertEquals("add", info.getName()); System.out.println("before1"); }) .after(() -> { Assert.assertTrue(true); System.out.println("after2"); }); }).initialize(); Set set = iocFactory.getInstance(HashSet.class);
更多細節請查詢: https://gitee.com/mirrors/Gadtry