* @param datastoreType the configuration type representing the current datastore.
* @return a {@link GlobalContext} object
* @throws HibernateException in case the given configuration type isn't supported by the current datastore provider
*/
public <G extends GlobalContext<?, ?>, D extends DatastoreConfiguration<G>> G configureDatastore(Class<D> datastoreType) {
ResolvedType resolvedDatastoreType = typeResolver.resolve( datastoreType );
ResolvedType globalContextType = resolvedDatastoreType.typeParametersFor( DatastoreConfiguration.class ).get( 0 );
ConfigurationBuilderService configurationBuilderService = getSessionFactory()
.getServiceRegistry()
.getService( ConfigurationBuilderService.class );
GlobalContext<?, ?> globalContext = configurationBuilderService.getConfigurationBuilder();
if ( globalContextType.getErasedType().isInstance( globalContext ) ) {
@SuppressWarnings("unchecked")
G store = (G) globalContext;
return store;
}