• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Narrowing

 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a small question regarding the narrow method of the PortableRemoteObject Class.

Which steps are required to get the remote component interface using the EJBObject method of the SessionContext interface ?

In my point of view I have to narrow the object (because it is a remote stub) and then cast it. According to the mock we have only to cast it... SO what is true ? I am really surprise about this answer, if anybody can highlight me, it will be greatful.

Thanks for your help,
Adri
 
Soni Prasad
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is the container's responsibility to provide you EJBObject from EJBContext so that only cast should be needed.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may help.
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very much for replying.

I thought remote stubs must always be narrowed when you want to use the methods of the remote/home interface.

I dont see why we don't need a narrow for the method getEJBObject() from the SessionContext. For the following example I can understand that we have to make a narrow (to the remote component interface):

MyComp comp = (MyComp) PortableRemoteObject.narrow(MySessionBean.getHandle().getObject(), MyComp.class);

So why is rule not applicable for getEJBOject in the SessionContext interafce ? I am kind of confused... is the getEJBOject method an exception to the rule or am I misunderstanding this concept ?

Thanks a lot buddy,
Adri
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you Roger,

If I follow your explainations, it means there are few cases in which we need to narrow:

* JNDI lookups of the remote home interface (your initial lookup of the bean's home).
* All calls to getHandle() or getHomeHandle()
* All other remote calls to business method returning a remote stub, and only if the return type of the method is not the same as the interface type to which you intend to cast it.

(I took partially this from your Post)

Therefore we do not need to narrow the result of getEJBObject and getEJBHome from the SessionContext (a cast is enough)?

I am right ?

Thanks to confirm guys, it will relieve my mind

Adri
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Soni could you tell me on what you base your affirmation ?

Thx,
Adri
 
Soni Prasad
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
go through specs it is written there clearly, right now I unable to recall the page number...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic