Guice AOP

使用bindInterceptor来实现AOP java

/* 
 * 第一个参数表示匹配全部的类
 * 第二个参数表示匹配由Logged注解的方法
 * 第三个参数表示具体的AOP方法
 */
bindInterceptor(Matchers.any(),
                Matchers.annotatedWith(Logged.class),
                new MethodInterceptor(){
                    @Override
                    public Object invoke(MethodInvocation invocation) throws Thorwable {
                        // 实现具体的切面方法
                        return null;
                    }
                });
相关文章
相关标签/搜索