[ 
https://issues.apache.org/cayenne/browse/CAY-949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrus Adamchik closed CAY-949.
-------------------------------

    Resolution: Fixed

This was closed for M3... somehow I forgot to close the jira... doing it now

> Factory for lifecycle listeners
> -------------------------------
>
>                 Key: CAY-949
>                 URL: https://issues.apache.org/cayenne/browse/CAY-949
>             Project: Cayenne
>          Issue Type: New Feature
>          Components: Cayenne JPA
>    Affects Versions: 3.0
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 3.0
>
>
> So far we've followed the JPA spec in Cayenne classic callbacks/listeners 
> implementation. I am using listeners extensively and till now I used to 
> install them in the code. Now that Modeler supports listeners, I discovered 
> that the default mechanism of listener instantiation 
> (Class.forName("listenerClass").newInstance()) is inadequate when a listener 
> has dependencies on its environment. I guess in the J2EE world the 
> dependencies are obtained via JNDI, but I wanted to use injection as a 
> cleaner approach (and to avoid setting up JNDI). 
> So... I wrote an extension point that would allow users to register a factory 
> object for creating the listeners:
> public interface EntityListenerFactory {
>     <T> T createListener(Class<T> listenerClass, ObjEntity entity);
> }
> This would support dependency injection (or any other environment specific 
> customization) of the listener objects, as well as using interfaces for the 
> listeners - something JPA does not support. So the same listener 
> configuration may be used with different implementations depending on some 
> app logic.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to