On 29 juil. 2011, at 19:30, Linda DeMichiel wrote:
>>>
>>>
>>>>
>>>> The JPA 2.0 spec states that:
>>>>
>>>> "Entity listeners are stateless. The lifecycle of an entity listener is unspecified."
>>>>
>>>> Is that necessarily going to be useful for a listener subject to injection?
>>>>
>>>
>>> I'd like to have the group discuss what we say about the lifecycle issue. AFAICT, however,
>>> the safest approach seems to be the creation of listener instances per invocation.
>>
>> It is still useful even if the listener itself is stateless. Remember that while the listener context is handled by the JPA provider, the injected components them selves can be scoped. So to take Craig's example, you could get a listener injecting a component return the request scoped username.
>> In practice, this is implemented via proxying by CDI implementations.
>>
>
> Right, I was assuming that for proxyable objects. However, for dependent objects, does it or does
> it not make a difference as to whether the component that causes the listener to be instantiated
> is a different component from the one on whose behalf a given lifecycle callback occurs?
> I.e., does adding this functionality mean that we need to nail down more specifically what
> the lifetime of such an entity listener is?
I don't think so. But more eyeballs are necessary.
>
>
>> BTW we should mention that an EL cannot directly or indirectly inject the persistence context it comes from.
>
> Cannot or *should not*? I was assuming "should not".
yep "should not" or "must not" I keep forgetting this RFC