Search in sources :

Example 1 with ScanResultCollector

use of org.hibernate.boot.archive.scan.internal.ScanResultCollector in project hibernate-orm by hibernate.

the class AbstractScannerImpl method scan.

@Override
public ScanResult scan(ScanEnvironment environment, ScanOptions options, ScanParameters parameters) {
    final ScanResultCollector collector = new ScanResultCollector(environment, options, parameters);
    if (environment.getNonRootUrls() != null) {
        final ArchiveContext context = new ArchiveContextImpl(false, collector);
        for (URL url : environment.getNonRootUrls()) {
            final ArchiveDescriptor descriptor = buildArchiveDescriptor(url, environment, false);
            descriptor.visitArchive(context);
        }
    }
    if (environment.getRootUrl() != null) {
        final ArchiveContext context = new ArchiveContextImpl(true, collector);
        final ArchiveDescriptor descriptor = buildArchiveDescriptor(environment.getRootUrl(), environment, true);
        descriptor.visitArchive(context);
    }
    return collector.toScanResult();
}
Also used : ScanResultCollector(org.hibernate.boot.archive.scan.internal.ScanResultCollector) ArchiveContext(org.hibernate.boot.archive.spi.ArchiveContext) ArchiveDescriptor(org.hibernate.boot.archive.spi.ArchiveDescriptor) URL(java.net.URL)

Example 2 with ScanResultCollector

use of org.hibernate.boot.archive.scan.internal.ScanResultCollector in project hibernate-orm by hibernate.

the class JarVisitorTest method testNestedJarProtocol.

@Test
public void testNestedJarProtocol() throws Exception {
    File defaultPar = buildDefaultPar();
    File nestedEar = buildNestedEar(defaultPar);
    File nestedEarDir = buildNestedEarDir(defaultPar);
    addPackageToClasspath(nestedEar);
    String jarFileName = nestedEar.toURL().toExternalForm() + "!/defaultpar.par";
    URL rootUrl = new URL(jarFileName);
    JarProtocolArchiveDescriptor archiveDescriptor = new JarProtocolArchiveDescriptor(StandardArchiveDescriptorFactory.INSTANCE, rootUrl, "");
    ScanEnvironment environment = new ScanEnvironmentImpl(rootUrl);
    ScanResultCollector collector = new ScanResultCollector(environment, new StandardScanOptions(), StandardScanParameters.INSTANCE);
    archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(true, collector));
    validateResults(collector.toScanResult(), org.hibernate.jpa.test.pack.defaultpar.ApplicationServer.class, Version.class);
    jarFileName = nestedEarDir.toURL().toExternalForm() + "!/defaultpar.par";
    rootUrl = new URL(jarFileName);
    archiveDescriptor = new JarProtocolArchiveDescriptor(StandardArchiveDescriptorFactory.INSTANCE, rootUrl, "");
    environment = new ScanEnvironmentImpl(rootUrl);
    collector = new ScanResultCollector(environment, new StandardScanOptions(), StandardScanParameters.INSTANCE);
    archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(true, collector));
    validateResults(collector.toScanResult(), org.hibernate.jpa.test.pack.defaultpar.ApplicationServer.class, Version.class);
}
Also used : JarProtocolArchiveDescriptor(org.hibernate.boot.archive.internal.JarProtocolArchiveDescriptor) AbstractScannerImpl(org.hibernate.boot.archive.scan.spi.AbstractScannerImpl) URL(java.net.URL) ScanResultCollector(org.hibernate.boot.archive.scan.internal.ScanResultCollector) ScanEnvironment(org.hibernate.boot.archive.scan.spi.ScanEnvironment) File(java.io.File) StandardScanOptions(org.hibernate.boot.archive.scan.internal.StandardScanOptions) Test(org.junit.Test)

Example 3 with ScanResultCollector

use of org.hibernate.boot.archive.scan.internal.ScanResultCollector in project hibernate-orm by hibernate.

the class JarVisitorTest method testJarProtocol.

@Test
public void testJarProtocol() throws Exception {
    File war = buildWar();
    addPackageToClasspath(war);
    String jarFileName = war.toURL().toExternalForm() + "!/WEB-INF/classes";
    URL rootUrl = new URL(jarFileName);
    JarProtocolArchiveDescriptor archiveDescriptor = new JarProtocolArchiveDescriptor(StandardArchiveDescriptorFactory.INSTANCE, rootUrl, "");
    final ScanEnvironment environment = new ScanEnvironmentImpl(rootUrl);
    final ScanResultCollector collector = new ScanResultCollector(environment, new StandardScanOptions(), StandardScanParameters.INSTANCE);
    archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(true, collector));
    validateResults(collector.toScanResult(), org.hibernate.jpa.test.pack.war.ApplicationServer.class, org.hibernate.jpa.test.pack.war.Version.class);
}
Also used : JarProtocolArchiveDescriptor(org.hibernate.boot.archive.internal.JarProtocolArchiveDescriptor) AbstractScannerImpl(org.hibernate.boot.archive.scan.spi.AbstractScannerImpl) URL(java.net.URL) ScanResultCollector(org.hibernate.boot.archive.scan.internal.ScanResultCollector) ScanEnvironment(org.hibernate.boot.archive.scan.spi.ScanEnvironment) File(java.io.File) StandardScanOptions(org.hibernate.boot.archive.scan.internal.StandardScanOptions) Test(org.junit.Test)

Aggregations

URL (java.net.URL)3 ScanResultCollector (org.hibernate.boot.archive.scan.internal.ScanResultCollector)3 File (java.io.File)2 JarProtocolArchiveDescriptor (org.hibernate.boot.archive.internal.JarProtocolArchiveDescriptor)2 StandardScanOptions (org.hibernate.boot.archive.scan.internal.StandardScanOptions)2 AbstractScannerImpl (org.hibernate.boot.archive.scan.spi.AbstractScannerImpl)2 ScanEnvironment (org.hibernate.boot.archive.scan.spi.ScanEnvironment)2 Test (org.junit.Test)2 ArchiveContext (org.hibernate.boot.archive.spi.ArchiveContext)1 ArchiveDescriptor (org.hibernate.boot.archive.spi.ArchiveDescriptor)1