Handles are serializeable, refs aren't. But for Entity beans anyway, refs are supposed to survive a restart. From the spec:

"Each entity object has an identity which, in general, survives a crash and restart of the container in
which the entity object has been created. The object identity is implemented by the container with the
cooperation of the enterprise bean class."

and

"While a crash of the Java Virtual Machine may result in a rollback of current transactions, it does not destroy previously
created entity objects nor invalidate the references to the home and component interfaces held by clients."

However, the spec is a little bit more vague about Session beans. On the one hand, it does say that clients should be prepared to get another reference to a session bean in case of failure (though it says that "high-end" containers can transparently hide errors like that from the client). On the other hand, for stateless session beans, it says that the container can service the client calls using any instance. Stateless session beans aren't subject to passivation and activation calls. I can't find anything pertaining to the reliability of session bean HOME interfaces across restarts.

That doesn't mean it's not in there ;-).

I guess (especially for stateful session beans) caution is warranted w/ the actual references to the objects, but I suspect that the Home interfaces are safe to cache. But then again, the code for JBoss is available, so if one has doubts, one can always "go to the source."

Dave



Brian Wallis <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

06/05/2003 08:43 PM
Please respond to jboss-user

       
        To:        [EMAIL PROTECTED], [EMAIL PROTECTED]
        cc:        
        Subject:        Re: [JBoss-user] Should I cache ejbRefs?



On Fri, 6 Jun 2003 00:01, [EMAIL PROTECTED] wrote:
> Brian,
>
> The XDoclet utilobject pattern caches Remote and (Local Homes the latter
> is of course only valid w/in one JVM), I've seen this mentioned on
> theserverside.com and elsewhere as a best practice, and after digging
> through the spec to be sure, apparently both Remote Homes and Remote
> interfaces should be durable even across a server restart (this is what
> the spec says -- the references themselves are still valid after a
> restart). The only time the references aren't valid is if the beans they
> reference have been removed. This is obviously only a problem w/ Remote
> Interfaces (not Homes).

I don't think the references them selves are durable, you need to get a
javax.ejb.Handle and use that. from it's doco:

* The Handle interface is implemented by all EJB object handles. A handle
* is an abstraction of a network reference to an EJB object. A handle is
* intended to be used as a "robust" persistent reference to an EJB object.

and you get these via javax.ejb.EJBObject.getHandle() on the base interface
for all the beans. Handle supports on method, getEJBObject() to get back to
your reference when you need it.

brian...



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to