jsr345-experts@ejb-spec.java.net

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

From: Carlo de Wolf <cdewolf_at_redhat.com>
Date: Fri, 30 Sep 2011 22:55:53 +0200

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