Hi David,
I was thinking on the lines that we will always have
java:comp/EJBContext in JNDI for the bean so we can enable the
setSessionContext callback only if the EJB implements the SessionBean
Interface in which case the callback will be called and the variable
initalized.Now resource-env-ref can be used to bind the SessionContext
to a custom location in JNDI and @ Resouce for injection. In all these
cases looking up java:comp/EJBContext will also get us the
SessionContext.
In a case where we do not extend from SessionBean and don't have any
resource-env-refs or annotations we can still lookup in
java:comp/EJBContext.
Is this approach acceptable? If not what should be the behaviour?
Thanks
Manu
On 1/13/07, David Blevins <[EMAIL PROTECTED]> wrote:
On Jan 12, 2007, at 9:58 AM, Manu George wrote:
> Hi Mohammad,
> Without the @Resource annotation itself it is
> getting injected. Is that the right behaviour? Setter injection needs
> to be specified using @Resource or in dd.But now it is injected
> irrespective of that. Is that the right behaviour?
It's not the right behavior. @Resource or the equivalent injection-
target xml declaration or implementing the SessionBean interface.
We could leave it as a convenience (provided the tck doesn't mind) or
yank it.
-David
>
> Thanks
> Manu
>
> On 1/12/07, Mohammad Nour El-Din <[EMAIL PROTECTED]> wrote:
>> Hi Manu...
>>
>> On 1/12/07, Manu George <[EMAIL PROTECTED]> wrote:
>> >
>> > Hi,
>> > A doubt on sessionContext
>> >
>> > The spec says
>> >
>> > 4.3.3 The SessionContext Interface
>> > If the bean specifies a dependency on the SessionContext
>> interface (or
>> > if the bean class implements
>> > the SessionBean interface), the container must provide the session
>> > bean instance with a SessionContext.
>> > This gives the session bean instance access to the instance's
>> context
>> > maintained by the
>> > container. The SessionContext interface has the following methods:
>> >
>> > Now does this mean that if we put a setSessionContext method in the
>> > bean the sessionContext should be injected irrespective of
>> whether the
>> > bean class implements
>> > the SessionBean interface? Currently that is how it is in
>> Openejb but
>> > still I wanted to confirm whether that is the behaviour
>> required. Same
>> > for MDB's as well.
>>
>>
>> Yes this is right, this is the setter injection, and you can have the
>> SessionContext field to be initialized to a SessionContext object
>> instance
>> by annotating it with the @Resource annotation, and you can
>> annotate the
>> setSessionContext method with the same annotation, but I don't
>> know the
>> status of the implementation for the annotated fields.
>>
>> thanks
>> > Manu
>> >
>>
>>
>>
>> --
>> Thanks
>> - Mohammad Nour
>>
>>
>