Peter Delaney wrote:

> Hello;
>
> I have a Stateful SessionBean called Bank, that clients applications talk to.
> The Bank SessionBean creates another Stateful SessionBean called Portfolio that
> contains information about the client.
>
> When my Bank SessionBean gets passivated by the container, how does it maintain
> its reference to the Porftolio SessionBean once it gets re-activated by the
> container?

Technically, this is easy - Bank can get a serializable handle to Portfolio and
save the serialised handle. See section 5.7 of the EJB spec (1.0 or 1.1)

However, because of the lack of "guarantees" for stateful session beans it is
generally not deemed good practice to have one stateful session bean calling
another. Bank cannot rely on Portfolio existing next time it tries to use it
(whether passivation occurred or not). This means Bank must terminate whenever it
finds Portfolio has terminated (or have a means reconstruct Portfolio in which case
Portfolio does not need to be stateful.) If there are multiple such stateful
session beans distributed over a network the application would get unreliable very
quickly with all work lost whenever any failure occurs.

The recommended way is to concentrate session state into a single session bean and
use stateless session beans or entity beans for the lower level services. This does
not lead to good OO encapsulation of course, but additional container services are
needed to give effective support to distributed session state.

Ian McCallion

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to