Difference between stateless and stateful Session Beans

Session bean description

A Session bean, whether stateful or stateless, is best understood by looking at its characteristics.
Look at the diagram below and then examine the list of characteristics:

A client can communicate to an EJBOjbect by means of 1) RMI 2) Corba 3) COM

A session bean is created on behalf of a single client

A session bean must implement the Session Bean interface

The client uses a naming service to locate the session bean

1. A client can communicate to an EJBOjbect 2.A session bean is created on behalf of a single client

Executes on behalf of a single client. There is a one-to-one relationship between the client and the bean instance. In the diagram above, each client is associated with a single bean.

Can have a transaction associated with it.

May update shared data in an underlying database, but it does not directly represent the shared data.

Is relatively short-lived. How long is short-lived, you may well ask? The EJB specification defines it as a fraction of a second to as much
as a few months. It assumes that it does get removed (remove is equivalent to delete) at some point after its creation.

Is removed when the container crashes. The state of the bean instance will be lost. The client will have to re-establish a new session bean
instance to continue computation.

A typical EJB container will provide a scalable runtime environment to execute a large number of session bean instances
concurrently and safely.
In the next lesson, stateful and stateless session beans will be discussed.