OLL Mobile


Creating and Using Contexts and Dependency Injection (CDI) Interceptors

General Information

  • Contexts and Dependency Injection (CDI) was introduced with Java Platform, Enterprise Edition (Java EE) 6 as JSR-299. The Contexts part of CDI allows beans to share and participate in the life cycle of another bean, while the Dependency Injection part of CDI allows beans to get a reference to an instance of another bean simply by injecting it. CDI power is the ability to loosely couple classes by removing the instantiation process and simultaneously enforcing strong-type checking. CDI provides an @Inject annotation to create a reference to another bean (avoiding the older context lookup process). CDI enforces typing by eliminating string-based lookup so that the compiler can detect errors. CDI works very well with integrated development environments (IDEs).

    This tutorial looks at a particular kind of CDI service called an interceptor. An interceptor is invoked prior to the invocation of a method on which the interceptor binding annotation is placed. Interceptors are very useful for tasks that need to be applied to several methods without adding more code to the existing methods. These tasks are often referred to as cross-cutting tasks. Logging and auditing are examples of tasks that cut across business methods,

    In this tutorial, you create an interceptor binding type, which is an annotation used to associate an interceptor with either a method or a bean class. The interceptor binding type is also associated with an interceptor class that contains a single method annotated with @AroundInvoke.

    Release Date: 14-Jan-13

    Duration: 45 minutes

    Credited To: -

    No Flash Plugin Needed

Other Related Products

Visit the Full Site | About Oracle | Contact Us | Terms of Use