2014/2/11 Hardy Ferentschik <ha...@hibernate.org> > Hi, > > not sure whether this could work in your use case, but in Search we use a > SessionFactoryObserver. > We register the observer in Integrator#integrate with the > SessionFactoryImplementor. > Once the SessionFactory is completely build you get a callback into > SessionFactoryObserver#sessionFactoryCreated(). > > In Search we had the case that we did not want to complete bootstrapping > at the integrator phase. Instead we defer > this until the SessionFactory is completely build. > > Hope it helps. >
Yes, that helps indeed. Implementing my validation routine in such an observer works. I guess if needed, I even could implement support for the suggested service contract in OGM with help of an observer. Thanks! > > --Hardy > > > > On 11 Jan 2014, at 09:38, Gunnar Morling <gun...@hibernate.org> wrote: > > > Hi, > > > > Is there a way for services (living in the SF-scoped registry) to get > > notified when the session factory has been set up and perform some action > > using that completely initialized factory? > > > > Upon invocation of initiateService() of SessionFactoryServiceInitiator > > implementations, the passed factory is still under construction (the call > > originates from SessionFactoryImpl<init>), so I can't access all members. > > The same holds true for the StartStoppable contract in OGM which also > sees > > a session factory under construction. > > > > Now I could store the passed reference in a field and execute the > required > > logic (some sort of validation) later on. I only have no meaningful hook > to > > trigger such action exactly once. So I'd have to manage a flag to make > sure > > the action is only performed once. > > > > Is there a better way to achieve this? > > > > Would it make sense to provide an additional contract to notify services > > about session factory lifecycle events: > > > > public interface SessionFactoryLifecycleAware extends Service { > > > > void onSessionFactoryLifecycleEvent(SessionFactoryImplementor sfi, > > Event event); > > > > public enum Event { POST_START, PRE_STOP } > > } > > > > ? > > > > Thanks, > > > > --Gunnar > > _______________________________________________ > > hibernate-dev mailing list > > hibernate-dev@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev