Professional Java® EE Design Patterns by Murat Yener & Alex Theedom

Professional Java® EE Design Patterns by Murat Yener & Alex Theedom

Author:Murat Yener & Alex Theedom
Language: eng
Format: epub
ISBN: 9781118843451
Published: 2014-12-16T00:00:00+00:00


Still, the example given is only valid in EJB and MDBs, which may not be enough for all cases. Thanks to CDI, it is not hard to achieve more.

CDI Interceptors

Before CDI, interceptors were applicable only for EJB and MDBs. CDI unleashed a huge power and transformed interceptors into an AOP-capable feature that works on any object.

Implementing CDI interceptors is straightforward and quite flexible. First, you need to specify a binding. A binding is a custom annotation annotated with @InterceptorBinding.

@InterceptorBinding @Target({TYPE, METHOD}) @Retention(RUNTIME) public @interface Secure {}

The @InterceptorBinding is used to bind interceptors with the target code. Next, you can implement and annotate the interceptor with the custom binding. CDI interceptors are implemented the same way as the EJB interceptors, the only significant difference being the use of the binding annotation which can be seen in Listing 8-10



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.