Hey
Andy Piper wrote:
> At 10:48 PM 2/26/99 +0100, Rickard �berg wrote:
> >You've got it backwards:
> >1) Stateless session beans don't get passivated
> >2) You can keep references to whatever you want (for example the Home of
> >an EntityBean)
>
> Sure, but surely bean references count as conversational state and
> therefore stateful session beans need to be used?
Nope, not necessarily. In a Teller bean which accesses Account
EntityBeans I could have a reference to the AccountHome which is looked
up when setSessionContext is called. Teller would still be a stateless
bean, but it has references to a Home-stub. Since the Home is not
specific for any client there is no problem.
> >> Ok, so here I'm caching the result of the lookup and if ejbPassivate()
> >> junks it then I get it again? This seem better but in a large, multi-user
> >> system, passivation is quite likely is it not?
> >
> >Not with stateless beans. What's to passivate??
>
> But with stateless beans surely I am not allowed to save home references
> because there is no guarantee that they will stick around?
It will stick around until ejbRemove is called which is when you should
drop the Home reference.
Example:
public class TellerBean
implements SessionBean
{
private AccountHome acctHome; // Not clientspecific so okay to share!
private SessionContext ctx;
public void ejbCreate() throws RemoteException {}
public void ejbRemove() { acctHome = null; } // Not really necessary
due to GC but anyway...
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext ctx)
{
this.ctx = ctx;
Properties props = ctx.getEnvironment();
Context ctx = new InitialContext(props);
acctHome = (AccountHome) ctx.lookup("Account");
}
...
business methods
...
}
/Rickard
--
Rickard �berg
Computer Science student@LiTH
@home: +46 13 177937
Email: [EMAIL PROTECTED]
Homepage: http://www-und.ida.liu.se/~ricob684
===========================================================================
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".