Java Reference
In-Depth Information
A stateless session bean approach is chosen for most
applications. Any user-specific state necessary for processing
should either be passed in as an argument to the EJB methods
(and stored outside the EJB through a mechanism like the
HttpSession), or be retrieved as part of the EJB transaction
from a persistent store (for instance, through the use of Entity
beans). Where appropriate, this information can be cached in
memory, but beware of the potential challenges that surround
keeping the cache consistent in a distributed environment.
Caching works best for read-only data.
In general, you should make sure that you plan for scalability
from day one. Examine all the assumptions in your design
and see if they still hold if your application will run on more
than one server. This rule applies not only in application code
in the cases outlined above, but also to situations like MBeans
and other administrative interfaces.
Use container-managed transactions.
Leverage two-phase commit transactions work in Java EE and
rely on them rather than developing your own transaction
management. The container will almost always be better at
transaction optimization.
Container-managed transactions (CMTs) provide two key
advantages that are nearly impossible to obtain without
container support: composable units of work, and robust
transactional behavior.
If your application code explicitly begins and ends
transactions (perhaps using javax.jts.UserTransaction, or even
native resource transactions), future requirements to compose
Search WWH ::




Custom Search