jsr338-experts@jpa-spec.java.net

[jsr338-experts] Re: Integration of EntityListeners Classes with CDI (Java EE 7)

From: Linda DeMichiel <linda.demichiel_at_oracle.com>
Date: Tue, 21 Jun 2011 13:50:02 -0700

Assuming you all have read the message from Pete Muir which I
forwarded earlier.....

Entity listeners are not container-managed objects in the sense of
EJBs or CDI managed beans, and do not have their own independent
component environment. They are managed by the persistence provider,
and when they are invoked within JavaEE their naming environment is
that of the calling component.

To support injection in them, they would presumably need to become
container-managed objects (as well), and we would need to define their
lifecycle, add support for PostConstruct, PreDestroy, etc.

While I think I can understand your motivation for wanting this
functionality, I'm not convinced of the tradeoff in terms of the
added complexity.

I'd like to hear from others on this point though.

thanks,

Linda


On 6/21/2011 5:18 AM, Adam Bien wrote:
> Hi *
>
> EntityListeners should be integrated with CDI / EJB 3.2. It means: Java EE 7 DI should work in EntityListener classes.
> An EntityListener could be annotated with @Singleton / @Stateless / @RequestScoped etc. (everything what is stateless)
>
> We should extend the sentence: "Entity listeners are stateless. The lifecycle of an entity listener is unspecified" at
> the page 95 of the Expert Group Draft 2. to "The lifecycle of an entity listener is unspecified in unmanaged
> environments. An EJB 3.2 @Stateless, @Singleton or CDI managed bean can also receive callback events",
>
> What do you think?
>
> adam