eWebProgrammer
Distributednetworks GofPatterns
prev next prev next
  Course navigation
 
Lesson 5
Objective
Session beans
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:
Session bean
  1. 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.
  2. Can have a transaction associated with it.
  3. May update shared data in an underlying database, but it does not directly represent the shared data.
  4. 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.
  5. 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.
  Course navigation