WebSphere® Application Server provides
a special operational mode called lightweight local mode, which
can improve the performance of entity bean methods. You can decide
which entity beans in your application to run in this mode.
In lightweight local mode, the container streamlines the processing
that it performs before and after every method on the local home interface
and local business interface of the bean. This streamlining can result
in improved performance when entity bean operations are called locally
from within an application. Because some processing is skipped when
running in lightweight local mode, this mode can be used in certain
scenarios only.
Lightweight local mode is patterned somewhat after the
Plain Old Java Object (POJO) entity
model introduced in the Enterprise JavaBeans (EJB) 3.0 specification.
Using lightweight local mode, you can obtain some of the performance
advantages of the POJO entity model without having to convert your
existing EJB 2.x application code to the new POJO model. You can
apply lightweight local mode to both container-managed persistence
(CMP) and bean-managed persistence (BMP) entity types that meet the
specific criteria.
Attention: Entity beans are not supported
in EJB 3.0 modules.
When to use the lightweight local mode
Lightweight
local mode is designed for entity beans that are created, found, and
called using the Session Facade pattern. Under this pattern,
entity bean local home and local business methods are called from
within methods of a stateless session bean or stateful session bean.
The session bean methods, which can be called remotely or locally,
provide security control and transaction demarcation for the entity
beans that are accessed by the session bean.
You can apply lightweight
local mode only to an entity bean that meets the following criteria:
- The bean implements an EJB local interface.
- No security authorization is defined on the entity bean local
home or local business interface methods.
- No run-as security attribute is defined on the local home
or local business methods.
- The classes for the calling bean and the called entity bean are
loaded by the same Java classloader.
- The entity bean methods do not call the WebSphere Application Server-specific Internationalization
Service or Work Area Service.
The first criterion prevents CMP 1.x beans from supporting
lightweight local mode, because the 1.x beans cannot have local interfaces.
In
addition, lightweight local mode provides its fullest performance
benefits only to entity bean methods that do not need to start a global
transaction. This condition is true if you ensure that your entity
bean also meets the following criteria:
- A global transaction is already in effect when the entity bean
home or business method is called. Typically, this transaction is
started by the calling session bean.
- The local business interface methods and the local home methods
of the entity bean use the following transaction attributes only:
REQUIRED, SUPPORTS, or MANDATORY.
If an entity bean method that is running in lightweight
local mode must start a global transaction, the bean still functions
normally but only a partial performance benefit is realized.
You
can mark an entity bean that defines a remote interface or a TimedObject
interface, in addition to the local interface, for lightweight local
mode. However, the performance benefit is apparent only when the bean
is called through its local interface.