Skip to content

Commit f25060e

Browse files
committed
clean up obsolete code in MetadataBuildingProcess
1 parent 22aba27 commit f25060e

File tree

1 file changed

+58
-86
lines changed

1 file changed

+58
-86
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java

Lines changed: 58 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.hibernate.boot.model.source.internal.hbm.ModelBinder;
5252
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
5353
import org.hibernate.boot.models.internal.DomainModelCategorizationCollector;
54-
import org.hibernate.boot.models.internal.OrmAnnotationHelper;
5554
import org.hibernate.boot.models.xml.spi.XmlPreProcessingResult;
5655
import org.hibernate.boot.models.xml.spi.XmlPreProcessor;
5756
import org.hibernate.boot.models.xml.spi.XmlProcessingResult;
@@ -73,14 +72,10 @@
7372
import org.hibernate.engine.config.spi.StandardConverters;
7473
import org.hibernate.engine.jdbc.spi.JdbcServices;
7574
import org.hibernate.mapping.Table;
76-
import org.hibernate.models.internal.jandex.JandexClassDetails;
7775
import org.hibernate.models.internal.jandex.JandexIndexerHelper;
78-
import org.hibernate.models.internal.jdk.JdkBuilders;
79-
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
8076
import org.hibernate.models.spi.ClassDetails;
8177
import org.hibernate.models.spi.ClassDetailsRegistry;
8278
import org.hibernate.models.spi.ClassLoading;
83-
import org.hibernate.models.spi.RegistryPrimer;
8479
import org.hibernate.models.spi.SourceModelBuildingContext;
8580
import org.hibernate.type.BasicType;
8681
import org.hibernate.type.BasicTypeRegistry;
@@ -101,11 +96,9 @@
10196
import org.hibernate.type.spi.TypeConfiguration;
10297
import org.hibernate.usertype.CompositeUserType;
10398

104-
import org.jboss.jandex.ClassInfo;
10599
import org.jboss.jandex.CompositeIndex;
106100
import org.jboss.jandex.IndexView;
107101
import org.jboss.jandex.Indexer;
108-
import org.jboss.logging.Logger;
109102

110103
import jakarta.persistence.AttributeConverter;
111104

@@ -135,7 +128,6 @@
135128
* @author Steve Ebersole
136129
*/
137130
public class MetadataBuildingProcess {
138-
private static final Logger log = Logger.getLogger( MetadataBuildingProcess.class );
139131

140132
/**
141133
* Unified single phase for MetadataSources to Metadata process
@@ -221,16 +213,14 @@ public static MetadataImplementor complete(
221213
// Set up the processors and start binding
222214
// NOTE : this becomes even more simplified after we move purely
223215
// to unified model
224-
final IndexView jandexView = domainModelSource.getJandexIndex();
216+
// final IndexView jandexView = domainModelSource.getJandexIndex();
225217

226218
coordinateProcessors(
227219
managedResources,
228220
options,
229221
rootMetadataBuildingContext,
230222
domainModelSource,
231-
classLoaderService,
232-
metadataCollector,
233-
jandexView
223+
metadataCollector
234224
);
235225

236226
processAdditionalMappingContributions( metadataCollector, options, classLoaderService, rootMetadataBuildingContext );
@@ -245,19 +235,18 @@ private static void coordinateProcessors(
245235
MetadataBuildingOptions options,
246236
MetadataBuildingContextRootImpl rootMetadataBuildingContext,
247237
DomainModelSource domainModelSource,
248-
ClassLoaderService classLoaderService,
249-
InFlightMetadataCollectorImpl metadataCollector,
250-
IndexView jandexView) {
238+
InFlightMetadataCollectorImpl metadataCollector) {
251239
final MetadataSourceProcessor processor = new MetadataSourceProcessor() {
252240
private final MetadataSourceProcessor hbmProcessor = options.isXmlMappingEnabled()
253241
? new HbmMetadataSourceProcessorImpl( managedResources, rootMetadataBuildingContext )
254242
: new NoOpMetadataSourceProcessorImpl();
255243

256-
private final AnnotationMetadataSourceProcessorImpl annotationProcessor = new AnnotationMetadataSourceProcessorImpl(
257-
managedResources,
258-
domainModelSource,
259-
rootMetadataBuildingContext
260-
);
244+
private final AnnotationMetadataSourceProcessorImpl annotationProcessor =
245+
new AnnotationMetadataSourceProcessorImpl(
246+
managedResources,
247+
domainModelSource,
248+
rootMetadataBuildingContext
249+
);
261250

262251
@Override
263252
public void prepare() {
@@ -527,66 +516,51 @@ public static IndexView resolveJandexIndex(
527516

528517
return CompositeIndex.create( suppliedJandexIndex, jandexIndexer.complete() );
529518
}
530-
531-
public static void preFillRegistries(RegistryPrimer.Contributions contributions, SourceModelBuildingContext buildingContext) {
532-
OrmAnnotationHelper.forEachOrmAnnotation( contributions::registerAnnotation );
533-
534-
final IndexView jandexIndex = buildingContext.getJandexIndex();
535-
if ( jandexIndex == null ) {
536-
return;
537-
}
538-
539-
final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry();
540-
final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext.getAnnotationDescriptorRegistry();
541-
542-
for ( ClassInfo knownClass : jandexIndex.getKnownClasses() ) {
543-
final String className = knownClass.name().toString();
544-
545-
if ( knownClass.isAnnotation() ) {
546-
// it is always safe to load the annotation classes - we will never be enhancing them
547-
//noinspection rawtypes
548-
final Class annotationClass = buildingContext
549-
.getClassLoading()
550-
.classForName( className );
551-
//noinspection unchecked
552-
annotationDescriptorRegistry.resolveDescriptor(
553-
annotationClass,
554-
(t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext )
555-
);
556-
}
557-
558-
classDetailsRegistry.resolveClassDetails(
559-
className,
560-
(name) -> new JandexClassDetails( knownClass, buildingContext )
561-
);
562-
}
563-
}
519+
//
520+
// public static void preFillRegistries(RegistryPrimer.Contributions contributions, SourceModelBuildingContext buildingContext) {
521+
// OrmAnnotationHelper.forEachOrmAnnotation( contributions::registerAnnotation );
522+
//
523+
// final IndexView jandexIndex = buildingContext.getJandexIndex();
524+
// if ( jandexIndex == null ) {
525+
// return;
526+
// }
527+
//
528+
// final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry();
529+
// final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext.getAnnotationDescriptorRegistry();
530+
//
531+
// for ( ClassInfo knownClass : jandexIndex.getKnownClasses() ) {
532+
// final String className = knownClass.name().toString();
533+
//
534+
// if ( knownClass.isAnnotation() ) {
535+
// // it is always safe to load the annotation classes - we will never be enhancing them
536+
// //noinspection rawtypes
537+
// final Class annotationClass = buildingContext
538+
// .getClassLoading()
539+
// .classForName( className );
540+
// //noinspection unchecked
541+
// annotationDescriptorRegistry.resolveDescriptor(
542+
// annotationClass,
543+
// (t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext )
544+
// );
545+
// }
546+
//
547+
// classDetailsRegistry.resolveClassDetails(
548+
// className,
549+
// (name) -> new JandexClassDetails( knownClass, buildingContext )
550+
// );
551+
// }
552+
// }
564553

565554
private static void processAdditionalMappingContributions(
566555
InFlightMetadataCollectorImpl metadataCollector,
567556
MetadataBuildingOptions options,
568557
ClassLoaderService classLoaderService,
569558
MetadataBuildingContextRootImpl rootMetadataBuildingContext) {
570-
final MappingBinder mappingBinder;
571-
if ( options.isXmlMappingEnabled() ) {
572-
mappingBinder = new MappingBinder(
573-
classLoaderService,
574-
new MappingBinder.Options() {
575-
@Override
576-
public boolean validateMappings() {
577-
return false;
578-
}
579-
}
580-
);
581-
}
582-
else {
583-
mappingBinder = null;
584-
}
585559

586560
final AdditionalMappingContributionsImpl contributions = new AdditionalMappingContributionsImpl(
587561
metadataCollector,
588562
options,
589-
mappingBinder,
563+
options.isXmlMappingEnabled() ? new MappingBinder( classLoaderService, () -> false ) : null,
590564
rootMetadataBuildingContext
591565
);
592566

@@ -1016,29 +990,27 @@ private static void adaptTimestampTypesToDefaultTimeZoneStorage(
1016990
}
1017991

1018992
private static JdbcType getTimeWithTimeZoneOverride(MetadataBuildingOptions options, JdbcTypeRegistry jdbcTypeRegistry) {
1019-
switch ( options.getDefaultTimeZoneStorage() ) {
1020-
case NORMALIZE:
993+
return switch ( options.getDefaultTimeZoneStorage() ) {
994+
case NORMALIZE ->
1021995
// For NORMALIZE, we replace the standard types that use TIME_WITH_TIMEZONE to use TIME
1022-
return jdbcTypeRegistry.getDescriptor( Types.TIME );
1023-
case NORMALIZE_UTC:
996+
jdbcTypeRegistry.getDescriptor( Types.TIME );
997+
case NORMALIZE_UTC ->
1024998
// For NORMALIZE_UTC, we replace the standard types that use TIME_WITH_TIMEZONE to use TIME_UTC
1025-
return jdbcTypeRegistry.getDescriptor( SqlTypes.TIME_UTC );
1026-
default:
1027-
return null;
1028-
}
999+
jdbcTypeRegistry.getDescriptor( SqlTypes.TIME_UTC );
1000+
default -> null;
1001+
};
10291002
}
10301003

10311004
private static JdbcType getTimestampWithTimeZoneOverride(MetadataBuildingOptions options, JdbcTypeRegistry jdbcTypeRegistry) {
1032-
switch ( options.getDefaultTimeZoneStorage() ) {
1033-
case NORMALIZE:
1005+
return switch (options.getDefaultTimeZoneStorage()) {
1006+
case NORMALIZE ->
10341007
// For NORMALIZE, we replace the standard types that use TIMESTAMP_WITH_TIMEZONE to use TIMESTAMP
1035-
return jdbcTypeRegistry.getDescriptor( Types.TIMESTAMP );
1036-
case NORMALIZE_UTC:
1008+
jdbcTypeRegistry.getDescriptor( Types.TIMESTAMP );
1009+
case NORMALIZE_UTC ->
10371010
// For NORMALIZE_UTC, we replace the standard types that use TIMESTAMP_WITH_TIMEZONE to use TIMESTAMP_UTC
1038-
return jdbcTypeRegistry.getDescriptor( SqlTypes.TIMESTAMP_UTC );
1039-
default:
1040-
return null;
1041-
}
1011+
jdbcTypeRegistry.getDescriptor( SqlTypes.TIMESTAMP_UTC );
1012+
default -> null;
1013+
};
10421014
}
10431015

10441016
private static void addFallbackIfNecessary(

0 commit comments

Comments
 (0)