• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

EJB Handles  RSS feed

 
Sheriff
Posts: 3034
12
IntelliJ IDE Java Mac Python VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've always read that when passing around an EJBObject, you should pass its handle, not the object itself. I've dutifully followed this rule in my own coding. Now I've come into a project where they retrieve an EntityBean through a finder method, then proceed to pass it around freely, even through session bean calls that return it to a different JVM. As far as I can tell though, everything works fine. So, what's the point of using handles?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiding program setting,such as Provider url,host,...,etc.
 
Ranch Hand
Posts: 8934
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Handles are serializable and consume less memory
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are passing the ejb reference amongst "normal" java classes then this is probably OK.
The Handle is serializable and thus is good for stuffing in a cache or something like HttpSession. It is also useful to pass to remote objects ("over the wire" to another machine").
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For what it's worth, you can use HomeHandles in a modified version of the EJBHomeFactory pattern when you have (for instance) a web container and an EJB container in separate processes or on separate nodes which may be started and stopped separately as the HomeHandle is valid for separate runs of the EJB container whereas the EJBHome reference is not.
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:
Handles are serializable and consume less memory



Handle is an interface. How can you serialize
it? What really serialized is the EJBObject.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It makes no difference whether Handle is an interface, you are serializing the class that implements that interface not the interface itself. For the record EJBObject is an interface also.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
I'm slightly confused now,
EJBObject implements java.rmi.Remote, whereas Handle implements java.io.Serializable.
Knowing that you can only pass either primitive values (ie int, float, double...) or serializable objects to remote objects (ie EJBs), would I be right to say that if you want to pass an EJB to another EJB (in another JVM), I cannot pass the EJBObject (it is not serializable) but I can pass the Handle?
If the above is right, how do you pass the remote interface to another EJB?
Eduard
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!