This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

casting problem

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can we deal with getEJBHome () and getEJBObject () in EJBContext interface? I mean how can we cast the general EJBHome and EJBOjbect to the application specific EJB home reference and EJB object reference.

EJBHome ejbo = context.getEJBHome ();
CartHome ch = (CartHome) ejbo;
// or CartHome ch = (CartHome) PortableRemoteObject.narrow ( ch, CartHome.class );

How about the EJBObject?

Thanks
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jingyi,

No need to perform type-narrowing of the object received from EJBContext. The following is sufficient enough:



That is what the spec says in regards to SessionContext (same is applicable to EntityContext)


7.11.10 SessionContext

The container must implement the SessionContext.getEJBObject() method such that the
bean instance can use the Java language cast to convert the returned value to the session bean�s remote
interface type. Specifically, the bean instance does not have to use the PortableRemoteObject.
narrow(...) method for the type conversion.




Hope it helps
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic