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 ]