use of org.hibernate.boot.archive.scan.spi.ScanResult in project hibernate-orm by hibernate.
the class ScanningCoordinator method coordinateScan.
public void coordinateScan(ManagedResourcesImpl managedResources, MetadataBuildingOptions options, XmlMappingBinderAccess xmlMappingBinderAccess) {
if (options.getScanEnvironment() == null) {
return;
}
final ClassLoaderService classLoaderService = options.getServiceRegistry().getService(ClassLoaderService.class);
final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl(options.getTempClassLoader(), classLoaderService);
// NOTE : the idea with JandexInitializer/JandexInitManager was to allow adding classes
// to the index as we discovered them via scanning and . Currently
final Scanner scanner = buildScanner(options, classLoaderAccess);
final ScanResult scanResult = scanner.scan(options.getScanEnvironment(), options.getScanOptions(), StandardScanParameters.INSTANCE);
applyScanResultsToManagedResources(managedResources, scanResult, options, xmlMappingBinderAccess);
}
use of org.hibernate.boot.archive.scan.spi.ScanResult in project hibernate-orm by hibernate.
the class JarVisitorTest method testExplodedJar.
@Test
public void testExplodedJar() throws Exception {
File explodedPar = buildExplodedPar();
addPackageToClasspath(explodedPar);
String dirPath = explodedPar.toURL().toExternalForm();
// TODO - shouldn't ExplodedJarVisitor take care of a trailing slash?
if (dirPath.endsWith("/")) {
dirPath = dirPath.substring(0, dirPath.length() - 1);
}
ScanResult result = standardScan(ArchiveHelper.getURLFromPath(dirPath));
assertEquals(1, result.getLocatedClasses().size());
assertEquals(1, result.getLocatedPackages().size());
assertEquals(1, result.getLocatedMappingFiles().size());
assertTrue(result.getLocatedClasses().contains(new ClassDescriptorImpl(Carpet.class.getName(), ClassDescriptor.Categorization.MODEL, null)));
for (MappingFileDescriptor mappingFileDescriptor : result.getLocatedMappingFiles()) {
assertNotNull(mappingFileDescriptor.getStreamAccess());
final InputStream stream = mappingFileDescriptor.getStreamAccess().accessInputStream();
assertNotNull(stream);
stream.close();
}
}
use of org.hibernate.boot.archive.scan.spi.ScanResult in project hibernate-orm by hibernate.
the class JarVisitorTest method testInputStreamZippedJar.
@Test
public void testInputStreamZippedJar() throws Exception {
File defaultPar = buildDefaultPar();
addPackageToClasspath(defaultPar);
ScanResult result = standardScan(defaultPar.toURL());
validateResults(result, org.hibernate.jpa.test.pack.defaultpar.ApplicationServer.class, Version.class);
}
use of org.hibernate.boot.archive.scan.spi.ScanResult in project hibernate-orm by hibernate.
the class ScannerTest method testNativeScanner.
@Test
public void testNativeScanner() throws Exception {
File defaultPar = buildDefaultPar();
addPackageToClasspath(defaultPar);
PersistenceUnitDescriptor descriptor = new ParsedPersistenceXmlDescriptor(defaultPar.toURL());
ScanEnvironment env = new StandardJpaScanEnvironmentImpl(descriptor);
ScanOptions options = new StandardScanOptions("hbm,class", descriptor.isExcludeUnlistedClasses());
Scanner scanner = new StandardScanner();
ScanResult scanResult = scanner.scan(env, options, StandardScanParameters.INSTANCE);
assertEquals(3, scanResult.getLocatedClasses().size());
assertClassesContained(scanResult, ApplicationServer.class);
assertClassesContained(scanResult, Version.class);
assertEquals(2, scanResult.getLocatedMappingFiles().size());
for (MappingFileDescriptor mappingFileDescriptor : scanResult.getLocatedMappingFiles()) {
assertNotNull(mappingFileDescriptor.getName());
assertNotNull(mappingFileDescriptor.getStreamAccess());
InputStream stream = mappingFileDescriptor.getStreamAccess().accessInputStream();
assertNotNull(stream);
stream.close();
}
}
use of org.hibernate.boot.archive.scan.spi.ScanResult in project hibernate-orm by hibernate.
the class JarVisitorTest method testHttp.
@Test
public void testHttp() throws Exception {
final URL url = ArchiveHelper.getJarURLFromURLEntry(new URL("jar:http://www.ibiblio.org/maven/hibernate/jars/hibernate-annotations-3.0beta1.jar!/META-INF/persistence.xml"), "/META-INF/persistence.xml");
try {
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
} catch (IOException ie) {
//fail silently
return;
}
ScanResult result = standardScan(url);
assertEquals(0, result.getLocatedClasses().size());
assertEquals(0, result.getLocatedPackages().size());
assertEquals(0, result.getLocatedMappingFiles().size());
}
Aggregations