aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Narrow Casting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Narrow Casting" Watch "Narrow Casting" New topic
Author

Narrow Casting

Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi,
Can one please clarify on why we will go for narrow casting for home stub. Is it like with narrow casting will get the stub that implements the interface ( home interface). Please clarify me with one example.

Thanks & Regards,
Parvathi.
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
Please note that Home is a remote object and you need a stub at the client side to communicate with it.Hence what we expect back is a stub object so we can communicate with the home.right.


With Regards,<br /> Rajan<br />"Java Rocks"
Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi,
When we register the home reference in the JNDI, it is the stub reference not the home object reference. Is it like, if we are refereing to any remote object reference in JNDI then we need to do a narrow casting instead of normal casting. Please correct if I am wrong any where.


Thanks & Regards,
Parvathi.
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
Originally posted by Parvathi G:
Hi,
When we register the home reference in the JNDI, it is the stub reference not the home object reference. Is it like, if we are refereing to any remote object reference in JNDI then we need to do a narrow casting instead of normal casting. Please correct if I am wrong any where.


Thanks & Regards,
Parvathi.


Where did you got the info that the home reference/object is registered in the JNDI? Is it in the spec.kindly mention the page number.Did you assumed it is home because of the client code?

When we are refering to any remote and if it is rmi then normal casting works.The reason for narrow casting here is for not only casting but also for doing certain other things.
Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi,
Please have look on the Head First EJB book from page number 91 (Chapter 2).


Thanks & Regards,
Parvathi.
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
hi,
what we are really registering in the JNDI is the AdviceBean with the name "advisor".if you see the client code in page no 57 we are doing a lookup with that name.

After being deployed the server seems to be creating a home object and registering with JNDI.My understanding is the stub might also created and associated with the jndi.when the client does a lookup the home stub is sent back.Otherwise what is the point of Home object? Where will it be? and what purpose it will be serving? It should be Home Object and not Home Object stub that will be registered with JNDI.Stub is basically for the client to communicate with the home object.stub acts as proxy for home object.isn't it.

so in the next step when we call create on the home,really we are calling create on the stub which communicates the call to the home object.
Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi..
Thanks for the Correction.
It is the Bean name what actually we refere through the JNDI.
And that reference is giving the home stub.
I actually made a conclusion depending on the diagaram.
Thanks a lot

Regards,
Parvathi.
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
Most Welcome.
[ November 02, 2006: Message edited by: Rajan Murugan ]
 
jQuery in Action, 2nd edition
 
subject: Narrow Casting