use of org.hibernate.boot.archive.scan.internal.StandardScanOptions 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.internal.StandardScanOptions in project hibernate-orm by hibernate.
the class EntityManagerFactoryBuilderImpl method populate.
protected void populate(MetadataBuilder metamodelBuilder, MergedSettings mergedSettings, StandardServiceRegistry ssr, List<AttributeConverterDefinition> attributeConverterDefinitions) {
if (persistenceUnit.getTempClassLoader() != null) {
metamodelBuilder.applyTempClassLoader(persistenceUnit.getTempClassLoader());
}
metamodelBuilder.applyScanEnvironment(new StandardJpaScanEnvironmentImpl(persistenceUnit));
metamodelBuilder.applyScanOptions(new StandardScanOptions((String) configurationValues.get(org.hibernate.cfg.AvailableSettings.SCANNER_DISCOVERY), persistenceUnit.isExcludeUnlistedClasses()));
if (mergedSettings.cacheRegionDefinitions != null) {
for (CacheRegionDefinition localCacheRegionDefinition : mergedSettings.cacheRegionDefinitions) {
metamodelBuilder.applyCacheRegionDefinition(localCacheRegionDefinition);
}
}
final TypeContributorList typeContributorList = (TypeContributorList) configurationValues.remove(TYPE_CONTRIBUTORS);
if (typeContributorList != null) {
for (TypeContributor typeContributor : typeContributorList.getTypeContributors()) {
metamodelBuilder.applyTypes(typeContributor);
}
}
if (attributeConverterDefinitions != null) {
for (AttributeConverterDefinition attributeConverterDefinition : attributeConverterDefinitions) {
metamodelBuilder.applyAttributeConverter(attributeConverterDefinition);
}
}
}
use of org.hibernate.boot.archive.scan.internal.StandardScanOptions 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);
}
use of org.hibernate.boot.archive.scan.internal.StandardScanOptions 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);
}
Aggregations