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).
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
Joined: Jan 29, 2005
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.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com