File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About EJB Handles

 
Yogananth
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since stub classes implements Serializable interface, it is possible to convert the stubs into stream and persist. And this provides us with the ability to save the Stub's of Home or Remote object. When we are able to do this, what is the need for the introduction of Handles in EJBs?
 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yoga
Welcome to JavaRanch.

Unfortunately your name doesn't gel well with our naming policy. Please take a quick look at the rules and edit your profile accordingly.

Thank you!
 
Subhash Bhushan C
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you can serialize the stub, that doesn't mean it's got enough information to get you back to the same EJB Object. When the stub comes over from the server, it's aready knowledgeable about how to contact a particular Remote object. When that stub is recreated, that exact Remote object might not even exist any longer.
The handle has the capability to communicate with the server and get back something that is just the same as the EJB Object you had before. In other words, it might not be the same EJB object, but the client will never be able to tell the difference.
 
James Carman
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to "persist" a remote reference to an EJB, use the handle of the EJBObject. With that, you can then re-establish the reference later.
 
Yogananth
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
My doubt is, why should we have a Handle object when the same functionality can be achieved through EJB Stub Objects?

Agni,
You have been telling that it is not possible for a persisted Remote Stub Object to communicate with Remote Object after Deserialization. But I don't think that would be the case. Since if an EJB Server tries to re-cycle its Remote Object, then this would render all the EJB clients to be Obsolete?

Thanks a lot for answering, Agni & James....

But still I feel I am yet to get an answer for my query... "What is the need for Handles when the same can be done even without it?"

Regards,
Yogananth
SCJP 1.4, SCWCD 1.4
 
James Carman
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the Stub class uses a Handle to persist itself?
 
Ghulam Rashid
Ranch Hand
Posts: 278
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since stub classes implements Serializable interface, it is possible to convert the stubs into stream and persist. And this provides us with the ability to save the Stub's of Home or Remote object. When we are able to do this, what is the need for the introduction of Handles in EJBs?


I believe we also do the same thing once we have Remote Object, getHandle() of the Handle class gives the reference to the current object, which we write to stream.

javax.ejb.Handle remoteHandle = ejbObject.getHandle(); // in your conext remoteHandle is mapped as stub
ObjectOutputStream stream = ...;
stream.writeObject(remoteHandle);

The whole idea I beleive is to shield the complexity from the application. Moreover, EJB specification prohibits file IO operation.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic