You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Otho <ta...@googlemail.com> on 2009/06/21 16:39:41 UTC
T5 Override of HibernateSessionSource
Hi all,
I want to override HibernateSessionSource with a
SpringHibernateSessionSource, where I configure Hibernate via Spring.
For that I need a hold on the ApplicationContext service in the
contributeServiceOverride method.
My understanding was, that I can inject dependencies via a public
constructor like this:
public class MyAppModule()
{
private static ApplicationContext context;
public MyAppModule(@Inject ApplicationContext ctx)
{
context = ctx;
}
public static void contributeServiceOverride(MappedConfiguration<Class,
Object> configuration)
{
configuration.add(HibernateSessionSource.class, new
SpringHibernateSessionSourceImpl(context));
}
...
}
But that doesn't work, since the context is null when I call the constructor
in the ServiceOverride contribution. In contrast to that a method like this
in the same MyAppModule works as expected.
@EagerLoad
public MyAppInitializer buildMyAppInitializer()
{
return new MyAppInitializerImpl(context);
}
Could someone hint me as to how get the contribution working?
Regards,
Otho