This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJBs and EJBObject

 
AnaB SuarezF
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a fundamental doubts about EJB and the stub instance returned back to the client.
Let's consider the following scenario, we've got a client calling "create" on a Home interface of an EJB. After that, the container will create and EJBObject instance (which implements the remote interface and hides all the network hassle for us and blah, blah, blah, ...). Is a reference to this instance what the cliente gets back? and then it will use this to access the business methods (calls which will be delegated to the real bean taken from a pool of beans).
My doubt is when in the client code we have this:

ConverterHome home = (ConverterHome) PortableRemoteObject.narrow(ref, ConverterHome.class);

Converter currencyConverter = home.create();

is currencyConverter a real reference to the instance that the container creates of type EJBObject??

Thanks!
 
Henrique Ordine
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again AnaB,

I don't think so. I think it's a reference to the stub.

P.S. I haven't got much to do at work today.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not only with EJB, even in RMI also, when you get reference to remote object, it not a real one. you always get proxy(stub) to it which hide network complexity and act like a real remote object.
 
Satish Kumar J
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please go through Head First EJB
All your doubts will be clarified.

--- Satish
 
Muhammad Asif
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you understand the basics of RMI, there are two types of objects created
Stubs -> Helper on Client Side
Skeleton -> Helper on Server Side

Stub Communicates with skeleton.

The reference that a client gets to work with is for the stub which does all the work for you. (Communication, Marshalling, Unmarshalling)
 
AnaB SuarezF
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much for all your answers.
So if I understand correctly, in the case of EJBs, the following instances will be created:

* an EJBHome instance (which lives in the container)
* an EJBObject instance (which lives in the container)
* an EJB bean instance, or a pool of them (which lives in the container)
* a skeleton (which lives in the container)
* a stub (which lives in the client machine)

Am I right? Thanks again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic