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) { } } }
public DeploymentImpl(VirtualFile rootFile, String location, String symbolicName, Version version) { if (rootFile == null) throw new IllegalArgumentException("Null rootFile"); if (location == null) location = rootFile.getPathName(); if (symbolicName == null) symbolicName = rootFile.getName(); if (version == null) version = Version.emptyVersion; this.rootFile = rootFile; this.location = location; this.symbolicName = symbolicName; this.version = version.toString(); try { this.rootURL = rootFile.toURL(); } catch (IOException ex) { throw new IllegalStateException("Cannot obtain root URL", ex); } }
private void addResources(JavaArchive archive, VirtualFile basedir, VirtualFile resdir) throws IOException { String basepath = basedir.getPathName(); for (final VirtualFile child : resdir.getChildrenRecursively()) { if (child.isDirectory()) continue; String path = child.getPathName(); path = path.substring(basepath.length()); addResource(archive, path, child); } }
public InputStream openStream() { try { return file.openStream(); } catch (IOException ex) { throw new IllegalStateException("Cannot open stream for: " + file, ex); } } };
protected Bundle installBundle(String location) throws BundleException, IOException { try { new URL(location); } catch (Exception e) { location = getTestHelper().getTestArchivePath(location); } return getSystemContext().installBundle(location); }
private BundleHandle installBundle(String location, VirtualFile virtualFile) throws BundleException, IOException { BundleInfo info = BundleInfo.createBundleInfo(virtualFile); URL streamURL = info.getRoot().getStreamURL(); return installBundle(location, streamURL); }
if (file.isDirectory()) path = path.substring(0, path.lastIndexOf("/")); VirtualFile classes = base.getChild(path); addResources(archive, base, classes);
private static URL toURL(VirtualFile file) { try { return file.toURL(); } catch (Exception e) { throw new IllegalArgumentException("Invalid root file: " + file); } }
@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 startBundleRefresh(XBundle bundle) throws BundleException { this.bundle = bundle; XBundleRevision brev = bundle.getBundleRevision(); Deployment deployment = bundle.adapt(Deployment.class); try { InputStream inputStream = deployment.getRoot().getStreamURL().openStream(); rootFile = AbstractVFS.toVirtualFile(inputStream); } catch (IOException ex) { throw FrameworkMessages.MESSAGES.cannotObtainVirtualFile(ex); } bundle.putAttachment(BUNDLE_REFRESHING_KEY, Boolean.TRUE); undeployRevision(brev); }
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) { } } }
@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 OSGiBundle installBundleInternal(BundleInfo info) throws BundleException { try { String location = info.getLocation(); String streamURL = info.getRoot().getStreamURL().toExternalForm(); long bundleId = getFrameworkMBean().installBundleFromURL(location, streamURL); return new RemoteBundle(this, bundleId); } catch (RuntimeException rte) { throw rte; } catch (Exception ex) { throw new BundleException("Cannot install: " + info, ex); } }
@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);