Really this is a question of sharing registries. Initially I designed registries with the thought of allowing them to be shared. What I mean is this:
BootstrapServiceRegistry bsr = ...;
StandardServiceRegistry ssr1 = new StandardServiceRegistryBuilder( bsr ).build();
StandardServiceRegistry ssr2 = new StandardServiceRegistryBuilder( bsr ).build();
The bsr registry instance gets reused, shared, as the parent of 2 other registries. The implication is that closing either ssr1 or ssr2 cannot automatically close bsr.
If we instead say that registries are not intended to be shared, then closing a registry could automatically "cascade" closing its parent. And further closing the SessionFactory could close its registry.
|