cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devnull2...@gmx.de
Subject Re: check for changes before commit
Date Fri, 23 Nov 2012 18:12:24 GMT
> @Startup
> public void init(ObjectContextProvider provider) { ... }

I tried it this way but sadly I get the same exception on startup as before.

> (Don't mix DataContext with ObjectContextProvider.)

"DataContext" in my example was just the id of the service.

>From TapestryCayenneModule:
public static void bind(ServiceBinder binder) 
{
    binder.bind(ObjectContextProvider.class, DataContextProviderImpl.class)
        .withMarker(Cayenne.class).withId("DataContext");
}                                  ^^^^^^^^^^^^^^^^^^^^^

I'd tried it several ways
@InjectService("ObjectContextProvider") ObjectContextProvider provider
    --> no service with this name

@InjectService("DataContext") ObjectContextProvider provider
--> TapestryIOCModule.RegistryStartup Construction of service RegistryStartup failed: org.apache.tapestry5.ioc.internal.OperationException

@Inject ObjectContextProvider provider
--> same exception as above

ObjectContextProvider provider
--> same exception as above

On the tapestry web page you linked they say
"RegistryStartup occurs after eager loaded services are instantiated."
I guess this means it occurs before non-eager services are instantiated and ObjectContextProvider
isn't eager loaded. So I'm afraid it's just not available yet.


> > public void init() {
> >     ServerRuntime runtime = new ServerRuntime("cayenne.xml");
> > 
> runtime.getDataDomain().getEntityResolver().getCallbackRegistry().addListener(new
> > LastModifiedListener());
> >     runtime.getDataDomain().addFilter(new ChangeSetFilter());
> > }
> >

This way there are no exceptions on startup. I put in some logging and the size of runtime.getDataDomain().getFilters()
in the init method is 1 (no surprise). I couldn't find a method to get the number of listeners.

But the lastmodified date isn't set when I edit something. So I added some logging output
in the insertAudit(DataObject object) of the LastModifiedListener and in the page class in
onSuccessFromEditForm(). The insertAudit method never logs anything, i. e. it doesn't get
called. And in the page class dataContext.getParentDataDomain().getFilters().size() is 0.
Too bad.



Mime
View raw message