I had some time today so I made an attempt at creating injectable
EntityListeners. After wandering for quite some time deep in the CDI land,
I had to pull out and decided that I really don't want to include all the
CDI container dependencies just make my entity listeners injectable. After
that, it was pretty simple although I had to use a provider (Eclipselink)
specific api:
ServerSession session = entityManager.unwrap(ServerSession.class);
session.setEntityListenerInjectionManager(new
EntityListenerInjectionManager() {...}
With a little advice, I can now have all my entity listeners available to
JPA and inject any tapestry services on them on via constructor injection
(that we all know and agree is far superior to setter/field injection...).
If they add this to the JPA api in a future version, I'll make a little
library for it.
Kalle
On Wed, Nov 13, 2013 at 9:24 AM, Kalle Korhonen
<[email protected]>wrote:
> Injectable listeners is only available in JPA 2.1. There was a thread
> earlier (started by me) on this. I want to carve out some time at some
> point to make it possible in Tapestry-ioc. If you are using EclipseLink and
> don't mind an ugly provider-specific hack, you could get some ideas from
> http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-jpa/src/main/java/org/tynamo/model/jpa/internal/ElasticSearchIndexMaintainer.java(see
> EclipseLinkDescriptorEventListener class and how it's used).
>
> Kalle
>
>
> On Wed, Nov 13, 2013 at 4:04 AM, Thiago H de Paula Figueiredo <
> [email protected]> wrote:
>
>> On Wed, 13 Nov 2013 08:38:05 -0200, Eugen <[email protected]> wrote:
>>
>> Hi,
>>>
>>
>> Hi!
>>
>>
>> it is possible to user service injections inside a @EntityListeners
>>> annotated class?
>>>
>>
>> If you manage to get it instantiated through Tapestry-IoC, yes.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>