Thanks Lance, got it working.

public interface HibernateInitializer {
    public void initialize();
}

public class HibernateInitializerImpl implements HibernateInitializer {

    @Inject
    SolrIndexer solrIndexer;

    @Inject
    private HibernateSessionSource hss;

    @Override
    public void initialize() {
EventListenerRegistry registry = ((SessionFactoryImpl) hss.getSessionFactory()).getServiceRegistry().getService(
                EventListenerRegistry.class);
registry.getEventListenerGroup(EventType.PERSIST).appendListener(new MyPersistEventListener(solrIndexer));
    }

}

in AppModule
public static void bind(ServiceBinder binder) {
  //...
  binder.bind(HibernateInitializer.class, HibernateInitializerImpl.class);
}

@Startup
public static void initHibernateEventListener(Logger logger, HibernateInitializer hi) {
  hi.initialize();
}

Not sure if this the best way to go, but it works :).


On 17.12.2013 11:03, Lance Java wrote:
I'm not convinced you should be doing this in a HibernateConfigurer since
you need the SessionSource. HibernateConfigurers are executed before the
SessionFactory exists.

Can you add the listener in a @Startup method or some @EagerLoad service?



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

Reply via email to