Java Reference
In-Depth Information
More flexible AOP-based design
Whereas an EJB 2 façade can only use the services provided by the EJB container, a
Spring AOP -based design has a lot of flexibility. For example, the application can
use its own custom interceptors to automatically retry transactions and implement
audit logging. It can also use a more flexible exception handling mechanism since
the application has greater control over which exceptions cause transaction roll-
backs and can use unchecked exceptions more easily. EJB 3 provides some of this
flexibility by letting you define interceptors, but Spring is much more flexible.
7.1.3
Drawbacks of a POJO façade
This approach has several drawbacks as well. Let's look at each one of them in turn.
No support for transactions initiated by a remote client
One of the strengths of EJB is that it supports distributed transactions. A remote cli-
ent can initiate a transaction and invoke one or more EJB s, which then automatically
participate in the transaction. Any updates made by those EJB s are applied atomi-
cally when the client commits the transactions. If your application has a require-
ment to use this kind of distributed transaction, then you must use EJB . As you will
see in section 7.2.6, POJO façades can be invoked remotely but they cannot partic-
ipate in transactions that are initiated by a remote caller. However, this is rarely an
issue because very few applications actually use this kind of distributed transaction.
No equivalent to message-driven beans
Message-driven beans are a convenient way for an application to consume JMS
messages. The EJB container automatically invokes the message-driven bean when
a JMS message arrives and takes care of managing transactions. Unfortunately, as of
this writing Spring lacked support for the POJO equivalent of message-driven
beans. This means that you should most likely use message-driven beans if your
application uses JMS extensively. You can make developing with message-driven
beans more palatable by writing message-driven beans that delegate to POJO busi-
ness logic, which, of course, is easier to develop and test.
Nonstandard security
When implementing EJB s, you can use the EJB container's security mechanism to
control access to them. Not only is this a well-tried and -tested mechanism, but
some application servers are also integrated with other security products that pro-
vide more elaborate capabilities. For example, IBM WebSphere is integrated with
other IBM products such as Tivoli Access Manager, which provides centralized
 
 
 
 
 
 
 
Search WWH ::




Custom Search