use of org.hibernate.boot.archive.scan.internal.ClassDescriptorImpl 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.internal.ClassDescriptorImpl in project hibernate-orm by hibernate.
the class ClassFileArchiveEntryHandler method toClassDescriptor.
private ClassDescriptor toClassDescriptor(ClassFile classFile, ArchiveEntry entry) {
ClassDescriptor.Categorization categorization = ClassDescriptor.Categorization.OTHER;
;
final AnnotationsAttribute visibleAnnotations = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
if (visibleAnnotations != null) {
if (visibleAnnotations.getAnnotation(Entity.class.getName()) != null || visibleAnnotations.getAnnotation(MappedSuperclass.class.getName()) != null || visibleAnnotations.getAnnotation(Embeddable.class.getName()) != null) {
categorization = ClassDescriptor.Categorization.MODEL;
} else if (visibleAnnotations.getAnnotation(Converter.class.getName()) != null) {
categorization = ClassDescriptor.Categorization.CONVERTER;
}
}
return new ClassDescriptorImpl(classFile.getName(), categorization, entry.getStreamAccess());
}
use of org.hibernate.boot.archive.scan.internal.ClassDescriptorImpl in project hibernate-orm by hibernate.
the class JarVisitorTest method validateResults.
private void validateResults(ScanResult scanResult, Class... expectedClasses) throws IOException {
assertEquals(3, scanResult.getLocatedClasses().size());
for (Class expectedClass : expectedClasses) {
assertTrue(scanResult.getLocatedClasses().contains(new ClassDescriptorImpl(expectedClass.getName(), ClassDescriptor.Categorization.MODEL, null)));
}
assertEquals(2, scanResult.getLocatedMappingFiles().size());
for (MappingFileDescriptor mappingFileDescriptor : scanResult.getLocatedMappingFiles()) {
assertNotNull(mappingFileDescriptor.getStreamAccess());
final InputStream stream = mappingFileDescriptor.getStreamAccess().accessInputStream();
assertNotNull(stream);
stream.close();
}
}
Aggregations