HHH-18522 Drop hard requirements on Jandex

This commit is contained in:
Andrea Boriero 2024-09-13 16:21:58 +02:00 committed by Steve Ebersole
parent cf0ab77cf2
commit 5280e15ba0
17 changed files with 41 additions and 175 deletions

View File

@ -21,7 +21,6 @@ import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.jboss.jandex.IndexView;
import jakarta.persistence.AttributeConverter; import jakarta.persistence.AttributeConverter;
import jakarta.persistence.SharedCacheMode; import jakarta.persistence.SharedCacheMode;
@ -148,7 +147,7 @@ public interface MetadataBuilder {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
MetadataBuilder applyIndexView(IndexView jandexView); MetadataBuilder applyIndexView(Object jandexView);
/** /**
* Specify the options to be used in performing scanning. * Specify the options to be used in performing scanning.

View File

@ -38,7 +38,6 @@ import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
@ -66,7 +65,7 @@ public class BootstrapContextImpl implements BootstrapContext {
private Object scannerSetting; private Object scannerSetting;
private ArchiveDescriptorFactory archiveDescriptorFactory; private ArchiveDescriptorFactory archiveDescriptorFactory;
private IndexView jandexView; private Object jandexView;
private HashMap<String,SqmFunctionDescriptor> sqlFunctionMap; private HashMap<String,SqmFunctionDescriptor> sqlFunctionMap;
private ArrayList<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList; private ArrayList<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
@ -182,7 +181,7 @@ public class BootstrapContextImpl implements BootstrapContext {
} }
@Override @Override
public IndexView getJandexView() { public Object getJandexView() {
return jandexView; return jandexView;
} }
@ -300,7 +299,7 @@ public class BootstrapContextImpl implements BootstrapContext {
this.archiveDescriptorFactory = factory; this.archiveDescriptorFactory = factory;
} }
void injectJandexView(IndexView jandexView) { void injectJandexView(Object jandexView) {
log.debugf( "Injecting Jandex IndexView [%s] into BootstrapContext; was [%s]", jandexView, this.jandexView ); log.debugf( "Injecting Jandex IndexView [%s] into BootstrapContext; was [%s]", jandexView, this.jandexView );
this.jandexView = jandexView; this.jandexView = jandexView;
} }

View File

@ -86,7 +86,6 @@ import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.usertype.CompositeUserType; import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.jboss.jandex.IndexView;
import jakarta.persistence.AttributeConverter; import jakarta.persistence.AttributeConverter;
import jakarta.persistence.ConstraintMode; import jakarta.persistence.ConstraintMode;
@ -213,7 +212,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
} }
@Override @Override
public MetadataBuilder applyIndexView(IndexView jandexView) { public MetadataBuilder applyIndexView(Object jandexView) {
this.bootstrapContext.injectJandexView( jandexView ); this.bootstrapContext.injectJandexView( jandexView );
return this; return this;
} }

View File

@ -71,10 +71,8 @@ import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.models.internal.MutableClassDetailsRegistry; import org.hibernate.models.internal.MutableClassDetailsRegistry;
import org.hibernate.models.jandex.internal.JandexIndexerHelper;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry; import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.ClassLoading;
import org.hibernate.models.spi.SourceModelBuildingContext; import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.BasicTypeRegistry; import org.hibernate.type.BasicTypeRegistry;
@ -99,9 +97,6 @@ import org.hibernate.type.internal.NamedBasicTypeImpl;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.usertype.CompositeUserType; import org.hibernate.usertype.CompositeUserType;
import org.jboss.jandex.CompositeIndex;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import jakarta.persistence.AttributeConverter; import jakarta.persistence.AttributeConverter;
@ -401,10 +396,6 @@ public class MetadataBuildingProcess {
} ); } );
managedResources.getAnnotatedClassReferences().forEach( (clazz) -> allKnownClassNames.add( clazz.getName() ) ); managedResources.getAnnotatedClassReferences().forEach( (clazz) -> allKnownClassNames.add( clazz.getName() ) );
// At this point we know all managed class names across all sources.
// Resolve the Jandex Index and build the SourceModelBuildingContext.
final IndexView jandexIndex = resolveJandexIndex( allKnownClassNames, bootstrapContext.getJandexView(), sourceModelBuildingContext.getClassLoading() );
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// - process metadata-complete XML // - process metadata-complete XML
// - collect overlay XML // - collect overlay XML
@ -427,7 +418,6 @@ public class MetadataBuildingProcess {
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector( final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
areIdGeneratorsGlobal, areIdGeneratorsGlobal,
metadataCollector.getGlobalRegistrations(), metadataCollector.getGlobalRegistrations(),
jandexIndex,
sourceModelBuildingContext sourceModelBuildingContext
); );
@ -461,7 +451,6 @@ public class MetadataBuildingProcess {
return new DomainModelSource( return new DomainModelSource(
classDetailsRegistry, classDetailsRegistry,
jandexIndex,
allKnownClassNames, allKnownClassNames,
modelCategorizationCollector.getGlobalRegistrations(), modelCategorizationCollector.getGlobalRegistrations(),
rootMappingDefaults, rootMappingDefaults,
@ -494,31 +483,6 @@ public class MetadataBuildingProcess {
} }
} }
public static IndexView resolveJandexIndex(
List<String> allKnownClassNames,
IndexView suppliedJandexIndex,
ClassLoading classLoading) {
// todo : we could build a new Jandex (Composite)Index that includes the `managedResources#getAnnotatedClassNames`
// and all classes from `managedResources#getXmlMappingBindings`. Only really worth it in the case
// of runtime enhancement. This would definitely need to be toggle-able.
// +
// For now, let's not as it does not matter for this PoC
if ( 1 == 1 ) {
return suppliedJandexIndex;
}
final Indexer jandexIndexer = new Indexer();
for ( String knownClassName : allKnownClassNames ) {
JandexIndexerHelper.apply( knownClassName, jandexIndexer, classLoading );
}
if ( suppliedJandexIndex == null ) {
return jandexIndexer.complete();
}
return CompositeIndex.create( suppliedJandexIndex, jandexIndexer.complete() );
}
private static void processAdditionalMappingContributions( private static void processAdditionalMappingContributions(
InFlightMetadataCollectorImpl metadataCollector, InFlightMetadataCollectorImpl metadataCollector,
MetadataBuildingOptions options, MetadataBuildingOptions options,

View File

@ -14,14 +14,11 @@ import org.hibernate.boot.models.spi.GlobalRegistrations;
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata; import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
import org.hibernate.models.spi.ClassDetailsRegistry; import org.hibernate.models.spi.ClassDetailsRegistry;
import org.jboss.jandex.IndexView;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class DomainModelSource { public class DomainModelSource {
private final ClassDetailsRegistry classDetailsRegistry; private final ClassDetailsRegistry classDetailsRegistry;
private final IndexView jandexIndex;
private final GlobalRegistrations globalRegistrations; private final GlobalRegistrations globalRegistrations;
private final RootMappingDefaults effectiveMappingDefaults; private final RootMappingDefaults effectiveMappingDefaults;
private final PersistenceUnitMetadata persistenceUnitMetadata; private final PersistenceUnitMetadata persistenceUnitMetadata;
@ -29,13 +26,11 @@ public class DomainModelSource {
public DomainModelSource( public DomainModelSource(
ClassDetailsRegistry classDetailsRegistry, ClassDetailsRegistry classDetailsRegistry,
IndexView jandexIndex,
List<String> allKnownClassNames, List<String> allKnownClassNames,
GlobalRegistrations globalRegistrations, GlobalRegistrations globalRegistrations,
RootMappingDefaults effectiveMappingDefaults, RootMappingDefaults effectiveMappingDefaults,
PersistenceUnitMetadata persistenceUnitMetadata) { PersistenceUnitMetadata persistenceUnitMetadata) {
this.classDetailsRegistry = classDetailsRegistry; this.classDetailsRegistry = classDetailsRegistry;
this.jandexIndex = jandexIndex;
this.allKnownClassNames = allKnownClassNames; this.allKnownClassNames = allKnownClassNames;
this.globalRegistrations = globalRegistrations; this.globalRegistrations = globalRegistrations;
this.effectiveMappingDefaults = effectiveMappingDefaults; this.effectiveMappingDefaults = effectiveMappingDefaults;
@ -46,10 +41,6 @@ public class DomainModelSource {
return classDetailsRegistry; return classDetailsRegistry;
} }
public IndexView getJandexIndex() {
return jandexIndex;
}
public GlobalRegistrations getGlobalRegistrations() { public GlobalRegistrations getGlobalRegistrations() {
return globalRegistrations; return globalRegistrations;
} }

View File

@ -15,8 +15,6 @@ import org.hibernate.models.spi.AnnotationDescriptorRegistry;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry; import org.hibernate.models.spi.ClassDetailsRegistry;
import org.jboss.jandex.IndexView;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@ -28,13 +26,11 @@ public class CategorizedDomainModelImpl implements CategorizedDomainModel {
private final ClassDetailsRegistry classDetailsRegistry; private final ClassDetailsRegistry classDetailsRegistry;
private final AnnotationDescriptorRegistry annotationDescriptorRegistry; private final AnnotationDescriptorRegistry annotationDescriptorRegistry;
private final IndexView jandexIndex;
private final PersistenceUnitMetadata persistenceUnitMetadata; private final PersistenceUnitMetadata persistenceUnitMetadata;
public CategorizedDomainModelImpl( public CategorizedDomainModelImpl(
ClassDetailsRegistry classDetailsRegistry, ClassDetailsRegistry classDetailsRegistry,
AnnotationDescriptorRegistry annotationDescriptorRegistry, AnnotationDescriptorRegistry annotationDescriptorRegistry,
IndexView jandexIndex,
PersistenceUnitMetadata persistenceUnitMetadata, PersistenceUnitMetadata persistenceUnitMetadata,
Set<EntityHierarchy> entityHierarchies, Set<EntityHierarchy> entityHierarchies,
Map<String, ClassDetails> mappedSuperclasses, Map<String, ClassDetails> mappedSuperclasses,
@ -47,7 +43,6 @@ public class CategorizedDomainModelImpl implements CategorizedDomainModel {
this.mappedSuperclasses = mappedSuperclasses; this.mappedSuperclasses = mappedSuperclasses;
this.embeddables = embeddables; this.embeddables = embeddables;
this.globalRegistrations = globalRegistrations; this.globalRegistrations = globalRegistrations;
this.jandexIndex = jandexIndex;
} }
@Override @Override
@ -60,11 +55,6 @@ public class CategorizedDomainModelImpl implements CategorizedDomainModel {
return annotationDescriptorRegistry; return annotationDescriptorRegistry;
} }
@Override
public IndexView getJandexIndex() {
return jandexIndex;
}
@Override @Override
public PersistenceUnitMetadata getPersistenceUnitMetadata() { public PersistenceUnitMetadata getPersistenceUnitMetadata() {
return persistenceUnitMetadata; return persistenceUnitMetadata;

View File

@ -15,8 +15,6 @@ import org.hibernate.models.spi.AnnotationDescriptorRegistry;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry; import org.hibernate.models.spi.ClassDetailsRegistry;
import org.jboss.jandex.IndexView;
/** /**
* The application's domain model, understood at a very rudimentary level - we know * The application's domain model, understood at a very rudimentary level - we know
* a class is an entity, a mapped-superclass, ... And we know about persistent attributes, * a class is an entity, a mapped-superclass, ... And we know about persistent attributes,
@ -38,8 +36,6 @@ public interface CategorizedDomainModel {
*/ */
AnnotationDescriptorRegistry getAnnotationDescriptorRegistry(); AnnotationDescriptorRegistry getAnnotationDescriptorRegistry();
IndexView getJandexIndex();
PersistenceUnitMetadata getPersistenceUnitMetadata(); PersistenceUnitMetadata getPersistenceUnitMetadata();
/** /**

View File

@ -30,15 +30,9 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingOptions; import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.models.internal.BasicModelBuildingContextImpl; import org.hibernate.models.internal.BasicModelBuildingContextImpl;
import org.hibernate.models.jandex.internal.JandexIndexerHelper;
import org.hibernate.models.spi.AnnotationDescriptorRegistry; import org.hibernate.models.spi.AnnotationDescriptorRegistry;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry; import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.ClassLoading;
import org.jboss.jandex.CompositeIndex;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import static org.hibernate.boot.models.categorize.internal.EntityHierarchyBuilder.createEntityHierarchies; import static org.hibernate.boot.models.categorize.internal.EntityHierarchyBuilder.createEntityHierarchies;
import static org.hibernate.internal.util.collections.CollectionHelper.mutableJoin; import static org.hibernate.internal.util.collections.CollectionHelper.mutableJoin;
@ -100,7 +94,6 @@ public class ManagedResourcesProcessor {
// At this point we know all managed class names across all sources. // At this point we know all managed class names across all sources.
// Resolve the Jandex Index and build the SourceModelBuildingContext. // Resolve the Jandex Index and build the SourceModelBuildingContext.
final IndexView jandexIndex = resolveJandexIndex( allKnownClassNames, bootstrapContext.getJandexView(), classLoading );
final BasicModelBuildingContextImpl sourceModelBuildingContext = new BasicModelBuildingContextImpl( final BasicModelBuildingContextImpl sourceModelBuildingContext = new BasicModelBuildingContextImpl(
classLoading, classLoading,
ModelsHelper::preFillRegistries ModelsHelper::preFillRegistries
@ -131,7 +124,6 @@ public class ManagedResourcesProcessor {
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector( final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
areIdGeneratorsGlobal, areIdGeneratorsGlobal,
globalRegistrations, globalRegistrations,
jandexIndex,
sourceModelBuildingContext sourceModelBuildingContext
); );
@ -222,31 +214,6 @@ public class ManagedResourcesProcessor {
} }
} }
public static IndexView resolveJandexIndex(
List<String> allKnownClassNames,
IndexView suppliedJandexIndex,
ClassLoading classLoading) {
// todo : we could build a new Jandex (Composite)Index that includes the `managedResources#getAnnotatedClassNames`
// and all classes from `managedResources#getXmlMappingBindings`. Only really worth it in the case
// of runtime enhancement. This would definitely need to be toggle-able.
// +
// For now, let's not as it does not matter for this PoC
if ( 1 == 1 ) {
return suppliedJandexIndex;
}
final Indexer jandexIndexer = new Indexer();
for ( String knownClassName : allKnownClassNames ) {
JandexIndexerHelper.apply( knownClassName, jandexIndexer, classLoading );
}
if ( suppliedJandexIndex == null ) {
return jandexIndexer.complete();
}
return CompositeIndex.create( suppliedJandexIndex, jandexIndexer.complete() );
}
/** /**
* For testing use only * For testing use only
*/ */

View File

@ -24,8 +24,6 @@ import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry; import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.SourceModelBuildingContext; import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.IndexView;
import jakarta.persistence.AttributeConverter; import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter; import jakarta.persistence.Converter;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
@ -40,7 +38,6 @@ import jakarta.persistence.MappedSuperclass;
public class DomainModelCategorizationCollector { public class DomainModelCategorizationCollector {
private final boolean areIdGeneratorsGlobal; private final boolean areIdGeneratorsGlobal;
private final IndexView jandexIndex;
private final GlobalRegistrationsImpl globalRegistrations; private final GlobalRegistrationsImpl globalRegistrations;
private final SourceModelBuildingContext modelsContext; private final SourceModelBuildingContext modelsContext;
@ -52,10 +49,8 @@ public class DomainModelCategorizationCollector {
public DomainModelCategorizationCollector( public DomainModelCategorizationCollector(
boolean areIdGeneratorsGlobal, boolean areIdGeneratorsGlobal,
GlobalRegistrations globalRegistrations, GlobalRegistrations globalRegistrations,
IndexView jandexIndex,
SourceModelBuildingContext modelsContext) { SourceModelBuildingContext modelsContext) {
this.areIdGeneratorsGlobal = areIdGeneratorsGlobal; this.areIdGeneratorsGlobal = areIdGeneratorsGlobal;
this.jandexIndex = jandexIndex;
this.globalRegistrations = (GlobalRegistrationsImpl) globalRegistrations; this.globalRegistrations = (GlobalRegistrationsImpl) globalRegistrations;
this.modelsContext = modelsContext; this.modelsContext = modelsContext;
} }
@ -176,7 +171,6 @@ public class DomainModelCategorizationCollector {
return new CategorizedDomainModelImpl( return new CategorizedDomainModelImpl(
classDetailsRegistry, classDetailsRegistry,
annotationDescriptorRegistry, annotationDescriptorRegistry,
jandexIndex,
persistenceUnitMetadata, persistenceUnitMetadata,
entityHierarchies, entityHierarchies,
mappedSuperclasses, mappedSuperclasses,

View File

@ -8,17 +8,11 @@ import java.util.function.Supplier;
import org.hibernate.annotations.TenantId; import org.hibernate.annotations.TenantId;
import org.hibernate.models.internal.MutableClassDetailsRegistry; import org.hibernate.models.internal.MutableClassDetailsRegistry;
import org.hibernate.models.internal.jdk.JdkBuilders;
import org.hibernate.models.jandex.internal.JandexClassDetails;
import org.hibernate.models.jandex.spi.JandexModelBuildingContext;
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry; import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.RegistryPrimer; import org.hibernate.models.spi.RegistryPrimer;
import org.hibernate.models.spi.SourceModelBuildingContext; import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.IndexView;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
@ -29,38 +23,38 @@ public class ModelsHelper {
buildingContext.getAnnotationDescriptorRegistry().getDescriptor( TenantId.class ); buildingContext.getAnnotationDescriptorRegistry().getDescriptor( TenantId.class );
if ( buildingContext instanceof JandexModelBuildingContext ) { // if ( buildingContext instanceof JandexModelBuildingContext ) {
final IndexView jandexIndex = buildingContext.as( JandexModelBuildingContext.class ).getJandexIndex(); // final IndexView jandexIndex = buildingContext.as( JandexModelBuildingContext.class ).getJandexIndex();
if ( jandexIndex == null ) { // if ( jandexIndex == null ) {
return; // return;
} // }
//
final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry(); // final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry();
final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext.getAnnotationDescriptorRegistry(); // final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext.getAnnotationDescriptorRegistry();
//
for ( ClassInfo knownClass : jandexIndex.getKnownClasses() ) { // for ( ClassInfo knownClass : jandexIndex.getKnownClasses() ) {
final String className = knownClass.name().toString(); // final String className = knownClass.name().toString();
//
if ( knownClass.isAnnotation() ) { // if ( knownClass.isAnnotation() ) {
// it is always safe to load the annotation classes - we will never be enhancing them // // it is always safe to load the annotation classes - we will never be enhancing them
//noinspection rawtypes // //noinspection rawtypes
final Class annotationClass = buildingContext // final Class annotationClass = buildingContext
.getClassLoading() // .getClassLoading()
.classForName( className ); // .classForName( className );
//noinspection unchecked // //noinspection unchecked
annotationDescriptorRegistry.resolveDescriptor( // annotationDescriptorRegistry.resolveDescriptor(
annotationClass, // annotationClass,
(t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext ) // (t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext )
); // );
} // }
//
resolveClassDetails( // resolveClassDetails(
className, // className,
classDetailsRegistry, // classDetailsRegistry,
() -> new JandexClassDetails( knownClass, buildingContext ) // () -> new JandexClassDetails( knownClass, buildingContext )
); // );
} // }
} // }
} }
public static ClassDetails resolveClassDetails( public static ClassDetails resolveClassDetails(

View File

@ -20,13 +20,10 @@ import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.JpaAnnotations; import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.XmlAnnotations; import org.hibernate.boot.models.XmlAnnotations;
import org.hibernate.models.AnnotationAccessException; import org.hibernate.models.AnnotationAccessException;
import org.hibernate.models.jandex.spi.JandexModelBuildingContext;
import org.hibernate.models.jandex.spi.JandexValueExtractor;
import org.hibernate.models.spi.AnnotationDescriptor; import org.hibernate.models.spi.AnnotationDescriptor;
import org.hibernate.models.spi.AttributeDescriptor; import org.hibernate.models.spi.AttributeDescriptor;
import org.hibernate.models.spi.SourceModelBuildingContext; import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
@ -72,22 +69,6 @@ public class OrmAnnotationHelper {
return extractJdkValue( jdkAnnotation, attributeDescriptor, modelContext ); return extractJdkValue( jdkAnnotation, attributeDescriptor, modelContext );
} }
public static <V> V extractJandexValue(AnnotationInstance jandexAnnotation, AttributeDescriptor<V> attributeDescriptor, SourceModelBuildingContext modelContext) {
final JandexValueExtractor<V> extractor = modelContext.as( JandexModelBuildingContext.class )
.getJandexValueExtractor( attributeDescriptor.getTypeDescriptor() );
return extractor.extractValue( jandexAnnotation, attributeDescriptor, modelContext );
// final AnnotationValue value = jandexAnnotation.value( attributeDescriptor.getName() );
// return attributeDescriptor
// .getTypeDescriptor()
// .createJandexValueConverter( modelContext )
// .convert( value, modelContext );
}
public static <V, A extends Annotation> V extractJandexValue(AnnotationInstance jandexAnnotation, AnnotationDescriptor<A> annotationDescriptor, String attributeName, SourceModelBuildingContext modelContext) {
final AttributeDescriptor<V> attributeDescriptor = annotationDescriptor.getAttribute( attributeName );
return extractJandexValue( jandexAnnotation, attributeDescriptor, modelContext );
}
public static List<Annotation> extractAnnotationTypeAnnotations(Class<? extends Annotation> annotationType) { public static List<Annotation> extractAnnotationTypeAnnotations(Class<? extends Annotation> annotationType) {
final ArrayList<Annotation> result = new ArrayList<>(); final ArrayList<Annotation> result = new ArrayList<>();
final Annotation[] annotationTypeAnnotations = annotationType.getAnnotations(); final Annotation[] annotationTypeAnnotations = annotationType.getAnnotations();

View File

@ -23,8 +23,6 @@ import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.jboss.jandex.IndexView;
import jakarta.persistence.AttributeConverter; import jakarta.persistence.AttributeConverter;
import jakarta.persistence.SharedCacheMode; import jakarta.persistence.SharedCacheMode;
@ -98,7 +96,7 @@ public abstract class AbstractDelegatingMetadataBuilderImplementor<T extends Met
} }
@Override @Override
public MetadataBuilder applyIndexView(IndexView jandexView) { public MetadataBuilder applyIndexView(Object jandexView) {
delegate.applyIndexView( jandexView ); delegate.applyIndexView( jandexView );
return getThis(); return getThis();
} }

View File

@ -25,8 +25,6 @@ import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.jandex.IndexView;
/** /**
* Defines a context for things available during the process of bootstrapping * Defines a context for things available during the process of bootstrapping
* a {@link org.hibernate.SessionFactory} which are expected to be cleaned up * a {@link org.hibernate.SessionFactory} which are expected to be cleaned up
@ -151,14 +149,14 @@ public interface BootstrapContext {
/** /**
* Access to the Jandex index passed by call to * Access to the Jandex index passed by call to
* {@link org.hibernate.boot.MetadataBuilder#applyIndexView(IndexView)}, if any. * {@link org.hibernate.boot.MetadataBuilder#applyIndexView(Object)}, if any.
* *
* @apiNote Jandex is currently not used, see * @apiNote Jandex is currently not used, see
* <a href="https://github.com/hibernate/hibernate-orm/wiki/Roadmap7.0">the roadmap</a> * <a href="https://github.com/hibernate/hibernate-orm/wiki/Roadmap7.0">the roadmap</a>
* *
* @return The Jandex index * @return The Jandex index
*/ */
IndexView getJandexView(); Object getJandexView();
/** /**
* Access to any SQL functions explicitly registered with the * Access to any SQL functions explicitly registered with the

View File

@ -104,7 +104,6 @@ public abstract class Ejb3XmlTestCase extends BaseUnitTestCase {
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector( final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
true, true,
globalRegistrations, globalRegistrations,
null,
modelBuildingContext modelBuildingContext
); );

View File

@ -297,7 +297,6 @@ public class SourceModelTestHelper {
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector( final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
true, true,
globalRegistrations, globalRegistrations,
jandexIndex,
sourceModelBuildingContext sourceModelBuildingContext
); );

View File

@ -132,7 +132,6 @@ public class XmlProcessingSmokeTests {
final DomainModelCategorizationCollector collector = new DomainModelCategorizationCollector( final DomainModelCategorizationCollector collector = new DomainModelCategorizationCollector(
false, false,
new GlobalRegistrationsImpl( buildingContext, new BootstrapContextImpl() ), new GlobalRegistrationsImpl( buildingContext, new BootstrapContextImpl() ),
null,
buildingContext buildingContext
); );
collectedXmlResources.getDocuments().forEach( jaxbEntityMappings -> { collectedXmlResources.getDocuments().forEach( jaxbEntityMappings -> {

View File

@ -29,7 +29,6 @@ import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.jandex.IndexView;
/** /**
* @author Andrea Boriero * @author Andrea Boriero
@ -121,7 +120,7 @@ public class BootstrapContextImpl implements BootstrapContext {
} }
@Override @Override
public IndexView getJandexView() { public Object getJandexView() {
return delegate.getJandexView(); return delegate.getJandexView();
} }