Skip to content

Commit 09fbe7d

Browse files
committed
some further minor cleanups
1 parent 51c5af7 commit 09fbe7d

File tree

18 files changed

+239
-248
lines changed

18 files changed

+239
-248
lines changed

hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import java.util.ArrayList;
88
import java.util.Collection;
9-
import java.util.Collections;
109
import java.util.HashMap;
1110
import java.util.Map;
1211

@@ -41,6 +40,9 @@
4140

4241
import org.jboss.logging.Logger;
4342

43+
import static java.util.Collections.emptyList;
44+
import static java.util.Collections.emptyMap;
45+
4446
/**
4547
* @author Andrea Boriero
4648
*/
@@ -75,42 +77,42 @@ public class BootstrapContextImpl implements BootstrapContext {
7577
private HashMap<Class<?>, ConverterDescriptor> attributeConverterDescriptorMap;
7678
private ArrayList<CacheRegionDefinition> cacheRegionDefinitions;
7779
private final ManagedTypeRepresentationResolver representationStrategySelector;
78-
private ConfigurationService configurationService;
80+
private final ConfigurationService configurationService;
7981

8082
public BootstrapContextImpl(
8183
StandardServiceRegistry serviceRegistry,
8284
MetadataBuildingOptions metadataBuildingOptions) {
8385
this.serviceRegistry = serviceRegistry;
84-
this.classmateContext = new ClassmateContext();
8586
this.metadataBuildingOptions = metadataBuildingOptions;
8687

87-
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
88-
this.classLoaderAccess = new ClassLoaderAccessImpl( classLoaderService );
88+
classmateContext = new ClassmateContext();
89+
classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
90+
classLoaderAccess = new ClassLoaderAccessImpl( classLoaderService );
8991

9092
final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class );
9193
final ConfigurationService configService = serviceRegistry.requireService( ConfigurationService.class );
9294

93-
this.jpaCompliance = new MutableJpaComplianceImpl( configService.getSettings() );
94-
this.scanOptions = new StandardScanOptions(
95+
jpaCompliance = new MutableJpaComplianceImpl( configService.getSettings() );
96+
scanOptions = new StandardScanOptions(
9597
(String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ),
9698
false
9799
);
98100

99101
// ScanEnvironment must be set explicitly
100-
this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER );
101-
this.archiveDescriptorFactory = strategySelector.resolveStrategy(
102+
scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER );
103+
archiveDescriptorFactory = strategySelector.resolveStrategy(
102104
ArchiveDescriptorFactory.class,
103105
configService.getSettings().get( AvailableSettings.SCANNER_ARCHIVE_INTERPRETER )
104106
);
105107

106-
this.representationStrategySelector = ManagedTypeRepresentationResolverStandard.INSTANCE;
108+
representationStrategySelector = ManagedTypeRepresentationResolverStandard.INSTANCE;
107109

108-
this.typeConfiguration = new TypeConfiguration();
109-
this.beanInstanceProducer = new TypeBeanInstanceProducer( configService, serviceRegistry );
110-
this.sqmFunctionRegistry = new SqmFunctionRegistry();
110+
typeConfiguration = new TypeConfiguration();
111+
beanInstanceProducer = new TypeBeanInstanceProducer( configService, serviceRegistry );
112+
sqmFunctionRegistry = new SqmFunctionRegistry();
111113

112-
this.managedBeanRegistry = serviceRegistry.requireService( ManagedBeanRegistry.class );
113-
this.configurationService = serviceRegistry.requireService( ConfigurationService.class );
114+
managedBeanRegistry = serviceRegistry.requireService( ManagedBeanRegistry.class );
115+
configurationService = serviceRegistry.requireService( ConfigurationService.class );
114116
}
115117

116118
@Override
@@ -210,24 +212,24 @@ public Object getJandexView() {
210212

211213
@Override
212214
public Map<String, SqmFunctionDescriptor> getSqlFunctions() {
213-
return sqlFunctionMap == null ? Collections.emptyMap() : sqlFunctionMap;
215+
return sqlFunctionMap == null ? emptyMap() : sqlFunctionMap;
214216
}
215217

216218
@Override
217219
public Collection<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectList() {
218-
return auxiliaryDatabaseObjectList == null ? Collections.emptyList() : auxiliaryDatabaseObjectList;
220+
return auxiliaryDatabaseObjectList == null ? emptyList() : auxiliaryDatabaseObjectList;
219221
}
220222

221223
@Override
222224
public Collection<ConverterDescriptor> getAttributeConverters() {
223225
return attributeConverterDescriptorMap != null
224226
? attributeConverterDescriptorMap.values()
225-
: Collections.emptyList();
227+
: emptyList();
226228
}
227229

228230
@Override
229231
public Collection<CacheRegionDefinition> getCacheRegionDefinitions() {
230-
return cacheRegionDefinitions == null ? Collections.emptyList() : cacheRegionDefinitions;
232+
return cacheRegionDefinitions == null ? emptyList() : cacheRegionDefinitions;
231233
}
232234

233235
private final Map<String,BasicType<?>> adHocBasicTypeRegistrations = new HashMap<>();
@@ -281,12 +283,11 @@ public ManagedTypeRepresentationResolver getRepresentationStrategySelector() {
281283
// Mutations
282284

283285
public void addAttributeConverterDescriptor(ConverterDescriptor descriptor) {
284-
if ( this.attributeConverterDescriptorMap == null ) {
285-
this.attributeConverterDescriptorMap = new HashMap<>();
286+
if ( attributeConverterDescriptorMap == null ) {
287+
attributeConverterDescriptorMap = new HashMap<>();
286288
}
287289

288-
final Object old = this.attributeConverterDescriptorMap.put( descriptor.getAttributeConverterClass(), descriptor );
289-
290+
final Object old = attributeConverterDescriptorMap.put( descriptor.getAttributeConverterClass(), descriptor );
290291
if ( old != null ) {
291292
throw new AssertionFailure(
292293
String.format(
@@ -328,17 +329,17 @@ void injectJandexView(Object jandexView) {
328329
}
329330

330331
public void addSqlFunction(String functionName, SqmFunctionDescriptor function) {
331-
if ( this.sqlFunctionMap == null ) {
332-
this.sqlFunctionMap = new HashMap<>();
332+
if ( sqlFunctionMap == null ) {
333+
sqlFunctionMap = new HashMap<>();
333334
}
334-
this.sqlFunctionMap.put( functionName, function );
335+
sqlFunctionMap.put( functionName, function );
335336
}
336337

337338
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) {
338-
if ( this.auxiliaryDatabaseObjectList == null ) {
339-
this.auxiliaryDatabaseObjectList = new ArrayList<>();
339+
if ( auxiliaryDatabaseObjectList == null ) {
340+
auxiliaryDatabaseObjectList = new ArrayList<>();
340341
}
341-
this.auxiliaryDatabaseObjectList.add( auxiliaryDatabaseObject );
342+
auxiliaryDatabaseObjectList.add( auxiliaryDatabaseObject );
342343
}
343344

344345

hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import org.hibernate.boot.query.NamedNativeQueryDefinition;
7070
import org.hibernate.boot.query.NamedProcedureCallDefinition;
7171
import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
72-
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
7372
import org.hibernate.boot.spi.BootstrapContext;
7473
import org.hibernate.boot.spi.InFlightMetadataCollector;
7574
import org.hibernate.boot.spi.MetadataBuildingContext;
@@ -204,10 +203,10 @@ public InFlightMetadataCollectorImpl(
204203
this.sourceModelBuildingContext = sourceModelBuildingContext;
205204
this.options = options;
206205

207-
this.uuid = UUID.randomUUID();
206+
uuid = UUID.randomUUID();
208207

209-
this.globalRegistrations = new GlobalRegistrationsImpl( sourceModelBuildingContext, bootstrapContext );
210-
this.persistenceUnitMetadata = new PersistenceUnitMetadataImpl();
208+
globalRegistrations = new GlobalRegistrationsImpl( sourceModelBuildingContext, bootstrapContext );
209+
persistenceUnitMetadata = new PersistenceUnitMetadataImpl();
211210

212211
for ( Map.Entry<String, SqmFunctionDescriptor> sqlFunctionEntry : bootstrapContext.getSqlFunctions().entrySet() ) {
213212
if ( sqlFunctionMap == null ) {
@@ -220,20 +219,19 @@ public InFlightMetadataCollectorImpl(
220219

221220
bootstrapContext.getAuxiliaryDatabaseObjectList().forEach( getDatabase()::addAuxiliaryDatabaseObject );
222221

223-
configurationService = bootstrapContext.getServiceRegistry().requireService(ConfigurationService.class);
222+
configurationService = bootstrapContext.getConfigurationService();
224223
}
225224

226225
public InFlightMetadataCollectorImpl(BootstrapContext bootstrapContext, MetadataBuildingOptions options) {
227226
this( bootstrapContext, createModelBuildingContext( bootstrapContext ), options );
228227
}
229228

230229
private static SourceModelBuildingContext createModelBuildingContext(BootstrapContext bootstrapContext) {
231-
final ClassLoaderService classLoaderService = bootstrapContext.getClassLoaderService();
232-
final ClassLoaderServiceLoading classLoading = new ClassLoaderServiceLoading( classLoaderService );
230+
final ClassLoaderServiceLoading classLoading =
231+
new ClassLoaderServiceLoading( bootstrapContext.getClassLoaderService() );
233232

234233
final ModelsConfiguration modelsConfiguration = new ModelsConfiguration();
235-
modelsConfiguration.setClassLoading(classLoading);
236-
// modelsConfiguration.setExplicitContextProvider( );
234+
modelsConfiguration.setClassLoading( classLoading );
237235
modelsConfiguration.configValue( "hibernate.models.jandex.index", bootstrapContext.getJandexView() );
238236
modelsConfiguration.setRegistryPrimer( ModelsHelper::preFillRegistries );
239237
return modelsConfiguration.bootstrap();
@@ -283,7 +281,7 @@ public SqmFunctionRegistry getFunctionRegistry() {
283281
public Database getDatabase() {
284282
// important to delay this instantiation until as late as possible.
285283
if ( database == null ) {
286-
this.database = new Database( options );
284+
database = new Database( options );
287285
}
288286
return database;
289287
}

0 commit comments

Comments
 (0)