• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javax.ejb.Handle

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

After some reading, I still cannot understand why we need the javax.ejb.Handle ? What is wrong with keeping a reference to an EJB object?

What am I missing here?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not an expert in the field, but I think that when you are using remote beans, the reference the client owns is not the same as what the server owns.
A Handle uniquely identifies a bean in the server. You could save a Handle, reuse it later, and you'll get the same bean (as long as it's still alive).
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
'Satou ' is right, actually EJBHandle is Serializable object which can be presisted and can be used in future to call ejb methods.
It is use to avoid re lookup/re creation of EJObject.
Only problem with EJBHandle is maintaing the reference to non-existing proxy on the server (i.e. associated ejb bean instance is no longer there) than it will throw runtime exception.
Hope that this will make clear picture to you.

Cheers,
Sunil Dixit
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it now. I was reading "Mastering EJB" and the code example there looked as if the remote client gets the stub (of an EJB object), then it gets the handle from the stub, then they said that the client "waits some time", then it uses the handle to get a stub again.

The misleading thing in that description was that the client looks as if he does all those actions in one long process. Which is not. Had he done, there was no use to get a handle... he could have just keep using the stub, which is what my original question was asking.

What that they actually meant is that "wait some time" means: the client ends the process, emails himself the stub, turn off the computer at home, go to bed, wake up in the morning, go to work, gets the stub from his email, and gets a (new) stub to his good old bean from last night.

But why bothering to write it? Why not misleading the readers and let them sweat?

As for what Sunil Dixit wrote:

It is use to avoid re lookup/re creation of EJObject.



Not as far as I know. What that the handle gives that guy from his work computer he cannot get with any lookup if the bean is stateful session bean. His only hope to get exactly his bean from last night (or more precisely, some bean with last night's state), is to use the handle.
reply
    Bookmark Topic Watch Topic
  • New Topic