Probably lots of way to do that, but I typically use code similar to this:
        public void 
contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer>
configurer,
                        @InjectService("DefaultHibernateConfigurer") 
HibernateConfigurer
defaultHibernateConfigurer) {

                class RunModeDependentHibernateConfigurer implements 
HibernateConfigurer {

                        public void configure(org.hibernate.cfg.Configuration 
configuration) {
                                if (productionMode ||
"true".equals(System.getProperty(Symbols.FORCE_PERSISTENT_DB)))
configuration
                                                
.configure("/hibernate-production.cfg.xml");
                                else 
configuration.configure("/hibernate-test.cfg.xml");
                        }
                }
                ;
                configurer.add(productionMode == true ? "production" : "test", 
new
RunModeDependentHibernateConfigurer(), "before:*");
        }

Even if you are not contributing custom configurers, you could just
inject the services you need and do your stuff with them within
contributeHibernateSessionSource().

Kalle


On Mon, Jan 3, 2011 at 10:55 AM, Mark <mark-li...@xeric.net> wrote:
> I am using the hibernate module and it works well.  However, I need to
> do some stuff before Hibernate loads.  I have tried using the @Startup
> annotation on a method in AppModule, but this appears to run after
> Hibernate starts up.  I have also tried something like:
>
>    public static void
> contributeRegistryStartup(OrderedConfiguration<Runnable>
> configuration)
>    {
>      configuration.add("dbMigration", new Runnable() {
>
>        public void run() {
>            //code that needs to run before Hibernate
>        }
>      });
>    }
>
> But that also seems to run after Hibernate has started.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to