Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.hibernate.type.BasicType;
import org.hibernate.usertype.UserType;

import org.jboss.jandex.IndexView;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.SharedCacheMode;
Expand Down Expand Up @@ -148,7 +147,7 @@ public interface MetadataBuilder {
*
* @return {@code this}, for method chaining
*/
MetadataBuilder applyIndexView(IndexView jandexView);
MetadataBuilder applyIndexView(Object jandexView);

/**
* Specify the options to be used in performing scanning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.hibernate.type.BasicType;
import org.hibernate.type.spi.TypeConfiguration;

import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;

/**
Expand Down Expand Up @@ -66,7 +65,7 @@ public class BootstrapContextImpl implements BootstrapContext {
private Object scannerSetting;
private ArchiveDescriptorFactory archiveDescriptorFactory;

private IndexView jandexView;
private Object jandexView;

private HashMap<String,SqmFunctionDescriptor> sqlFunctionMap;
private ArrayList<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
Expand Down Expand Up @@ -182,7 +181,7 @@ public Object getScanner() {
}

@Override
public IndexView getJandexView() {
public Object getJandexView() {
return jandexView;
}

Expand Down Expand Up @@ -300,7 +299,7 @@ void injectArchiveDescriptorFactory(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 );
this.jandexView = jandexView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserType;

import org.jboss.jandex.IndexView;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.ConstraintMode;
Expand Down Expand Up @@ -213,7 +212,7 @@ public MetadataBuilder applyAccessType(AccessType implicitCacheAccessType) {
}

@Override
public MetadataBuilder applyIndexView(IndexView jandexView) {
public MetadataBuilder applyIndexView(Object jandexView) {
this.bootstrapContext.injectJandexView( jandexView );
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.mapping.Table;
import org.hibernate.models.internal.MutableClassDetailsRegistry;
import org.hibernate.models.jandex.internal.JandexIndexerHelper;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.ClassLoading;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.type.BasicType;
import org.hibernate.type.BasicTypeRegistry;
Expand All @@ -95,9 +93,6 @@
import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.usertype.CompositeUserType;

import org.jboss.jandex.CompositeIndex;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;

import jakarta.persistence.AttributeConverter;

Expand Down Expand Up @@ -398,10 +393,6 @@ public static DomainModelSource processManagedResources(
} );
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
// - collect overlay XML
Expand All @@ -424,7 +415,6 @@ public static DomainModelSource processManagedResources(
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
areIdGeneratorsGlobal,
metadataCollector.getGlobalRegistrations(),
jandexIndex,
sourceModelBuildingContext
);

Expand Down Expand Up @@ -458,7 +448,6 @@ public static DomainModelSource processManagedResources(

return new DomainModelSource(
classDetailsRegistry,
jandexIndex,
allKnownClassNames,
modelCategorizationCollector.getGlobalRegistrations(),
rootMappingDefaults,
Expand Down Expand Up @@ -491,31 +480,6 @@ private static void applyKnownClass(
}
}

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(
InFlightMetadataCollectorImpl metadataCollector,
MetadataBuildingOptions options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,23 @@
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
import org.hibernate.models.spi.ClassDetailsRegistry;

import org.jboss.jandex.IndexView;

/**
* @author Steve Ebersole
*/
public class DomainModelSource {
private final ClassDetailsRegistry classDetailsRegistry;
private final IndexView jandexIndex;
private final GlobalRegistrations globalRegistrations;
private final RootMappingDefaults effectiveMappingDefaults;
private final PersistenceUnitMetadata persistenceUnitMetadata;
private final List<String> allKnownClassNames;

public DomainModelSource(
ClassDetailsRegistry classDetailsRegistry,
IndexView jandexIndex,
List<String> allKnownClassNames,
GlobalRegistrations globalRegistrations,
RootMappingDefaults effectiveMappingDefaults,
PersistenceUnitMetadata persistenceUnitMetadata) {
this.classDetailsRegistry = classDetailsRegistry;
this.jandexIndex = jandexIndex;
this.allKnownClassNames = allKnownClassNames;
this.globalRegistrations = globalRegistrations;
this.effectiveMappingDefaults = effectiveMappingDefaults;
Expand All @@ -46,10 +41,6 @@ public ClassDetailsRegistry getClassDetailsRegistry() {
return classDetailsRegistry;
}

public IndexView getJandexIndex() {
return jandexIndex;
}

public GlobalRegistrations getGlobalRegistrations() {
return globalRegistrations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry;

import org.jboss.jandex.IndexView;

/**
* @author Steve Ebersole
*/
Expand All @@ -28,13 +26,11 @@ public class CategorizedDomainModelImpl implements CategorizedDomainModel {

private final ClassDetailsRegistry classDetailsRegistry;
private final AnnotationDescriptorRegistry annotationDescriptorRegistry;
private final IndexView jandexIndex;
private final PersistenceUnitMetadata persistenceUnitMetadata;

public CategorizedDomainModelImpl(
ClassDetailsRegistry classDetailsRegistry,
AnnotationDescriptorRegistry annotationDescriptorRegistry,
IndexView jandexIndex,
PersistenceUnitMetadata persistenceUnitMetadata,
Set<EntityHierarchy> entityHierarchies,
Map<String, ClassDetails> mappedSuperclasses,
Expand All @@ -47,7 +43,6 @@ public CategorizedDomainModelImpl(
this.mappedSuperclasses = mappedSuperclasses;
this.embeddables = embeddables;
this.globalRegistrations = globalRegistrations;
this.jandexIndex = jandexIndex;
}

@Override
Expand All @@ -60,11 +55,6 @@ public AnnotationDescriptorRegistry getAnnotationDescriptorRegistry() {
return annotationDescriptorRegistry;
}

@Override
public IndexView getJandexIndex() {
return jandexIndex;
}

@Override
public PersistenceUnitMetadata getPersistenceUnitMetadata() {
return persistenceUnitMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry;

import org.jboss.jandex.IndexView;

/**
* 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,
Expand All @@ -38,8 +36,6 @@ public interface CategorizedDomainModel {
*/
AnnotationDescriptorRegistry getAnnotationDescriptorRegistry();

IndexView getJandexIndex();

PersistenceUnitMetadata getPersistenceUnitMetadata();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.models.internal.BasicModelBuildingContextImpl;
import org.hibernate.models.jandex.internal.JandexIndexerHelper;
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
import org.hibernate.models.spi.ClassDetails;
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.internal.util.collections.CollectionHelper.mutableJoin;
Expand Down Expand Up @@ -100,7 +94,6 @@ public static CategorizedDomainModel processManagedResources(

// 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(), classLoading );
final BasicModelBuildingContextImpl sourceModelBuildingContext = new BasicModelBuildingContextImpl(
classLoading,
ModelsHelper::preFillRegistries
Expand Down Expand Up @@ -131,7 +124,6 @@ public static CategorizedDomainModel processManagedResources(
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
areIdGeneratorsGlobal,
globalRegistrations,
jandexIndex,
sourceModelBuildingContext
);

Expand Down Expand Up @@ -222,31 +214,6 @@ private static void warnAboutUnusedMappedSuperclasses(Map<String, ClassDetails>
}
}

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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.SourceModelBuildingContext;

import org.jboss.jandex.IndexView;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import jakarta.persistence.Embeddable;
Expand All @@ -40,7 +38,6 @@

public class DomainModelCategorizationCollector {
private final boolean areIdGeneratorsGlobal;
private final IndexView jandexIndex;

private final GlobalRegistrationsImpl globalRegistrations;
private final SourceModelBuildingContext modelsContext;
Expand All @@ -52,10 +49,8 @@ public class DomainModelCategorizationCollector {
public DomainModelCategorizationCollector(
boolean areIdGeneratorsGlobal,
GlobalRegistrations globalRegistrations,
IndexView jandexIndex,
SourceModelBuildingContext modelsContext) {
this.areIdGeneratorsGlobal = areIdGeneratorsGlobal;
this.jandexIndex = jandexIndex;
this.globalRegistrations = (GlobalRegistrationsImpl) globalRegistrations;
this.modelsContext = modelsContext;
}
Expand Down Expand Up @@ -176,7 +171,6 @@ public CategorizedDomainModel createResult(
return new CategorizedDomainModelImpl(
classDetailsRegistry,
annotationDescriptorRegistry,
jandexIndex,
persistenceUnitMetadata,
entityHierarchies,
mappedSuperclasses,
Expand Down
Loading