简介:
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