public InputStream openStream() { try { return file.openStream(); } catch (IOException ex) { throw new IllegalStateException("Cannot open stream for: " + file, ex); } } };
public static Manifest getManifest(VirtualFile archive) throws IOException { if (archive == null) throw new IllegalArgumentException("Null archive"); VirtualFile manifest = archive.getChild(JarFile.MANIFEST_NAME); if (manifest == null) return null; InputStream stream = manifest.openStream(); try { return new Manifest(stream); } finally { try { stream.close(); } catch (IOException ignored) { } } }
public static Manifest getManifest(VirtualFile archive) throws IOException { if (archive == null) throw MESSAGES.illegalArgumentNull("archive"); VirtualFile manifest = archive.getChild(JarFile.MANIFEST_NAME); if (manifest == null) return null; InputStream stream = manifest.openStream(); try { return new Manifest(stream); } finally { try { stream.close(); } catch (IOException ignored) { } } }
protected Bundle installBundle(String location) throws BundleException, IOException { try { new URL(location); } catch (Exception e) { location = getTestHelper().getTestArchivePath(location); } return getSystemContext().installBundle(location); }
@Override OSGiBundle installBundleInternal(BundleInfo info) throws BundleException { try { VirtualFile rootFile = info.getRoot(); BundleContext context = getSystemContext(); Bundle auxBundle = context.installBundle(info.getLocation(), rootFile.openStream()); return new EmbeddedBundle(this, auxBundle); } catch (IOException ex) { throw new BundleException("Cannot install bundle: " + info, ex); } }
@Override public void refreshCurrentRevision(XBundleRevision brev) throws BundleException { // Create the revision {@link Deployment} DeploymentProvider deploymentManager = injectedDeploymentManager.getValue(); Deployment deployment = deploymentManager.createDeployment(bundle.getLocation(), rootFile); deployment.putAttachment(IntegrationConstants.BUNDLE_KEY, bundle); deployment.setAutoStart(false); String runtimeName = getRuntimeName(deployment); putDeployment(runtimeName, deployment); try { InputStream input = deployment.getRoot().openStream(); try { ServerDeploymentHelper server = new ServerDeploymentHelper(serverDeploymentManager); server.deploy(runtimeName, input); } finally { VFSUtils.safeClose(input); } } catch (RuntimeException rte) { throw rte; } catch (Exception ex) { throw MESSAGES.cannotDeployBundleRevision(ex, deployment); } }
@Override public void install(Deployment dep) throws BundleException { // Do the install directly if we have a running management op // https://issues.jboss.org/browse/AS7-5642 if (OperationAssociation.INSTANCE.getAssociation() != null) { LOGGER.warnCannotDeployBundleFromManagementOperation(dep); BundleManager bundleManager = injectedBundleManager.getValue(); bundleManager.installBundle(dep, null, null); } else { LOGGER.debugf("Install deployment: %s", dep); String runtimeName = getRuntimeName(dep); putDeployment(runtimeName, dep); try { InputStream input = dep.getRoot().openStream(); try { ServerDeploymentHelper server = new ServerDeploymentHelper(deploymentManager); server.deploy(runtimeName, input); } finally { VFSUtils.safeClose(input); } } catch (RuntimeException rte) { throw rte; } catch (Exception ex) { throw MESSAGES.cannotDeployBundle(ex, dep); } } }
putDeployment(runtimeName, deployment); try { InputStream input = deployment.getRoot().openStream(); try { ServerDeploymentHelper server = new ServerDeploymentHelper(serverDeploymentManager);