Hey

Laird Nelson wrote:
> > Assume that a stateless bean only exists for the duration of a method
> > call. After you're done with it, the bean is disposed of (or reused by
> > someone else). Before calling a bean, always look it up through JNDI.
>
> I think I understood this before, but its impact is just becoming clear
> to me.  Is it REALLY true that I *shouldn't* do something like this:
>
>   // look up session bean here via JNDI...
>   sessionBean.foo();
>   sessionBean.bar();
>   sessionBean.baz();
>
> ...but SHOULD instead do something like this:
>
>   InitialContext ctx = getTheContext(); // can't remember syntax off top
> of head
>   SomeSessionBean bean = (SomeSessionBean)ctx.lookup(name);
>   bean.foo();
>
>   bean = (SomeSessionBean)ctx.lookup(name);
>   bean.bar();
>
>   bean = (SomeSessionBean)ctx.lookup(name);
>   bean.baz();
>
> ...?  Wow.  And this is all supposed to scale?!

I think Assaf took it one step too far. You should hang on to the home
object and do create/remove if you're in a clustered environment, since
"many" implementations do loadbalancing on create() (a la COM).

/Rickard

--
Rickard Öberg

@home: +46 13 177937
Email: [EMAIL PROTECTED]
http://www.dreambean.com
Question reality

===========================================================================
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