jsr345-experts@ejb-spec.java.net

[jsr345-experts] Re: Non-reentrant instances and getBusinessObject

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Mon, 10 Oct 2011 17:09:39 -0700

Coming back to it ... We need to fix both :(.

Our CTS people clarified that "These tests verify the equals semantics
of client view, including checking equals among results from various
sessioinContext.getBusinessObject(class) calls."

I also checked with Linda and she confirmed that for the SLSB, any
instance can be used to execute the call on the returned reference. But
SFSB and singletons need to be addressed explicitly.

Experts,

Please let me know if you agree to add this statement to 4.3.3The
SessionContext Interface (EJB 3.2 working draft) after the existing
paragraph:

"The getBusinessObject(Class businessInterface)method returns a business
object reference to the session bean’s business interface or
no-interface view. In the case of the no-interface view, the argument is
of the type of the bean class. Only session beans with an EJB 3.x
business interface or no-interface view are permitted to call this method."

=========
If a business method is called on such reference from the same session
bean that called getBusinessObject method, unless the bean supports
reentrant calls, a container will use a different stateless session bean
instance either from the pool or will create a new instance to serve the
request. For the stateful session beans and singleton session beans the
returned reference will be for the same instance, and the bean must
support reentrant calls to call a method on it.
=========

thanks,
-marina


Carlo de Wolf wrote:
> An associated TCK test is com.sun.ts.tests.ejb30.lite.view.equals.
>
> Carlo
>
> On 09/30/2011 10:55 PM, Carlo de Wolf wrote:
>> I would certainly hope not that the javadoc is wrong. But I do agree
>> that the spec only hints at the identity of the business object
>> returned, the API docs are correct. That needs more amplification in
>> the spec.
>>
>> EJB 3.2 Draft 2011-05-05 16.2.2:
>> The enterprise bean must not attempt to pass this as an argument or
>> method result. The
>> enterprise bean must pass the result of
>> SessionContext.getBusinessObject, Ses-
>> sionContext.getEJBObject, SessionContext.getEJBLocalObject, Enti-
>> tyContext.getEJBObject, or EntityContext.getEJBLocalObject instead.
>>
>> Carlo
>>
>> On 09/30/2011 09:59 PM, Marina Vatkina wrote:
>>> I think the javadoc (if you are looking at it) is misleading.
>>> ctx.getBusinessObject returns you an instance, not this instance.
>>>
>>> You can even do this inside that bean
>>>
>>> @EJB MyLocalView meLocal;
>>> @EJB MyRemoteView meRemote;
>>>
>>> -marina
>>>
>>> Carlo de Wolf wrote:
>>>> In light of EJB 3.2 Draft 2011-05-05 4.10.13 Non-reentrant is the
>>>> following allowed in a session bean:
>>>>
>>>> 1. public String aMethod() { return
>>>> ctx.getBusinessObject(MyLocalView.class).doSomething(); } ?
>>>>
>>>> 2. public String bMethod() { return
>>>> ctx.getBusinessObject(MyRemoteView.class).doSomething(); } ?
>>>>
>>>> Carlo
>>
>