In Hibernate ORM, there is the notion of SessionFactory aware services (SessionFactoryServiceInitiator). We did not use it in OGM because we could not find a way to add new service initiators to the SessionFactoryServiceRegistry. Instead we used a SessionFactory observer to listen to the SessionFactory creation and use that hook to create these SF aware services.
There is a more standard way in Hibernate ORM. The trick is to override (in OgmIntegrator) SessionFactoryServiceRegistryFactoryInitiator like we do override others and change the list of services at will.
This approach will also be useful for the metamodel work.
Bonus point if we can devise an easier solution to register these SF aware ServiceInitiator. non SF aware service initiators can be registered by an Integrator implementing ServiceContributingIntegrator.
We could imagine a SessionFactoryServiceContributingIntegrator. any better solution? A potential complex point is to see if the Integrator is still around when the SesisonFactoryServiceRegistry is created.