users@javaee-spec.java.net

[javaee-spec users] Fwd: [cdi-dev] Fwd: [jsr338-experts] Integration of EntityListeners Classes with CDI (Java EE 7)

From: Pete Muir <pmuir_at_bleepbleep.org.uk>
Date: Tue, 21 Jun 2011 15:25:30 +0100

FYI - feedback from CDI EG that clarifies the proposal.

Begin forwarded message:

> From: Pete Muir <pmuir_at_bleepbleep.org.uk>
> Date: 21 June 2011 15:11:27 GMT+01:00
> To: Jens Schumann <jens.schumann_at_openknowledge.de>
> Cc: CDI-Dev <cdi-dev_at_lists.jboss.org>
> Subject: Re: [cdi-dev] Fwd: [jsr338-experts] Integration of EntityListeners Classes with CDI (Java EE 7)
>
>
> On 21 Jun 2011, at 15:07, Jens Schumann wrote:
>
>> Pete:
>>
>>> Instead, I would propose that EntityListeners are simply added to
>>> the list of Java EE components which are able to be injected. This
>>> means they can be injected, but are not available for injection into
>>> other components.
>>
>>
>> Maybe I don't understand this because I am not a native English speaker;).
>>
>> Will your proposal support something like this:
>>
>> public class ModificationListener {
>>
>> @Inject
>> @Current
>> private User user;
>>
>> @PrePersist
>> public void onCreate(Object obj) {
>> if (obj instanceof ModifiableObject) {
>> // make use of current user
>> }
>> }
>> }
>>
>
> Yes, it would allow exactly this. What it won't allow is the converse:
>
> class User {
>
> @Inject ModificationListener listener
>
> ...
>
> }
>
> As I don't believe this has any meaning :-)
>
> In Java EE spec speak, we can achieve this by making EntityListener a Java EE component (as a side effect, this would also allow @Resource and @EJB injection).
>
>
>> Right now I have use the BeanManager within the listener to achieve the
>> same result. Pretty inconvenient.
>
> Exactly.
> _______________________________________________
> cdi-dev mailing list
> cdi-dev_at_lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev