I'm quickly running out of ideas, but perhaps one of these two would work
to make sure the ObjectContextProvider is available up-front:
#1 Use an AppModule constructor
public class AppModule
{
private final ObjectContextProvider objectContextProvider;
public AppModule(ObjectContextProvider objectContextProvider)
{
this.objectContextProvider = objectContextProvider;
}
@Startup { ... }
}
#2 Use @Inject
public class AppModule
{
@Inject
private ObjectContextProvider objectContextProvider;
@Startup { ... }
}
If neither of those work, perhaps the T5 list would be more helpful. I'm
pretty sure Robert Ziegler, who wrote the T5-Cayenne module, follows that
list.
mrg
On Fri, Nov 23, 2012 at 1:12 PM, <[email protected]> wrote:
> > @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.
>
>
>