use of org.apache.aries.util.filesystem.ICloseableDirectory in project aries by apache.
the class ModelledResourceManagerImpl method getServiceElements.
public ParsedServiceElements getServiceElements(InputStreamProvider archive) throws ModellerException {
ICloseableDirectory dir = null;
try {
dir = FileSystem.getFSRoot(archive.open());
BundleManifest bm = BundleManifest.fromBundle(dir);
return getServiceElements(bm, dir);
} catch (IOException e) {
throw new ModellerException(e);
} finally {
IOUtils.close(dir);
}
}
use of org.apache.aries.util.filesystem.ICloseableDirectory in project aries by apache.
the class EJBLocatorTest method runTest.
private void runTest(byte[] zip, String manifest) throws ModellerException, IOException {
ICloseableDirectory icd = FileSystem.getFSRoot(new ByteArrayInputStream(zip));
new OpenEJBLocator().findEJBs(new BundleManifest(getClass().getClassLoader().getResourceAsStream(manifest)), icd, registry);
icd.close();
}
use of org.apache.aries.util.filesystem.ICloseableDirectory in project aries by apache.
the class BasicSubsystem method install.
@Override
public AriesSubsystem install(String location, final InputStream content, InputStream deploymentManifest) {
AriesSubsystem result = null;
IDirectory directory = null;
try {
directory = content == null ? null : AccessController.doPrivileged(new PrivilegedAction<IDirectory>() {
@Override
public IDirectory run() {
return FileSystem.getFSRoot(content);
}
});
result = install(location, directory, deploymentManifest);
return result;
} finally {
// This method must guarantee the content input stream was closed.
// TODO Not sure closing the content is necessary. The content will
// either be null of will have been closed while copying the data
// to the temporary file.
IOUtils.close(content);
// at start time if it contains any dependencies.
if (directory instanceof ICloseableDirectory) {
if (result == null || Utils.isProvisionDependenciesInstall((BasicSubsystem) result) || !wasInstalledWithChildrenHavingProvisionDependenciesResolve()) {
final IDirectory toClose = directory;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
try {
((ICloseableDirectory) toClose).close();
} catch (IOException ioex) {
logger.info("Exception calling close for content {}. Exception {}", content, ioex);
}
return null;
}
});
}
}
}
}
Aggregations