jsr345-experts@ejb-spec.java.net

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

From: David Blevins <david.blevins_at_gmail.com>
Date: Mon, 10 Oct 2011 18:57:03 -0700

On Oct 10, 2011, at 5:34 PM, Linda DeMichiel wrote:

> What I would expect is that if a subsequent invocation were made on
> the result of getBusinessObject, then:
>
> 1) for a stateless session bean, the invocation would be delivered
> to another stateless session bean instance.
> 2) for a stateful session bean or singleton session bean, the invocation
> would be delivered to the bean instance that returned the reference.

That matches my understanding.

In terms of practicality, I can't see any other semantics being useful. The method has little point unless you get the same stateful bean instance. If you did not, then all three scenarios would be the same as looking up the bean from JNDI.

The method is really only useful for stateful session beans.


-David

>
> On 10/10/2011 5:09 PM, Marina Vatkina wrote:
>> 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
>>>>
>>>