From de6aa69fb04f4370a70af80ecfd798bb860340fe Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 24 Sep 2024 12:00:11 +0200 Subject: [PATCH] HHH-18633 Split Jandex-based scanning into new module/artifact --- hibernate-core/hibernate-core.gradle | 7 ++++-- .../scan/internal/DisabledScanner.java | 25 +++++++++++++++---- .../boot/archive/scan/spi/Scanner.java | 6 +++++ .../boot/archive/scan/spi/ScannerFactory.java | 12 +++++++++ .../process/internal/ScanningCoordinator.java | 17 ++++++++++--- .../bootstrap/scanning/CustomScanner.java | 2 +- .../bootstrap/scanning/JarVisitorTest.java | 8 +++--- .../test/bootstrap/scanning/ScannerTest.java | 2 +- .../scanning/ScanningCoordinatorTest.java | 10 ++++---- ...ernate-integrationtest-java-modules.gradle | 1 + .../java/module/test/ScannerTest.java | 2 +- .../hibernate-scan-jandex.gradle | 18 +++++++++++++ .../scan/internal/ClassDescriptorImpl.java | 2 +- .../internal/MappingFileDescriptorImpl.java | 2 +- .../scan/internal/NoopEntryHandler.java | 2 +- .../scan/internal/PackageDescriptorImpl.java | 2 +- .../scan/internal/ScanResultCollector.java | 2 +- .../archive/scan/internal/ScanResultImpl.java | 2 +- .../scan/internal/StandardScanner.java | 4 +-- .../scan/internal/StandardScannerFactory.java | 19 ++++++++++++++ .../archive/scan/spi/AbstractScannerImpl.java | 11 +++++--- .../spi/ClassFileArchiveEntryHandler.java | 7 +++--- .../spi/NonClassFileArchiveEntryHandler.java | 6 ++--- .../spi/PackageInfoArchiveEntryHandler.java | 7 +++--- ...rnate.boot.archive.scan.spi.ScannerFactory | 1 + settings.gradle | 4 +++ 26 files changed, 138 insertions(+), 43 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/ScannerFactory.java create mode 100644 hibernate-scan-jandex/hibernate-scan-jandex.gradle rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/internal/ClassDescriptorImpl.java (96%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/internal/MappingFileDescriptorImpl.java (96%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/internal/NoopEntryHandler.java (91%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/internal/PackageDescriptorImpl.java (95%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/internal/ScanResultCollector.java (98%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/internal/ScanResultImpl.java (96%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/internal/StandardScanner.java (86%) create mode 100644 hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/StandardScannerFactory.java rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/spi/AbstractScannerImpl.java (91%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/spi/ClassFileArchiveEntryHandler.java (92%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/spi/NonClassFileArchiveEntryHandler.java (83%) rename {hibernate-core/src/main/java/org/hibernate/boot => hibernate-scan-jandex/src/main/java/org/hibernate}/archive/scan/spi/PackageInfoArchiveEntryHandler.java (85%) create mode 100644 hibernate-scan-jandex/src/main/resources/META-INF/services/org.hibernate.boot.archive.scan.spi.ScannerFactory diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 62b237fcec..4eb19a21c7 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -28,8 +28,6 @@ dependencies { api jakartaLibs.jta implementation libs.hibernateModels - implementation libs.hibernateModelsJandex - implementation libs.jandex implementation libs.classmate implementation libs.byteBuddy @@ -50,8 +48,12 @@ dependencies { // annotationProcessor project( ":annotation-descriptor-generator" ) compileOnly project( ":annotation-descriptor-generator" ) + runtimeOnly project(':hibernate-scan-jandex') + testImplementation project(':hibernate-testing') testImplementation project(':hibernate-ant') + testImplementation project(':hibernate-scan-jandex') + testImplementation testLibs.shrinkwrapApi testImplementation testLibs.shrinkwrap testImplementation testLibs.shrinkwrapDescriptors @@ -71,6 +73,7 @@ dependencies { testRuntimeOnly libs.byteBuddy testRuntimeOnly testLibs.weld testRuntimeOnly testLibs.wildFlyTxnClient + testImplementation libs.jandex testImplementation jakartaLibs.jsonb testImplementation libs.jackson testRuntimeOnly libs.jacksonXml diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/DisabledScanner.java b/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/DisabledScanner.java index 8faa3e795e..b72afa1023 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/DisabledScanner.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/DisabledScanner.java @@ -5,7 +5,11 @@ package org.hibernate.boot.archive.scan.internal; import java.util.Collections; +import java.util.Set; +import org.hibernate.boot.archive.scan.spi.ClassDescriptor; +import org.hibernate.boot.archive.scan.spi.MappingFileDescriptor; +import org.hibernate.boot.archive.scan.spi.PackageDescriptor; import org.hibernate.boot.archive.scan.spi.ScanEnvironment; import org.hibernate.boot.archive.scan.spi.ScanOptions; import org.hibernate.boot.archive.scan.spi.ScanParameters; @@ -19,11 +23,22 @@ import org.hibernate.boot.archive.scan.spi.Scanner; * @author Petteri Pitkanen */ public class DisabledScanner implements Scanner { - private static final ScanResult emptyScanResult = new ScanResultImpl( - Collections.emptySet(), - Collections.emptySet(), - Collections.emptySet() - ); + private static final ScanResult emptyScanResult = new ScanResult() { + @Override + public Set getLocatedPackages() { + return Collections.emptySet(); + } + + @Override + public Set getLocatedClasses() { + return Collections.emptySet(); + } + + @Override + public Set getLocatedMappingFiles() { + return Collections.emptySet(); + } + }; @Override public ScanResult scan(final ScanEnvironment environment, final ScanOptions options, final ScanParameters parameters) { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/Scanner.java b/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/Scanner.java index 3defcd7aea..2530b2f7b8 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/Scanner.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/Scanner.java @@ -4,6 +4,8 @@ */ package org.hibernate.boot.archive.scan.spi; +import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory; + /** * Defines the contract for Hibernate to be able to scan for classes, packages and resources inside a * persistence unit. @@ -29,4 +31,8 @@ public interface Scanner { * @param params The parameters for scanning */ ScanResult scan(ScanEnvironment environment, ScanOptions options, ScanParameters params); + + default void setArchiveDescriptorFactory(ArchiveDescriptorFactory archiveDescriptorFactory){ + throw new UnsupportedOperationException(); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/ScannerFactory.java b/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/ScannerFactory.java new file mode 100644 index 0000000000..cc08717acc --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/ScannerFactory.java @@ -0,0 +1,12 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.boot.archive.scan.spi; + +import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory; +import org.hibernate.service.Service; + +public interface ScannerFactory extends Service { + Scanner getScanner(ArchiveDescriptorFactory archiveDescriptorFactory); +} diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ScanningCoordinator.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ScanningCoordinator.java index 73b1275641..cb27c407e1 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ScanningCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ScanningCoordinator.java @@ -8,20 +8,22 @@ import java.lang.reflect.Constructor; import java.net.URL; import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; import org.hibernate.boot.MappingException; import org.hibernate.boot.archive.internal.StandardArchiveDescriptorFactory; import org.hibernate.boot.archive.internal.UrlInputStreamAccess; +import org.hibernate.boot.archive.scan.internal.DisabledScanner; import org.hibernate.boot.archive.scan.internal.StandardScanParameters; -import org.hibernate.boot.archive.scan.internal.StandardScanner; import org.hibernate.boot.archive.scan.spi.ClassDescriptor; import org.hibernate.boot.archive.scan.spi.MappingFileDescriptor; import org.hibernate.boot.archive.scan.spi.PackageDescriptor; import org.hibernate.boot.archive.scan.spi.ScanEnvironment; import org.hibernate.boot.archive.scan.spi.ScanResult; import org.hibernate.boot.archive.scan.spi.Scanner; +import org.hibernate.boot.archive.scan.spi.ScannerFactory; import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory; import org.hibernate.boot.internal.ClassLoaderAccessImpl; import org.hibernate.boot.jaxb.Origin; @@ -86,11 +88,18 @@ public class ScanningCoordinator { if ( scannerSetting == null ) { // No custom Scanner specified, use the StandardScanner - if ( archiveDescriptorFactory == null ) { - return new StandardScanner(); + final Iterator iterator = bootstrapContext.getServiceRegistry() + .requireService( ClassLoaderService.class ) + .loadJavaServices( ScannerFactory.class ) + .iterator(); + if ( iterator.hasNext() ) { + // todo: check for multiple scanner and in case raise a warning? + final ScannerFactory factory = iterator.next(); + return factory.getScanner( archiveDescriptorFactory ); } else { - return new StandardScanner( archiveDescriptorFactory ); + // todo: add a debug message that there is no Scanner? + return new DisabledScanner(); } } else { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/CustomScanner.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/CustomScanner.java index 2eedcd3a55..8b5bb7611b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/CustomScanner.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/CustomScanner.java @@ -4,7 +4,7 @@ */ package org.hibernate.orm.test.bootstrap.scanning; -import org.hibernate.boot.archive.scan.internal.StandardScanner; +import org.hibernate.archive.scan.internal.StandardScanner; import org.hibernate.boot.archive.scan.spi.ScanEnvironment; import org.hibernate.boot.archive.scan.spi.ScanOptions; import org.hibernate.boot.archive.scan.spi.ScanParameters; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/JarVisitorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/JarVisitorTest.java index 6b516aa056..29838f9313 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/JarVisitorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/JarVisitorTest.java @@ -16,17 +16,17 @@ import java.net.URLStreamHandlerFactory; import java.util.Collections; import java.util.List; +import org.hibernate.archive.scan.internal.ClassDescriptorImpl; +import org.hibernate.archive.scan.internal.ScanResultCollector; +import org.hibernate.archive.scan.internal.StandardScanner; +import org.hibernate.archive.scan.spi.AbstractScannerImpl; import org.hibernate.boot.archive.internal.ArchiveHelper; import org.hibernate.boot.archive.internal.ExplodedArchiveDescriptor; import org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor; import org.hibernate.boot.archive.internal.JarProtocolArchiveDescriptor; import org.hibernate.boot.archive.internal.StandardArchiveDescriptorFactory; -import org.hibernate.boot.archive.scan.internal.ClassDescriptorImpl; -import org.hibernate.boot.archive.scan.internal.ScanResultCollector; import org.hibernate.boot.archive.scan.internal.StandardScanOptions; import org.hibernate.boot.archive.scan.internal.StandardScanParameters; -import org.hibernate.boot.archive.scan.internal.StandardScanner; -import org.hibernate.boot.archive.scan.spi.AbstractScannerImpl; import org.hibernate.boot.archive.scan.spi.ClassDescriptor; import org.hibernate.boot.archive.scan.spi.MappingFileDescriptor; import org.hibernate.boot.archive.scan.spi.ScanEnvironment; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScannerTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScannerTest.java index 9843f28b5e..e2c2706cef 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScannerTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScannerTest.java @@ -14,9 +14,9 @@ import java.util.Map; import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.Persistence; +import org.hibernate.archive.scan.internal.StandardScanner; import org.hibernate.boot.archive.scan.internal.StandardScanOptions; import org.hibernate.boot.archive.scan.internal.StandardScanParameters; -import org.hibernate.boot.archive.scan.internal.StandardScanner; import org.hibernate.boot.archive.scan.spi.ClassDescriptor; import org.hibernate.boot.archive.scan.spi.MappingFileDescriptor; import org.hibernate.boot.archive.scan.spi.ScanEnvironment; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScanningCoordinatorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScanningCoordinatorTest.java index d57fc958ab..90cbdab2ea 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScanningCoordinatorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/scanning/ScanningCoordinatorTest.java @@ -9,13 +9,13 @@ import java.net.URL; import java.util.Arrays; import java.util.Collections; +import org.hibernate.archive.scan.internal.ClassDescriptorImpl; +import org.hibernate.boot.archive.scan.internal.DisabledScanner; +import org.hibernate.archive.scan.internal.MappingFileDescriptorImpl; +import org.hibernate.archive.scan.internal.PackageDescriptorImpl; +import org.hibernate.archive.scan.internal.ScanResultImpl; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.archive.internal.ByteArrayInputStreamAccess; -import org.hibernate.boot.archive.scan.internal.ClassDescriptorImpl; -import org.hibernate.boot.archive.scan.internal.DisabledScanner; -import org.hibernate.boot.archive.scan.internal.MappingFileDescriptorImpl; -import org.hibernate.boot.archive.scan.internal.PackageDescriptorImpl; -import org.hibernate.boot.archive.scan.internal.ScanResultImpl; import org.hibernate.boot.archive.scan.spi.ClassDescriptor; import org.hibernate.boot.archive.scan.spi.MappingFileDescriptor; import org.hibernate.boot.archive.scan.spi.PackageDescriptor; diff --git a/hibernate-integrationtest-java-modules/hibernate-integrationtest-java-modules.gradle b/hibernate-integrationtest-java-modules/hibernate-integrationtest-java-modules.gradle index 553966abd1..7d84aaded5 100644 --- a/hibernate-integrationtest-java-modules/hibernate-integrationtest-java-modules.gradle +++ b/hibernate-integrationtest-java-modules/hibernate-integrationtest-java-modules.gradle @@ -17,6 +17,7 @@ java.modularity.inferModulePath = true dependencies { api project( ':hibernate-core' ) api project( ':hibernate-envers' ) + implementation project( ':hibernate-scan-jandex' ) //Provide the jakarta.cdi module, as it's required by module jakarta.transaction //but not provided as transitive dependency of Narayana. testRuntimeOnly( jakartaLibs.cdi ) diff --git a/hibernate-integrationtest-java-modules/src/test/java/org/hibernate/orm/integrationtest/java/module/test/ScannerTest.java b/hibernate-integrationtest-java-modules/src/test/java/org/hibernate/orm/integrationtest/java/module/test/ScannerTest.java index 92df4f36c0..315a24a40f 100644 --- a/hibernate-integrationtest-java-modules/src/test/java/org/hibernate/orm/integrationtest/java/module/test/ScannerTest.java +++ b/hibernate-integrationtest-java-modules/src/test/java/org/hibernate/orm/integrationtest/java/module/test/ScannerTest.java @@ -10,7 +10,7 @@ import java.util.Set; import org.hibernate.boot.archive.internal.StandardArchiveDescriptorFactory; import org.hibernate.boot.archive.scan.internal.StandardScanOptions; import org.hibernate.boot.archive.scan.internal.StandardScanParameters; -import org.hibernate.boot.archive.scan.internal.StandardScanner; +import org.hibernate.archive.scan.internal.StandardScanner; import org.hibernate.boot.archive.scan.spi.ClassDescriptor; import org.hibernate.boot.archive.scan.spi.ScanResult; import org.hibernate.orm.integrationtest.java.module.test.entity.Author; diff --git a/hibernate-scan-jandex/hibernate-scan-jandex.gradle b/hibernate-scan-jandex/hibernate-scan-jandex.gradle new file mode 100644 index 0000000000..aab65a3eb7 --- /dev/null +++ b/hibernate-scan-jandex/hibernate-scan-jandex.gradle @@ -0,0 +1,18 @@ +description = 'Integrate support for Jandex into Hibernate O/RM' + +apply from: rootProject.file( 'gradle/published-java-module.gradle' ) + + +dependencies { + api project( ':hibernate-core' ) + api jakartaLibs.jpa + + implementation libs.jandex + + testImplementation project( ':hibernate-testing' ) + +} + +sourceSets.test.resources { + setSrcDirs( ['src/test/resources'] ) +} \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ClassDescriptorImpl.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ClassDescriptorImpl.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ClassDescriptorImpl.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ClassDescriptorImpl.java index 84da5d4668..04e5d93ed7 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ClassDescriptorImpl.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ClassDescriptorImpl.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.internal; +package org.hibernate.archive.scan.internal; import java.io.Serializable; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/MappingFileDescriptorImpl.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/MappingFileDescriptorImpl.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/MappingFileDescriptorImpl.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/MappingFileDescriptorImpl.java index 1b14896f00..757bad83f2 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/MappingFileDescriptorImpl.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/MappingFileDescriptorImpl.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.internal; +package org.hibernate.archive.scan.internal; import java.io.Serializable; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/NoopEntryHandler.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/NoopEntryHandler.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/NoopEntryHandler.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/NoopEntryHandler.java index 968403f99f..70f8378f60 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/NoopEntryHandler.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/NoopEntryHandler.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.internal; +package org.hibernate.archive.scan.internal; import org.hibernate.boot.archive.spi.ArchiveContext; import org.hibernate.boot.archive.spi.ArchiveEntry; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/PackageDescriptorImpl.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/PackageDescriptorImpl.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/PackageDescriptorImpl.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/PackageDescriptorImpl.java index 905ce2a82b..b67ee31da2 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/PackageDescriptorImpl.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/PackageDescriptorImpl.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.internal; +package org.hibernate.archive.scan.internal; import java.io.Serializable; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ScanResultCollector.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ScanResultCollector.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ScanResultCollector.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ScanResultCollector.java index 5770e746b5..231267377d 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ScanResultCollector.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ScanResultCollector.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.internal; +package org.hibernate.archive.scan.internal; import java.util.Collections; import java.util.HashSet; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ScanResultImpl.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ScanResultImpl.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ScanResultImpl.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ScanResultImpl.java index 0eac9dedda..183988bd56 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/ScanResultImpl.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/ScanResultImpl.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.internal; +package org.hibernate.archive.scan.internal; import java.io.Serializable; import java.util.Set; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/StandardScanner.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/StandardScanner.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/StandardScanner.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/StandardScanner.java index 66f1508646..54d7050136 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/internal/StandardScanner.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/StandardScanner.java @@ -2,10 +2,10 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.internal; +package org.hibernate.archive.scan.internal; +import org.hibernate.archive.scan.spi.AbstractScannerImpl; import org.hibernate.boot.archive.internal.StandardArchiveDescriptorFactory; -import org.hibernate.boot.archive.scan.spi.AbstractScannerImpl; import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory; /** diff --git a/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/StandardScannerFactory.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/StandardScannerFactory.java new file mode 100644 index 0000000000..043b1ac0ac --- /dev/null +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/internal/StandardScannerFactory.java @@ -0,0 +1,19 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.archive.scan.internal; + +import org.hibernate.boot.archive.scan.spi.Scanner; +import org.hibernate.boot.archive.scan.spi.ScannerFactory; +import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory; + +public class StandardScannerFactory implements ScannerFactory { + @Override + public Scanner getScanner(ArchiveDescriptorFactory archiveDescriptorFactory) { + if ( archiveDescriptorFactory == null ) { + return new StandardScanner(); + } + return new StandardScanner( archiveDescriptorFactory ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/AbstractScannerImpl.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/AbstractScannerImpl.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/AbstractScannerImpl.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/AbstractScannerImpl.java index 4327ccc1ff..1452b0950f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/AbstractScannerImpl.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/AbstractScannerImpl.java @@ -2,14 +2,19 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.spi; +package org.hibernate.archive.scan.spi; import java.net.URL; import java.util.HashMap; import java.util.Map; -import org.hibernate.boot.archive.scan.internal.NoopEntryHandler; -import org.hibernate.boot.archive.scan.internal.ScanResultCollector; +import org.hibernate.archive.scan.internal.NoopEntryHandler; +import org.hibernate.archive.scan.internal.ScanResultCollector; +import org.hibernate.boot.archive.scan.spi.ScanEnvironment; +import org.hibernate.boot.archive.scan.spi.ScanOptions; +import org.hibernate.boot.archive.scan.spi.ScanParameters; +import org.hibernate.boot.archive.scan.spi.ScanResult; +import org.hibernate.boot.archive.scan.spi.Scanner; import org.hibernate.boot.archive.spi.ArchiveContext; import org.hibernate.boot.archive.spi.ArchiveDescriptor; import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/ClassFileArchiveEntryHandler.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/ClassFileArchiveEntryHandler.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/ClassFileArchiveEntryHandler.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/ClassFileArchiveEntryHandler.java index 26e7ef2e5d..70b9051c35 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/ClassFileArchiveEntryHandler.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/ClassFileArchiveEntryHandler.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.spi; +package org.hibernate.archive.scan.spi; import java.io.IOException; import java.io.InputStream; @@ -11,8 +11,9 @@ import jakarta.persistence.Embeddable; import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; -import org.hibernate.boot.archive.scan.internal.ClassDescriptorImpl; -import org.hibernate.boot.archive.scan.internal.ScanResultCollector; +import org.hibernate.archive.scan.internal.ClassDescriptorImpl; +import org.hibernate.archive.scan.internal.ScanResultCollector; +import org.hibernate.boot.archive.scan.spi.ClassDescriptor; import org.hibernate.boot.archive.spi.ArchiveContext; import org.hibernate.boot.archive.spi.ArchiveEntry; import org.hibernate.boot.archive.spi.ArchiveEntryHandler; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/NonClassFileArchiveEntryHandler.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/NonClassFileArchiveEntryHandler.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/NonClassFileArchiveEntryHandler.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/NonClassFileArchiveEntryHandler.java index 1f4bccd809..203ab9b17f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/NonClassFileArchiveEntryHandler.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/NonClassFileArchiveEntryHandler.java @@ -2,10 +2,10 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.spi; +package org.hibernate.archive.scan.spi; -import org.hibernate.boot.archive.scan.internal.MappingFileDescriptorImpl; -import org.hibernate.boot.archive.scan.internal.ScanResultCollector; +import org.hibernate.archive.scan.internal.MappingFileDescriptorImpl; +import org.hibernate.archive.scan.internal.ScanResultCollector; import org.hibernate.boot.archive.spi.ArchiveContext; import org.hibernate.boot.archive.spi.ArchiveEntry; import org.hibernate.boot.archive.spi.ArchiveEntryHandler; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/PackageInfoArchiveEntryHandler.java b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/PackageInfoArchiveEntryHandler.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/PackageInfoArchiveEntryHandler.java rename to hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/PackageInfoArchiveEntryHandler.java index c1f3dd2def..0f68faaca4 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/archive/scan/spi/PackageInfoArchiveEntryHandler.java +++ b/hibernate-scan-jandex/src/main/java/org/hibernate/archive/scan/spi/PackageInfoArchiveEntryHandler.java @@ -2,10 +2,11 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.boot.archive.scan.spi; +package org.hibernate.archive.scan.spi; -import org.hibernate.boot.archive.scan.internal.PackageDescriptorImpl; -import org.hibernate.boot.archive.scan.internal.ScanResultCollector; +import org.hibernate.archive.scan.internal.PackageDescriptorImpl; +import org.hibernate.archive.scan.internal.ScanResultCollector; +import org.hibernate.boot.archive.scan.spi.PackageDescriptor; import org.hibernate.boot.archive.spi.ArchiveContext; import org.hibernate.boot.archive.spi.ArchiveEntry; import org.hibernate.boot.archive.spi.ArchiveEntryHandler; diff --git a/hibernate-scan-jandex/src/main/resources/META-INF/services/org.hibernate.boot.archive.scan.spi.ScannerFactory b/hibernate-scan-jandex/src/main/resources/META-INF/services/org.hibernate.boot.archive.scan.spi.ScannerFactory new file mode 100644 index 0000000000..39161a1567 --- /dev/null +++ b/hibernate-scan-jandex/src/main/resources/META-INF/services/org.hibernate.boot.archive.scan.spi.ScannerFactory @@ -0,0 +1 @@ +org.hibernate.archive.scan.internal.StandardScannerFactory \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 98f5b4d0cb..3e50e41ea8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -347,6 +347,8 @@ if ( "OpenJDK Runtime Environment".equals( System.getProperty( "java.runtime.nam include 'hibernate-jfr' } +include 'hibernate-scan-jandex' + include 'metamodel-generator' project(':metamodel-generator').projectDir = new File(rootProject.projectDir, "tooling/metamodel-generator") project(':metamodel-generator').name = 'hibernate-processor' @@ -367,3 +369,5 @@ rootProject.children.each { project -> assert project.buildFile.isFile() } include 'hibernate-platform' + +