• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

casting problem

 
Jingyi Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic