Skip to Main Content
Enterprise JavaBeans 3.1, 6th Edition
book

Enterprise JavaBeans 3.1, 6th Edition

by Andrew Lee Rubinger, Bill Burke
September 2010
Intermediate to advanced content levelIntermediate to advanced
766 pages
18h 35m
English
O'Reilly Media, Inc.
Content preview from Enterprise JavaBeans 3.1, 6th Edition

Appendix I. Interceptors: TV Channel Service Example

Description

As we’ve seen with security and transactions, often we have business logic that is not a part of our core concerns. Quite the opposite; applications are likely to have rules that need to be universal across modules or EJBs, and baking this logic into our implementation mixes concerns and makes for an unmaintainable system over time.

Much like Servlet Filters or AOP aspects, the EJB Interceptor model provides a mechanism for application developers to apply logic to incoming requests. The @Interceptors annotation quickly acts as a mapping marker for the EJB container to know to apply a particular interceptor for a given invocation.

Our example represents a television server which is capable of returning channel streams when a channel number is requested by the client. We apply a custom security policy whereby Channel 2 may be closed by an administrator; if a client requests Channel 2 while access is disallowed, the invocation will return a “Channel2ClosedException”. All of this logic is separated from the core code to return the channel requested, and therefore may be applied to other modules or unplugged from the system without need to alter the existing application in any way.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
JavaServer Faces

JavaServer Faces

Hans Bergsten
EJB 3 Developer Guide

EJB 3 Developer Guide

Michael Sikora

Publisher Resources

ISBN: 9781449399139Errata Page