+

Search Tips   |   Advanced Search

Develop stateful session beans

Create a bean implementation class for a stateful session bean as introduced in the Enterprise JavaBeans (EJB) 1.0 specification and significantly simplified by the EJB 3.0 specification. A stateful bean is a type of session bean intended for use by a single client during its lifetime and maintains a conversational state with the client that is calling it.

Make sure that we understand the inheritance rules for each annotation you implement. For example, the @TransactionManagement annotation is coded on the stateful session bean class only. We cannot use the @TransactionManagement annotation in the class that it extends, or any class higher in the class inheritance tree.

Stateful session beans can have the following views: no-interface local view (new in EJB 3.1), business local, business remote, EJB 2.1 local, and EJB2.1 remote client views. One example is a shopping cart where the client adds items to the cart over the course of an on-line shopping session.

Basic stateful session bean:

As with other enterprise bean types, we can also declare metadata for stateful session beans in the deployment descriptor rather than using annotations; for example:


Tasks


  • EJB container system properties