Java Reference
In-Depth Information
Session beans
A session bean exposes operations to the user. The session bean exists in mem-
ory until the client removes the bean or disconnects from the server, terminating
the session. A session bean can either be stateless or stateful . A stateless session
bean exposes service APIs without ever storing a state—many people equate the
exposed methods on this type of bean to using static methods. A stateful ses-
sion bean, as its name implies, stores a state temporarily during its execution.
However, even though it has a state, it is not persisted and is therefore discarded
when the bean is removed or the client terminates the connection.
Entity beans
An entity bean provides access to persistent enterprise data. The bean is mapped
to a row in a database table. For example, a purchase order management system
would typically use an entity bean to provide access to an individual purchase order.
Combining session beans with entity beans using common software patterns
provides a robust solution for accessing data. For example, a session bean could
expose an interface that would provide employee information. The session
bean could return an EmployeeInfo object that would be built from an Employee-
Address object and an EmployeeSalary object. The EmployeeAddress object and
the EmployeeSalary object would be persistent entity beans. The session bean
would build the information object by combining the data that came from both
entity beans.
Message-driven beans
Message-driven beans are used to handle messages from JMS . These beans are
similar to stateless session beans in that they do not keep a client's state and retain
no data between operations. Message-driven beans are used specifically to handle
JMS messages in an asynchronous matter to avoid tying up application resources.
14.1.2
Why combine JMX with EJBs?
Combining EJB s with a JMX management system provides a powerful way to
monitor data flow and manage an enterprise application. If your management
system has visibility into the enterprise business model, you can present data in a
fashion that might make certain decision processes simpler and more efficient.
You can build additional client access into your back-end EJB s, but doing so takes
time and additional resources for development and testing. By using JMX , you
can quickly instrument your EJB s in order to provide direct access to their func-
tionality and data.
Search WWH ::




Custom Search