Package uk.co.brunella.osgi.bdt.bundle

Examples of uk.co.brunella.osgi.bdt.bundle.BundleDescriptor


    ExportPackage[] exportPackages = repository.resolve(packageName, versionRange, true);
    if (exportPackages.length == 0) {
      System.out.println("No match found");
    } else {
      for (ExportPackage exportPackage : exportPackages) {
        BundleDescriptor descriptor = exportPackage.getBundleDescriptor();
        System.out.println(exportPackage.getName() + " " + exportPackage.getVersion() +
            " [" + descriptor.getBundleSymbolicName() + " " + descriptor.getBundleVersion() + "]");
      }
    }
   
    return true;
  }
View Full Code Here


      stopFramework();
    }
  }
 
  private void addRequiredBundleFromTest(OSGiBundleDescriptor descriptor) {
    BundleDescriptor bundleDescriptor = resolveBundle(descriptor);
    File bundleFile = bundleFile(bundleDescriptor);
    try {
      JarFile bundleJarFile = new JarFile(bundleFile);
      ZipEntry entry = bundleJarFile.getEntry("META-INF/osgi-bdt-testcase.xml");
      if (entry != null) {
View Full Code Here

    logClear();
    log("Deploying bundle " + sourceBundleFile);

    // undeploy existing bundle
    JarFile originalJarFile = new JarFile(sourceBundleFile);
    BundleDescriptor originalDescriptor = new BundleDescriptor(originalJarFile.getName(), originalJarFile.getManifest());
    originalJarFile.close();
    undeploy(originalDescriptor.getBundleSymbolicName(), originalDescriptor.getBundleVersion(), false);
   
    // try to lock the repository
    if (persister.lock(MAX_WAIT_TIME_IN_MILLIS)) {
      try {
        // copy the bundle to the bundles directory
        File bundleFile = copyBundle(sourceBundleFile);
        // get the bundle descriptor
        JarFile bundleJarFile = new JarFile(bundleFile);
        BundleDescriptor descriptor = new BundleDescriptor(bundleFile.getName(), bundleJarFile.getManifest());
        bundleJarFile.close();
        // unpack the bundle to extracted directory
        File extractDirectory = new File(bundleExtractedDirectory, descriptor.getBundleSymbolicName() + "_" + descriptor.getBundleVersion());
        FileUtils.deleteDir(extractDirectory);
        extractBundle(bundleFile, extractDirectory, false);
        // unpack the bundle to extracted directory
        File tempExtractDirectory = new File(tempDirectory, bundleFile.getName());
        extractBundle(bundleFile, tempExtractDirectory, true);
View Full Code Here

    }
    // try to lock the repository
    if (persister.lock(MAX_WAIT_TIME_IN_MILLIS)) {
      try {
        BundleRepository repository = persister.load();
        BundleDescriptor descriptor = repository.removeBundleDescriptor(bundleSymbolicName, bundleVersionRange);
        if (descriptor != null) {
          persister.save(repository);
          File bundleJar = new File(bundleDirectory, descriptor.getBundleJarFileName());
          bundleJar.delete();
          File packageDir = new File(packageDirectory, descriptor.getBundleSymbolicName() + File.separator
              + descriptor.getBundleVersion());
          FileUtils.deleteDir(packageDir);
          File[] children = packageDir.getParentFile().listFiles();
          if (children == null || children.length == 0) {
            FileUtils.deleteDir(packageDir.getParentFile());
          }
View Full Code Here

      name = bundleName;
      versionRange = VersionRange.parseVersionRange("");
    }
    BundleDescriptor[] descriptors = repository.resolveBundle(name, versionRange, true);
    if (descriptors.length > 0) {
      BundleDescriptor descriptor = descriptors[0];
      File bundleJarFile = new File(repository.getLocation(), Deployer.BUNDLES_DIRECTORY + File.separator + descriptor.getBundleJarFileName());
      return bundleJarFile;
    } else {
      throw new RuntimeException("Cannot find bundle " + bundleName);
    }
  }
View Full Code Here

 
  private void checkAndSetDirtyFlag() {
    for (BundleDescriptor descriptor : buildRepository.getBundleDescriptors()) {
      BuildBundleDescriptor buildDescriptor = (BuildBundleDescriptor) descriptor;
      // check if already deployed in deploy repository
      BundleDescriptor deployedDescriptor = deployRepository.findBundleDescriptor(buildDescriptor.getBundleSymbolicName(), buildDescriptor.getBundleVersion());
      if (deployedDescriptor != null) {
        buildDescriptor.setDirty(isDirty(
            new File(deployRepository.getLocation(), "bundles/" + deployedDescriptor.getBundleJarFileName()),
            buildDescriptor.getProjectDirectory()));
      } else {
        buildDescriptor.setDirty(true);
      }
    }
View Full Code Here

  public void setManifest(File manifestFile) {
    FileInputStream fis = null;
    try {
      fis = new FileInputStream(manifestFile);
      Manifest manifest = new Manifest(fis);
      descriptor = new BundleDescriptor("", manifest);
    } catch (IOException e) {
      throw new BuildException(e.getMessage());
    } finally {
      if (fis != null) {
        try {
View Full Code Here

   
    // add fragment host bundle
    if (descriptor.getFragmentHost() != null) {
      BundleDescriptor[] hosts = repository.resolveBundle(descriptor.getFragmentHost(), descriptor.getFragmentHostVersionRange(), true);
      if (hosts.length > 0) {
        BundleDescriptor fragmentHost = hosts[0];
        importedBundles.add(fragmentHost);
        // resolve the fragment host
        resolveBundle(0, fragmentHost, repository);
      } else {
        if (failOnUnresolved || failOnUnresolvedMandatory) {
          throw new BuildException("Cannot resolve fragment host bundle for " + descriptor.getFragmentHost());
        }
      }
    }

    resolveBundle(0, descriptor, repository);
   
    if (unresolved.size() > 0) {
      StringBuilder sb = new StringBuilder();
      sb.append("Could not resolve imports:\n");
      boolean mandatoryUnresolved = false;
      for (ImportPackage importPackage : unresolved) {
        if (importPackage.isMandatory()) {
          mandatoryUnresolved = true;
          sb.append('\t').append(importPackage.getName()).append(' ').append(importPackage.getVersionRange()).append('\n');
        } else {
          sb.append('\t').append(importPackage.getName()).append(' ').append(importPackage.getVersionRange()).append(" [optional]\n");
        }
      }
      if (failOnUnresolved || (mandatoryUnresolved && failOnUnresolvedMandatory)) {
        throw new BuildException(sb.toString());
      } else {
        log(sb.toString(), Project.MSG_ERR);
      }
    }
    if (verbose) {
      log("Classpath elements:");
    }
   
    if (resolveToBundle) {
      for (ExportPackage exportPackage : resolved) {
        BundleDescriptor exportDescriptor = exportPackage.getBundleDescriptor();
        if (exportDescriptor != null) {
          importedBundles.add(exportDescriptor);
        }
      }
    } else {
      for (ExportPackage exportPackage : resolved) {
        BundleDescriptor exportDescriptor = exportPackage.getBundleDescriptor();
        // bundle descriptor is null for system packages
        if (exportDescriptor != null) {
          File path = new File(repositoryDirectory, "packages" + File.separator +
              exportDescriptor.getBundleSymbolicName() + File.separator + exportDescriptor.getBundleVersion() +
              File.separator + exportPackage.getName() + File.separator + exportPackage.getVersion());
          if (verbose) {
            log("\t" + path.toString());
          }
          createPathElement().setPath(path.toString());
View Full Code Here

      name = bundleName;
      versionRange = VersionRange.parseVersionRange("");
    }
    BundleDescriptor[] descriptors = repository.resolveBundle(name, versionRange, true);
    if (descriptors.length > 0) {
      BundleDescriptor descriptor = descriptors[0];
      File bundleJarFile = new File(repository.getLocation(), Deployer.BUNDLES_DIRECTORY + File.separator + descriptor.getBundleJarFileName());
      return bundleJarFile;
    } else {
      throw new RuntimeException("Cannot find bundle " + bundleName);
    }
  }
View Full Code Here

    actionRemoveBundle = new Action() {
      public void run() {
        ISelection selection = viewer.getSelection();
        TreeObject selectedItem = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
        BundleDescriptor descriptor = (BundleDescriptor) selectedItem.getValue();
        if (MessageDialog.openConfirm(getShell(), "Removing bundle", "Are you sure to remove bundle\n"
            + descriptor.getBundleSymbolicName() + " (" + descriptor.getBundleVersion() + ")")) {
          ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getShell());
          try {
            progressDialog.run(true, false, new BundleUndeployJob(getRepositoryLocation(selectedItem.getParent()),
                descriptor.getBundleSymbolicName(), descriptor.getBundleVersion()));
            viewer.refresh();
          } catch (InvocationTargetException e) {
            MessageDialog.openError(getShell(), "Add bundle", "Could not remove bundle\n"
                + e.getTargetException().getMessage());
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of uk.co.brunella.osgi.bdt.bundle.BundleDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.