• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Narrowing

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is the container's responsibility to provide you EJBObject from EJBContext so that only cast should be needed.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may help.
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
go through specs it is written there clearly, right now I unable to recall the page number...
 
reply
    Bookmark Topic Watch Topic
  • New Topic