• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getEJBObject method

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is getEJBObject mehtod is from the EJBObject interface??
If it is then can anyone tell me what is its return type??? an object of remote or bean
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Home Object can be obtained from the EJBObject Interface, but not the EJBObject from the home interface directly. There is no API call to do that. We need to use create() or find() methods for it.
Coming to ur question :
getEJBObject() is a method defined in the EntityContext and SessionContext interface. It is not defined in the MessageDrivenContext interface as MDBs do not have any home/remote.
The return type is EJBObject interface. At run time, this will be an Object created by the Container that implements the EJBObject interface.
(EJBObject interface extends from Remote interface)
I suggest that you download a copy of the J2EE API documentation onto your machine and refer to it...
http://java.sun.com/j2ee/1.4/docs/api/index.html
http://java.sun.com/j2ee/1.4/download.html#apidocs
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vish pretty much nailed it. This can be useful for calling another method on the same bean and have it still go through all the standard container checks (CMT, security, etc).
For example, if you have two exposed business methods on a single session bean, if you call one method from the other using standard Java calling semantics -- this.otherBusinessMethod() -- the container won't get involved. If otherBusinessMethod is marked as "RequiresNew" for CMT or requires a security check, these will not be enforced as you're bypassing the containers bean proxy.
Instead, you should acquire a remote or local reference to the bean (this will look just like the reference acquired by the original caller) using context.getEJBObject() and then call the other method using it.

In the code above, "context" is an instance member of the bean class that is set in the setSessionContext() callback method. I find the following code handy for this. I put it in each session bean class. Since it's typed for the bean, it cannot go in the superclass.

[ March 04, 2004: Message edited by: David Harkness ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic