>
> Hi,
>
> Another question about Dukes Pet Store:
>
> The EJB 1.1 Specification stresses the fact that a
> reference to a bean
> should not be passed to another class. Rather, the EJB
> Object reference
> should always be passed to another class as a parameter if
> communication
> with the bean is required by that other class.
>
> The com.sun.estore.control.ejb.StateMachine class is
> constructed by the
> com.sun.estore.control.ejb.ShoppingClientControllerEJB using
> the following
> code:
>
> public void ejbCreate() {
> sm = new StateMachine(this);
> }
I'm not familiar with that particular pet store, but it looks as if
StateMachine is a helper class of the ShoppingClientControllerEJB EJB, and
as such, the rule above does not apply.
If the StateMachine itself was an EJB, then the code would have looked
something like:
public void ejbCreate() {
...
sm =
stateMachineHome.create((ShoppingClientController)getSessionContext().getEJB
Object());
}
However, this would create a new problem: the SCC could not call the
StateMachine, because if the SM tried to call the SCC back, a re-entrant
call would result, which is forbidden.
Helper classes are in general fully contained within the EJB implementation.
When the EJB is passivated, all helper class instances are serialized to
secondary storage along with it, so all the cross-JVM problems that arise
when you pass EJB references don't exist. Helper classes are subject to all
the restrictions and enjoy all the benefits of their containing EJB classes.
>
> The StateMachine then logs out the user using this code:
>
> private void logout () {
> sccejb.ejbRemove();
> Debug.println("Logged out user.");
> }
>
> This seems to be a complete contradiction of the way
> things are supposed
> to be done. In this case the container has no idea that the
> bean has been
> removed. I assume the RI gets away with this code since it
> probably clears
> out the beans from the session during a logout but the
> assumption can not be
> made for all servers.
I agree with you on this - the EJB callbacks should not be called by user
code.
In theory, the container-generated classes could trap this method call, but
I doubt if any do this.
>
> Again, have I misunderstood something?
>
HTH,
- Avi
--
s/\be(\w+)/e-\1/g;
===========================================================================
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".