Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Isn't an Handle to an EB dangerous for synchronization?

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm studying that on an entity bean component stub (or reference) it makes sense to have business methods to Delete, Update, Query that entity, to get the entity home reference (in order to get other entities of the same type) and...get an handle to the entity.

Now, while handles with stateful session beans have got a meaning (because the client is keeping a reference to business logic), I can't see the utility of having an handle to an underlying entity. On the opposite, I see it as potentially dangerous, because in the meantime (I mean between the moment when an Handle is retrieved and the moment when it is re-used to get a reference (or stub) to the EJB[Local]Object it represents) the underlying entity can have been changed by someone else.
 
Severin Stoeckli
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...between the moment when an Handle is retrieved and the moment when it is re-used to get a reference (or stub) to the EJB[Local]Object it represents) the underlying entity can have been changed by someone else.


(1) yes, that's true, but the same is true if you use a reference (stub)?

(2) how would you pass a reference of an entity bean to a bean that live's in annother VM / on annother host if not by a handle?

...to the EJB[Local]Object


(3) handles are never used for local objects. Handles are only available on the remote interface

Spec, 9.11:

An entity object�s handle is an object that identifies the entity object on a network. A client that has a
reference to an entity object�s remote interface can obtain the entity object�s handle by invoking the
getHandle() method on the remote interface. The getHandle() method is only available on the
remote interface.
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Severin St�ckli:

(3) handles are never used for local objects. Handles are only available on the remote interface



Yes, of course. Sorry for that. I realized that I put a [Local] that I shouldn't few moments after posting, but was too lazy to go and edit the post again, as the main subject was referring to synchronization and not local or remote. That said, to answer to your question, I would never pass a reference to an entity bean to a remote client. I would prefer to client to get the data itself, so that the container can ensure sync with the underlying persistent storage. If not, who is supposed to realize that sync? My class that passes the Handle to the remote client? I'd never do that...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic