Hi,

I'd like to register a listener and filter at application startup on a Cayenne 
data domain (a non-Tapestry filter/listener). I need to add something like 
these two lines somewhere:

runtime.getDataDomain().getEntityResolver().getCallbackRegistry().addListener(new
 LastModifiedListener());
runtime.getDataDomain().addFilter(new ChangeSetFilter());

Since I use tapestry5-cayenne there's no easy way to do this, because I just 
add the dependency in my pom and then inject the cayenne object context (or 
data context). I never do something like 
ServerRuntime runtime = new ServerRuntime("cayenne.xml"); ......

In the TapestryCayenneModule there's a ObjectContextProvider service with a 
private field runtime. I tried to override this service and add my two lines 
but got a conflict because in TapestryCayenneModule.java the service is not 
only bound but also overridden.

Then I tried to inject this service into my startup method and access the 
DataDomain object via the ObjectContext returned by a method of the service. 
But nothing worked. I guess it's too early, the service isn't available yet. 
The actual exception was 
Registry Error invoking service contribution method 
de.myapp.services.AppModule.registerCayenneFilterAndListener(): Unable to 
delegate method invocation to property 'request' of <Proxy 
for RequestGlobals(org.apache.tapestry5.services.RequestGlobals)>, because the 
property is null.

I also tried a method with @Startup and 
ServerRuntime runtime = new ServerRuntime("cayenne.xml"); ......
but then the data domain in the TapestryCayenneModule doesn't know about any 
listener or filter.


So is there any way to access a field of a service from another module on 
startup?
Or is there something like the @Startup annotation but at a later point of 
time, after the services are available?

Initially I asked on the cayenne mailing list 
http://mail-archives.apache.org/mod_mbox/cayenne-user/201211.mbox/%[email protected]%3E
but then it became more of a tapestry question.


Cheers,
-bjello



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to