HHH-12947 Remove need for BootstrapContext where it's unused

This commit is contained in:
Sanne Grinovero 2018-09-04 13:35:50 +01:00
parent b3c2c2fe47
commit 8cf00ad3fd
10 changed files with 5 additions and 58 deletions

View File

@ -42,13 +42,10 @@ import org.hibernate.tuple.entity.EntityTuplizerFactory;
*/
public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplementor {
private final MetadataImplementor metadata;
private final BootstrapContext bootstrapContext;
private final SessionFactoryOptionsBuilder optionsBuilder;
public SessionFactoryBuilderImpl(MetadataImplementor metadata, BootstrapContext bootstrapContext) {
this.metadata = metadata;
this.bootstrapContext = bootstrapContext;
this.optionsBuilder = new SessionFactoryOptionsBuilder(
metadata.getMetadataBuildingOptions().getServiceRegistry(),
bootstrapContext
@ -436,11 +433,6 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
return this;
}
@Override
public void markAsJpaBootstrap() {
this.bootstrapContext.markAsJpaBootstrap();
}
@Override
public void disableRefreshDetachedEntity() {
this.optionsBuilder.disableRefreshDetachedEntity();
@ -464,7 +456,7 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
@Override
public SessionFactory build() {
metadata.validate();
return new SessionFactoryImpl( bootstrapContext, metadata, buildSessionFactoryOptions() );
return new SessionFactoryImpl( metadata, buildSessionFactoryOptions() );
}
@Override

View File

@ -25,12 +25,6 @@ public abstract class AbstractDelegatingSessionFactoryBuilderImplementor<T exten
return (SessionFactoryBuilderImplementor) super.delegate();
}
@SuppressWarnings("deprecation")
@Override
public void markAsJpaBootstrap() {
delegate().markAsJpaBootstrap();
}
@Override
public void disableJtaTransactionAccess() {
delegate().disableJtaTransactionAccess();

View File

@ -15,20 +15,6 @@ import org.hibernate.boot.SessionFactoryBuilder;
* @author Steve Ebersole
*/
public interface SessionFactoryBuilderImplementor extends SessionFactoryBuilder {
/**
* Indicates that the SessionFactory being built comes from JPA bootstrapping.
* Internally {@code false} is the assumed value. We only need to call this to
* mark that as true.
*
* @deprecated (since 5.2) In fact added in 5.2 as part of consolidating JPA support
* directly into Hibernate contracts (SessionFactory, Session); intended to provide
* transition help in cases where we need to know the difference in JPA/native use for
* various reasons.
* Use {@link BootstrapContext#markAsJpaBootstrap()}
*
*/
@Deprecated
void markAsJpaBootstrap();
void disableJtaTransactionAccess();

View File

@ -50,7 +50,6 @@ import org.hibernate.TypeHelper;
import org.hibernate.boot.cfgxml.spi.CfgXmlAccessService;
import org.hibernate.boot.cfgxml.spi.LoadedConfig;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.spi.CacheImplementor;
@ -191,7 +190,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
private final transient TypeHelper typeHelper;
public SessionFactoryImpl(
final BootstrapContext bootstrapContext,
final MetadataImplementor metadata,
SessionFactoryOptions options) {
LOG.debug( "Building session factory" );
@ -202,7 +200,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
this.serviceRegistry = options
.getServiceRegistry()
.getService( SessionFactoryServiceRegistryFactory.class )
.buildServiceRegistry( this, bootstrapContext, options );
.buildServiceRegistry( this, options );
prepareEventListeners( metadata );
@ -291,7 +289,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
LOG.debug( "Instantiated session factory" );
this.metamodel = metadata.getTypeConfiguration().scope( this , bootstrapContext);
this.metamodel = metadata.getTypeConfiguration().scope( this );
( (MetamodelImpl) this.metamodel ).initialize(
metadata,
determineJpaMetaModelPopulationSetting( properties )

View File

@ -9,7 +9,6 @@ package org.hibernate.service.internal;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.service.Service;
@ -62,14 +61,12 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS
public SessionFactoryServiceRegistry buildSessionFactoryServiceRegistry(
SessionFactoryImplementor sessionFactory,
BootstrapContext bootstrapContext,
SessionFactoryOptions options) {
return new SessionFactoryServiceRegistryImpl(
parent,
initiators,
providedServices,
sessionFactory,
bootstrapContext,
options
);
}

View File

@ -7,7 +7,6 @@
package org.hibernate.service.internal;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@ -31,7 +30,6 @@ public class SessionFactoryServiceRegistryFactoryImpl implements SessionFactoryS
@Override
public SessionFactoryServiceRegistry buildServiceRegistry(
SessionFactoryImplementor sessionFactory,
BootstrapContext bootstrapContext,
SessionFactoryOptions options) {
final ClassLoaderService cls = options.getServiceRegistry().getService( ClassLoaderService.class );
final SessionFactoryServiceRegistryBuilderImpl builder = new SessionFactoryServiceRegistryBuilderImpl( theBasicServiceRegistry );
@ -40,6 +38,6 @@ public class SessionFactoryServiceRegistryFactoryImpl implements SessionFactoryS
contributor.contribute( builder );
}
return builder.buildSessionFactoryServiceRegistry( sessionFactory, bootstrapContext, options );
return builder.buildSessionFactoryServiceRegistry( sessionFactory, options );
}
}

View File

@ -8,7 +8,6 @@ package org.hibernate.service.internal;
import java.util.List;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -33,21 +32,17 @@ public class SessionFactoryServiceRegistryImpl
private final SessionFactoryImplementor sessionFactory;
private EventListenerRegistry cachedEventListenerRegistry;
private final BootstrapContext bootstrapContext;
@SuppressWarnings( {"unchecked"})
public SessionFactoryServiceRegistryImpl(
ServiceRegistryImplementor parent,
List<SessionFactoryServiceInitiator> initiators,
List<ProvidedService> providedServices,
SessionFactoryImplementor sessionFactory,
BootstrapContext bootstrapContext,
SessionFactoryOptions sessionFactoryOptions) {
super( parent );
this.sessionFactory = sessionFactory;
this.sessionFactoryOptions = sessionFactoryOptions;
this.bootstrapContext = bootstrapContext;
// for now, just use the standard initiator list
for ( SessionFactoryServiceInitiator initiator : initiators ) {
@ -58,8 +53,6 @@ public class SessionFactoryServiceRegistryImpl
for ( ProvidedService providedService : providedServices ) {
createServiceBinding( providedService );
}
bootstrapContext = null;
}
@Override
@ -75,11 +68,6 @@ public class SessionFactoryServiceRegistryImpl
}
}
@Override
public BootstrapContext getBootstrapContext() {
return bootstrapContext;
}
@Override
public SessionFactoryImplementor getSessionFactory() {
return sessionFactory;

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.service.spi;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -14,7 +13,6 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
* @author Steve Ebersole
*/
public interface SessionFactoryServiceInitiatorContext {
BootstrapContext getBootstrapContext();
SessionFactoryImplementor getSessionFactory();
SessionFactoryOptions getSessionFactoryOptions();
ServiceRegistryImplementor getServiceRegistry();

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.service.spi;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.service.Service;
@ -26,14 +25,12 @@ public interface SessionFactoryServiceRegistryFactory extends Service {
* for grabbing a reference for later use. However, care should be taken when invoking on
* the session factory until after it has been fully initialized.
* @param sessionFactoryOptions The build options.
* @param bootstrapContext The (still active) BootstrapContext.
* @param sessionFactoryOptions The build options.
*
* @return The registry
*/
SessionFactoryServiceRegistry buildServiceRegistry(
SessionFactoryImplementor sessionFactory,
BootstrapContext bootstrapContext,
SessionFactoryOptions sessionFactoryOptions);
}

View File

@ -17,7 +17,6 @@ import org.hibernate.Incubating;
import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver;
import org.hibernate.boot.cfgxml.spi.CfgXmlAccessService;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.id.uuid.LocalObjectUuidHelper;
@ -143,7 +142,7 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
scope.setMetadataBuildingContext( metadataBuildingContext );
}
public MetamodelImplementor scope(SessionFactoryImplementor sessionFactory, BootstrapContext bootstrapContext) {
public MetamodelImplementor scope(SessionFactoryImplementor sessionFactory) {
log.debugf( "Scoping TypeConfiguration [%s] to SessionFactoryImpl [%s]", this, sessionFactory );
for ( Map.Entry<String, String> importEntry : scope.metadataBuildingContext.getMetadataCollector().getImports().entrySet() ) {