|
8 | 8 | import java.net.URL;
|
9 | 9 | import java.util.ArrayList;
|
10 | 10 | import java.util.HashSet;
|
| 11 | +import java.util.Iterator; |
11 | 12 | import java.util.List;
|
12 | 13 | import java.util.Set;
|
13 | 14 |
|
14 | 15 | import org.hibernate.boot.MappingException;
|
15 | 16 | import org.hibernate.boot.archive.internal.StandardArchiveDescriptorFactory;
|
16 | 17 | import org.hibernate.boot.archive.internal.UrlInputStreamAccess;
|
| 18 | +import org.hibernate.boot.archive.scan.internal.DisabledScanner; |
17 | 19 | import org.hibernate.boot.archive.scan.internal.StandardScanParameters;
|
18 |
| -import org.hibernate.boot.archive.scan.internal.StandardScanner; |
19 | 20 | import org.hibernate.boot.archive.scan.spi.ClassDescriptor;
|
20 | 21 | import org.hibernate.boot.archive.scan.spi.MappingFileDescriptor;
|
21 | 22 | import org.hibernate.boot.archive.scan.spi.PackageDescriptor;
|
22 | 23 | import org.hibernate.boot.archive.scan.spi.ScanEnvironment;
|
23 | 24 | import org.hibernate.boot.archive.scan.spi.ScanResult;
|
24 | 25 | import org.hibernate.boot.archive.scan.spi.Scanner;
|
| 26 | +import org.hibernate.boot.archive.scan.spi.ScannerFactory; |
25 | 27 | import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
|
26 | 28 | import org.hibernate.boot.internal.ClassLoaderAccessImpl;
|
27 | 29 | import org.hibernate.boot.jaxb.Origin;
|
@@ -86,11 +88,18 @@ private static Scanner buildScanner(BootstrapContext bootstrapContext, ClassLoad
|
86 | 88 |
|
87 | 89 | if ( scannerSetting == null ) {
|
88 | 90 | // No custom Scanner specified, use the StandardScanner
|
89 |
| - if ( archiveDescriptorFactory == null ) { |
90 |
| - return new StandardScanner(); |
| 91 | + final Iterator<ScannerFactory> iterator = bootstrapContext.getServiceRegistry() |
| 92 | + .requireService( ClassLoaderService.class ) |
| 93 | + .loadJavaServices( ScannerFactory.class ) |
| 94 | + .iterator(); |
| 95 | + if ( iterator.hasNext() ) { |
| 96 | + // todo: check for multiple scanner and in case raise a warning? |
| 97 | + final ScannerFactory factory = iterator.next(); |
| 98 | + return factory.getScanner( archiveDescriptorFactory ); |
91 | 99 | }
|
92 | 100 | else {
|
93 |
| - return new StandardScanner( archiveDescriptorFactory ); |
| 101 | + // todo: add a debug message that there is no Scanner? |
| 102 | + return new DisabledScanner(); |
94 | 103 | }
|
95 | 104 | }
|
96 | 105 | else {
|
|
0 commit comments