import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.framework.ProxyFactory;
public class Hello {
public void hello() {
System.out.println("Hello");
}
public static void main(String[] args) {
Hello hello = new Hello();
ProxyFactory pf = new ProxyFactory(hello);
pf.addAdvice(new MethodInterceptor() {
public Object invoke(MethodInvocation invocation) throws Throwable {
if (invocation.getMethod().getName().equals("hello")) {
System.out.println("Intercepting hello");
}
Object retVal = invocation.proceed();
return retVal;
}
});
Hello proxyHello = (Hello)pf.getProxy();
proxyHello.hello();
}
}
See. I think we can implement this on Guice. Is it possible? I haven't check the source code yet, but I think this is possible.