Skip to content

Commit 5280e15

Browse files
dreab8sebersole
authored andcommitted
HHH-18522 Drop hard requirements on Jandex
1 parent cf0ab77 commit 5280e15

File tree

17 files changed

+41
-175
lines changed

17 files changed

+41
-175
lines changed

hibernate-core/src/main/java/org/hibernate/boot/MetadataBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.hibernate.type.BasicType;
2222
import org.hibernate.usertype.UserType;
2323

24-
import org.jboss.jandex.IndexView;
2524

2625
import jakarta.persistence.AttributeConverter;
2726
import jakarta.persistence.SharedCacheMode;
@@ -148,7 +147,7 @@ public interface MetadataBuilder {
148147
*
149148
* @return {@code this}, for method chaining
150149
*/
151-
MetadataBuilder applyIndexView(IndexView jandexView);
150+
MetadataBuilder applyIndexView(Object jandexView);
152151

153152
/**
154153
* Specify the options to be used in performing scanning.

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.hibernate.type.BasicType;
3939
import org.hibernate.type.spi.TypeConfiguration;
4040

41-
import org.jboss.jandex.IndexView;
4241
import org.jboss.logging.Logger;
4342

4443
/**
@@ -66,7 +65,7 @@ public class BootstrapContextImpl implements BootstrapContext {
6665
private Object scannerSetting;
6766
private ArchiveDescriptorFactory archiveDescriptorFactory;
6867

69-
private IndexView jandexView;
68+
private Object jandexView;
7069

7170
private HashMap<String,SqmFunctionDescriptor> sqlFunctionMap;
7271
private ArrayList<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
@@ -182,7 +181,7 @@ public Object getScanner() {
182181
}
183182

184183
@Override
185-
public IndexView getJandexView() {
184+
public Object getJandexView() {
186185
return jandexView;
187186
}
188187

@@ -300,7 +299,7 @@ void injectArchiveDescriptorFactory(ArchiveDescriptorFactory factory) {
300299
this.archiveDescriptorFactory = factory;
301300
}
302301

303-
void injectJandexView(IndexView jandexView) {
302+
void injectJandexView(Object jandexView) {
304303
log.debugf( "Injecting Jandex IndexView [%s] into BootstrapContext; was [%s]", jandexView, this.jandexView );
305304
this.jandexView = jandexView;
306305
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
import org.hibernate.usertype.CompositeUserType;
8787
import org.hibernate.usertype.UserType;
8888

89-
import org.jboss.jandex.IndexView;
9089

9190
import jakarta.persistence.AttributeConverter;
9291
import jakarta.persistence.ConstraintMode;
@@ -213,7 +212,7 @@ public MetadataBuilder applyAccessType(AccessType implicitCacheAccessType) {
213212
}
214213

215214
@Override
216-
public MetadataBuilder applyIndexView(IndexView jandexView) {
215+
public MetadataBuilder applyIndexView(Object jandexView) {
217216
this.bootstrapContext.injectJandexView( jandexView );
218217
return this;
219218
}

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@
7171
import org.hibernate.engine.jdbc.spi.JdbcServices;
7272
import org.hibernate.mapping.Table;
7373
import org.hibernate.models.internal.MutableClassDetailsRegistry;
74-
import org.hibernate.models.jandex.internal.JandexIndexerHelper;
7574
import org.hibernate.models.spi.ClassDetails;
7675
import org.hibernate.models.spi.ClassDetailsRegistry;
77-
import org.hibernate.models.spi.ClassLoading;
7876
import org.hibernate.models.spi.SourceModelBuildingContext;
7977
import org.hibernate.type.BasicType;
8078
import org.hibernate.type.BasicTypeRegistry;
@@ -99,9 +97,6 @@
9997
import org.hibernate.type.spi.TypeConfiguration;
10098
import org.hibernate.usertype.CompositeUserType;
10199

102-
import org.jboss.jandex.CompositeIndex;
103-
import org.jboss.jandex.IndexView;
104-
import org.jboss.jandex.Indexer;
105100

106101
import jakarta.persistence.AttributeConverter;
107102

@@ -401,10 +396,6 @@ public static DomainModelSource processManagedResources(
401396
} );
402397
managedResources.getAnnotatedClassReferences().forEach( (clazz) -> allKnownClassNames.add( clazz.getName() ) );
403398

404-
// At this point we know all managed class names across all sources.
405-
// Resolve the Jandex Index and build the SourceModelBuildingContext.
406-
final IndexView jandexIndex = resolveJandexIndex( allKnownClassNames, bootstrapContext.getJandexView(), sourceModelBuildingContext.getClassLoading() );
407-
408399
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409400
// - process metadata-complete XML
410401
// - collect overlay XML
@@ -427,7 +418,6 @@ public static DomainModelSource processManagedResources(
427418
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
428419
areIdGeneratorsGlobal,
429420
metadataCollector.getGlobalRegistrations(),
430-
jandexIndex,
431421
sourceModelBuildingContext
432422
);
433423

@@ -461,7 +451,6 @@ public static DomainModelSource processManagedResources(
461451

462452
return new DomainModelSource(
463453
classDetailsRegistry,
464-
jandexIndex,
465454
allKnownClassNames,
466455
modelCategorizationCollector.getGlobalRegistrations(),
467456
rootMappingDefaults,
@@ -494,31 +483,6 @@ private static void applyKnownClass(
494483
}
495484
}
496485

497-
public static IndexView resolveJandexIndex(
498-
List<String> allKnownClassNames,
499-
IndexView suppliedJandexIndex,
500-
ClassLoading classLoading) {
501-
// todo : we could build a new Jandex (Composite)Index that includes the `managedResources#getAnnotatedClassNames`
502-
// and all classes from `managedResources#getXmlMappingBindings`. Only really worth it in the case
503-
// of runtime enhancement. This would definitely need to be toggle-able.
504-
// +
505-
// For now, let's not as it does not matter for this PoC
506-
if ( 1 == 1 ) {
507-
return suppliedJandexIndex;
508-
}
509-
510-
final Indexer jandexIndexer = new Indexer();
511-
for ( String knownClassName : allKnownClassNames ) {
512-
JandexIndexerHelper.apply( knownClassName, jandexIndexer, classLoading );
513-
}
514-
515-
if ( suppliedJandexIndex == null ) {
516-
return jandexIndexer.complete();
517-
}
518-
519-
return CompositeIndex.create( suppliedJandexIndex, jandexIndexer.complete() );
520-
}
521-
522486
private static void processAdditionalMappingContributions(
523487
InFlightMetadataCollectorImpl metadataCollector,
524488
MetadataBuildingOptions options,

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/DomainModelSource.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,23 @@
1414
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
1515
import org.hibernate.models.spi.ClassDetailsRegistry;
1616

17-
import org.jboss.jandex.IndexView;
18-
1917
/**
2018
* @author Steve Ebersole
2119
*/
2220
public class DomainModelSource {
2321
private final ClassDetailsRegistry classDetailsRegistry;
24-
private final IndexView jandexIndex;
2522
private final GlobalRegistrations globalRegistrations;
2623
private final RootMappingDefaults effectiveMappingDefaults;
2724
private final PersistenceUnitMetadata persistenceUnitMetadata;
2825
private final List<String> allKnownClassNames;
2926

3027
public DomainModelSource(
3128
ClassDetailsRegistry classDetailsRegistry,
32-
IndexView jandexIndex,
3329
List<String> allKnownClassNames,
3430
GlobalRegistrations globalRegistrations,
3531
RootMappingDefaults effectiveMappingDefaults,
3632
PersistenceUnitMetadata persistenceUnitMetadata) {
3733
this.classDetailsRegistry = classDetailsRegistry;
38-
this.jandexIndex = jandexIndex;
3934
this.allKnownClassNames = allKnownClassNames;
4035
this.globalRegistrations = globalRegistrations;
4136
this.effectiveMappingDefaults = effectiveMappingDefaults;
@@ -46,10 +41,6 @@ public ClassDetailsRegistry getClassDetailsRegistry() {
4641
return classDetailsRegistry;
4742
}
4843

49-
public IndexView getJandexIndex() {
50-
return jandexIndex;
51-
}
52-
5344
public GlobalRegistrations getGlobalRegistrations() {
5445
return globalRegistrations;
5546
}

hibernate-core/src/main/java/org/hibernate/boot/models/categorize/internal/CategorizedDomainModelImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import org.hibernate.models.spi.ClassDetails;
1616
import org.hibernate.models.spi.ClassDetailsRegistry;
1717

18-
import org.jboss.jandex.IndexView;
19-
2018
/**
2119
* @author Steve Ebersole
2220
*/
@@ -28,13 +26,11 @@ public class CategorizedDomainModelImpl implements CategorizedDomainModel {
2826

2927
private final ClassDetailsRegistry classDetailsRegistry;
3028
private final AnnotationDescriptorRegistry annotationDescriptorRegistry;
31-
private final IndexView jandexIndex;
3229
private final PersistenceUnitMetadata persistenceUnitMetadata;
3330

3431
public CategorizedDomainModelImpl(
3532
ClassDetailsRegistry classDetailsRegistry,
3633
AnnotationDescriptorRegistry annotationDescriptorRegistry,
37-
IndexView jandexIndex,
3834
PersistenceUnitMetadata persistenceUnitMetadata,
3935
Set<EntityHierarchy> entityHierarchies,
4036
Map<String, ClassDetails> mappedSuperclasses,
@@ -47,7 +43,6 @@ public CategorizedDomainModelImpl(
4743
this.mappedSuperclasses = mappedSuperclasses;
4844
this.embeddables = embeddables;
4945
this.globalRegistrations = globalRegistrations;
50-
this.jandexIndex = jandexIndex;
5146
}
5247

5348
@Override
@@ -60,11 +55,6 @@ public AnnotationDescriptorRegistry getAnnotationDescriptorRegistry() {
6055
return annotationDescriptorRegistry;
6156
}
6257

63-
@Override
64-
public IndexView getJandexIndex() {
65-
return jandexIndex;
66-
}
67-
6858
@Override
6959
public PersistenceUnitMetadata getPersistenceUnitMetadata() {
7060
return persistenceUnitMetadata;

hibernate-core/src/main/java/org/hibernate/boot/models/categorize/spi/CategorizedDomainModel.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import org.hibernate.models.spi.ClassDetails;
1616
import org.hibernate.models.spi.ClassDetailsRegistry;
1717

18-
import org.jboss.jandex.IndexView;
19-
2018
/**
2119
* The application's domain model, understood at a very rudimentary level - we know
2220
* a class is an entity, a mapped-superclass, ... And we know about persistent attributes,
@@ -38,8 +36,6 @@ public interface CategorizedDomainModel {
3836
*/
3937
AnnotationDescriptorRegistry getAnnotationDescriptorRegistry();
4038

41-
IndexView getJandexIndex();
42-
4339
PersistenceUnitMetadata getPersistenceUnitMetadata();
4440

4541
/**

hibernate-core/src/main/java/org/hibernate/boot/models/categorize/spi/ManagedResourcesProcessor.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,9 @@
3030
import org.hibernate.boot.spi.BootstrapContext;
3131
import org.hibernate.boot.spi.MetadataBuildingOptions;
3232
import org.hibernate.models.internal.BasicModelBuildingContextImpl;
33-
import org.hibernate.models.jandex.internal.JandexIndexerHelper;
3433
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
3534
import org.hibernate.models.spi.ClassDetails;
3635
import org.hibernate.models.spi.ClassDetailsRegistry;
37-
import org.hibernate.models.spi.ClassLoading;
38-
39-
import org.jboss.jandex.CompositeIndex;
40-
import org.jboss.jandex.IndexView;
41-
import org.jboss.jandex.Indexer;
4236

4337
import static org.hibernate.boot.models.categorize.internal.EntityHierarchyBuilder.createEntityHierarchies;
4438
import static org.hibernate.internal.util.collections.CollectionHelper.mutableJoin;
@@ -100,7 +94,6 @@ public static CategorizedDomainModel processManagedResources(
10094

10195
// At this point we know all managed class names across all sources.
10296
// Resolve the Jandex Index and build the SourceModelBuildingContext.
103-
final IndexView jandexIndex = resolveJandexIndex( allKnownClassNames, bootstrapContext.getJandexView(), classLoading );
10497
final BasicModelBuildingContextImpl sourceModelBuildingContext = new BasicModelBuildingContextImpl(
10598
classLoading,
10699
ModelsHelper::preFillRegistries
@@ -131,7 +124,6 @@ public static CategorizedDomainModel processManagedResources(
131124
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
132125
areIdGeneratorsGlobal,
133126
globalRegistrations,
134-
jandexIndex,
135127
sourceModelBuildingContext
136128
);
137129

@@ -222,31 +214,6 @@ private static void warnAboutUnusedMappedSuperclasses(Map<String, ClassDetails>
222214
}
223215
}
224216

225-
public static IndexView resolveJandexIndex(
226-
List<String> allKnownClassNames,
227-
IndexView suppliedJandexIndex,
228-
ClassLoading classLoading) {
229-
// todo : we could build a new Jandex (Composite)Index that includes the `managedResources#getAnnotatedClassNames`
230-
// and all classes from `managedResources#getXmlMappingBindings`. Only really worth it in the case
231-
// of runtime enhancement. This would definitely need to be toggle-able.
232-
// +
233-
// For now, let's not as it does not matter for this PoC
234-
if ( 1 == 1 ) {
235-
return suppliedJandexIndex;
236-
}
237-
238-
final Indexer jandexIndexer = new Indexer();
239-
for ( String knownClassName : allKnownClassNames ) {
240-
JandexIndexerHelper.apply( knownClassName, jandexIndexer, classLoading );
241-
}
242-
243-
if ( suppliedJandexIndex == null ) {
244-
return jandexIndexer.complete();
245-
}
246-
247-
return CompositeIndex.create( suppliedJandexIndex, jandexIndexer.complete() );
248-
}
249-
250217
/**
251218
* For testing use only
252219
*/

hibernate-core/src/main/java/org/hibernate/boot/models/internal/DomainModelCategorizationCollector.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import org.hibernate.models.spi.ClassDetailsRegistry;
2525
import org.hibernate.models.spi.SourceModelBuildingContext;
2626

27-
import org.jboss.jandex.IndexView;
28-
2927
import jakarta.persistence.AttributeConverter;
3028
import jakarta.persistence.Converter;
3129
import jakarta.persistence.Embeddable;
@@ -40,7 +38,6 @@
4038

4139
public class DomainModelCategorizationCollector {
4240
private final boolean areIdGeneratorsGlobal;
43-
private final IndexView jandexIndex;
4441

4542
private final GlobalRegistrationsImpl globalRegistrations;
4643
private final SourceModelBuildingContext modelsContext;
@@ -52,10 +49,8 @@ public class DomainModelCategorizationCollector {
5249
public DomainModelCategorizationCollector(
5350
boolean areIdGeneratorsGlobal,
5451
GlobalRegistrations globalRegistrations,
55-
IndexView jandexIndex,
5652
SourceModelBuildingContext modelsContext) {
5753
this.areIdGeneratorsGlobal = areIdGeneratorsGlobal;
58-
this.jandexIndex = jandexIndex;
5954
this.globalRegistrations = (GlobalRegistrationsImpl) globalRegistrations;
6055
this.modelsContext = modelsContext;
6156
}
@@ -176,7 +171,6 @@ public CategorizedDomainModel createResult(
176171
return new CategorizedDomainModelImpl(
177172
classDetailsRegistry,
178173
annotationDescriptorRegistry,
179-
jandexIndex,
180174
persistenceUnitMetadata,
181175
entityHierarchies,
182176
mappedSuperclasses,

0 commit comments

Comments
 (0)