Should You Use EJBs?
This book assumes that youâve already made the decision to use EJBs. However, there are several instances where EJBs are not the best solution to a problem. It makes sense, therefore to review where EJBs are strong and then discuss situations in which EJBs donât make as much sense. There are several situationsâeven some enterprise database-centric applicationsâin which EJBs are simply not the best choice. At the end of this section, weâll look at some of the alternative approaches and where they might fit.
When to Use EJBs
Hereâs a list of situations where EJBs are strong; we havenât distinguished between different types of EJBs.
- Single and multisystem business transactions
The ability to maintain transactional integrity for complex business entities is one of an EJBâs key strengths. EJBs arenât alone in providing straightforward transactional control over a single data repository. However, EJBs shine where multiple resources (relational databases, messaging systems, etc.) are involved because they allow transactions to spread across as many different resources as you like, so long as the resources support distributed transactions.
- Distributed functionality
Business services often live on a remote server. For example, a business enterprise will have many different systems, ranging in degrees of inflexibility and entrenchment. One of these systems may need to access another; EJBs, which are inherently distributed, are often the simplest way to distribute ...
Get Enterprise JavaBeans, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.