O'Reilly logo

Learning Google Guice by Hussain Pithawala

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How Guice supports AOP?

Guice conforms to AOP alliance, and so we could directly write interceptors by implementing MethodInterceptor interface (org.aopalliance.intercept). APIs could then be annotated with custom annotations, and these annotations could be used to join method invocation with the interceptors. For joining method interception with the interceptor, we need to use the bindInterceptor(…) API from the AbstractModule. Let's see all of this in action.

Implementing a LoggingInterceptor

Consider we need to design a mechanism (a fictitious one), which could be used to log invocation to a method and arguments passed to it. This could be used across the methods. This makes it a good cross-cutting concern. Let's implement this concern as an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required