use of org.hibernate.boot.archive.spi.ArchiveEntry in project hibernate-orm by hibernate.
the class OsgiArchiveDescriptor method visitArchive.
@Override
public void visitArchive(ArchiveContext context) {
final Collection<String> resources = bundleWiring.listResources("/", "*", BundleWiring.LISTRESOURCES_RECURSE);
for (final String resource : resources) {
// TODO: Is there a better way to check this? Karaf is including directories.
if (!resource.endsWith("/")) {
try {
// TODO: Is using resource as the names correct?
final InputStreamAccess inputStreamAccess = new InputStreamAccess() {
@Override
public String getStreamName() {
return resource;
}
@Override
public InputStream accessInputStream() {
return openInputStream();
}
private InputStream openInputStream() {
try {
return persistenceBundle.getResource(resource).openStream();
} catch (IOException e) {
throw new PersistenceException("Unable to open an InputStream on the OSGi Bundle resource!", e);
}
}
};
final ArchiveEntry entry = new ArchiveEntry() {
@Override
public String getName() {
return resource;
}
@Override
public String getNameWithinArchive() {
return resource;
}
@Override
public InputStreamAccess getStreamAccess() {
return inputStreamAccess;
}
};
context.obtainArchiveEntryHandler(entry).handleEntry(entry, context);
} catch (Exception e) {
LOG.unableToLoadScannedClassOrResource(e);
}
}
}
}
Aggregations