aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes About EJB Handles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "About EJB Handles" Watch "About EJB Handles" New topic
Author

About EJB Handles

Yogananth
Greenhorn

Joined: Jan 11, 2005
Posts: 6
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?


------------------------<br />Regards,<br />Yogananth<br />SCJP 1.4, SCWCD 1.4<br />------------------------
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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!


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Subhash Bhushan C
Ranch Hand

Joined: Jan 27, 2005
Posts: 106
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.


Regards,<br />Subhash Bhushan.
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
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.


James Carman, President<br />Carman Consulting, Inc.
Yogananth
Greenhorn

Joined: Jan 11, 2005
Posts: 6
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

Joined: Feb 20, 2001
Posts: 580
Maybe the Stub class uses a Handle to persist itself?
Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: About EJB Handles