Book Image

EJB 3 Developer Guide

By : Michael Sikora
Book Image

EJB 3 Developer Guide

By: Michael Sikora

Overview of this book

Table of Contents (18 chapters)
EJB 3 Developer Guide
Credits
About the Author
About the Reviewers
Preface
Annotations and Their Corresponding Packages

Summary


Interceptors are a new EJB 3 feature which separate common, or cross-cutting, code from business methods. Interceptors can be defined for session and message-driven beans. We can add an interceptor method to a bean by annotating that method with the @AroundInvoke annotation. The interceptor method wraps itself around the associated business method.

Interceptors can be defined in a separate class. A bean can have one or more interceptor classes associated with it denoted by the @Interceptors annotation.

Default interceptors are specified by XML deployment descriptors rather than annotations and apply when deployed. Default interceptors apply for all beans in the deployment.

If a business method has two or more interceptors, then it is possible for interceptors to pass messages between each other within the same business method invocation. This is done using the InvocationContext.getContextData() method.