Package org.osgi.framework

Examples of org.osgi.framework.Version


    for(Iterator it = exportPackages.iterator(); it.hasNext(); ) {
      final String pkgName = (String) it.next();
      sb.append(pkgName);

      final Version pkgVersion = bpInfo.getProvidedPackageVersion(pkgName);
      if (null!=pkgVersion) {
        sb.append(versionPrefix).append(pkgVersion);
      }

      appendUsesDirective(sb, pkgName);
View Full Code Here


      if (null==versionStr) {
        // Fallback to pre OSGi R4 name
        versionKey = "specification-version";
        versionStr = (String) expEntry.remove(versionKey);
      }
      Version version = null;
      if (null!=versionStr) {
        try {
          version = new Version(versionStr);
        } catch (Exception e) {
          final String msg = "Found invalid version value in given "
            +"Export-Package header for the package '"
            +pkgName +"': '"+versionStr +"'; Error: "
            +e.getMessage();
          log(msg, Project.MSG_ERR );
          throw new BuildException(msg, e);
        }
      }
      Version curVersion = bpInfo.getProvidedPackageVersion(pkgName);
      if (null==version && null!=curVersion) {
        // Version is missing, add it
        version = curVersion;
      } else if (null!=version && null!=curVersion
                 && !version.equals(curVersion)) {
View Full Code Here

        version += s;
      }
      if (level<0) {
        return getBundleArchive(name, null, null);
      } else {
        Version min = new Version(version);
        Version max = null;

        switch(level) {
        case 0:
          max = new Version(min.getMajor()+1, 0, 0,"");
          break;
        case 1:
          max = new Version(min.getMajor(), min.getMinor()+1, 0,"");
          break;
        case 2:
          max = new Version(min.getMajor(), min.getMinor(), min.getMicro()+1,
                            "");
          break;
        default:
          max = min;
        }
View Full Code Here

                                   final BundleArchive ba)
  {
    final int ix = ba.bsn.lastIndexOf('.');
    final String aId = -1==ix ? ba.bsn : ba.bsn.substring(ix+1);
    final String gId = -1==ix ? (String) groupId : ba.bsn.substring(0,ix);
    final Version v = ba.version;

    if (null!=gId) {
      el.setAttribute("groupId", gId);
    }
    el.setAttribute("artifactId", aId);
    el.setAttribute("version", v.toString());
  }
View Full Code Here

      upperBoundInclusive = false;
    }

    int splitPos = s.indexOf(",");
    if (-1==splitPos) {
      lowerBound = new Version(s);
      upperBound = null; // Infinity
    } else {
      lowerBound = new Version(s.substring(0,splitPos).trim());
      upperBound = new Version(s.substring(splitPos+1,s.length()).trim());
    }
  }
View Full Code Here

      this.file = resource.getFile();
      this.relPath = resource.getName();

      // The version derived from the file name, to be checked against
      // the version from the manifest.
      Version nameVersion = null;

      // Derive bundle name from the file name
      final String fileName = file.getName();
      String bn = null;
      // The file name format is "<bundleName>-<version>.jar"
      final int ix = fileName.lastIndexOf('-');
      if (0 < ix) {
        bn = fileName.substring(0, ix);
        final String versionS = fileName.substring(ix + 1,
                                                   fileName.length() - 4);
        try {
          nameVersion = new Version(versionS);
        } catch (NumberFormatException nfe) {
          bn = null; // Not valid due to missing version.
          task.log("Invalid version in bundle file name '" + versionS + "': "
                   + nfe, Project.MSG_VERBOSE);
        }
      } else {
        // No version in file name, just remove the ".jar"-suffix
        bn = fileName.substring(0, fileName.length() - 4);
      }

      final JarFile bundle = new JarFile(file);
      try {
        final Manifest manifest = bundle.getManifest();
        this.mainAttributes = manifest.getMainAttributes();
        this.manifestVersion = deriveBundleManifestVersion();
        this.bsn = deriveBundleSymbolicName();
        this.version = deriveBundleVersion();
        this.name = mainAttributes.getValue(Constants.BUNDLE_NAME);

        int count = 0;
        for (Enumeration e = bundle.entries(); e.hasMoreElements();) {
          ZipEntry entry = (ZipEntry) e.nextElement();

          if (entry.getName().startsWith(SRC_PREFIX)) {
            count++;
          }
        }
        srcCount = count;

      } finally {
        if (null != bundle) {
          try {
            bundle.close();
          } catch (IOException _ioe) {
          }
        }
      }

      // Compare version from the file name with the one from the manifest
      if (null != nameVersion && 0 != nameVersion.compareTo(version)) {
        if (nameVersion.getMajor() == version.getMajor()
            && nameVersion.getMinor() == version.getMinor()
            && nameVersion.getMicro() == version.getMicro()
            && "".equals(nameVersion.getQualifier())) {
          task.log("Found version '" + nameVersion + "' in the file name '"
                   + fileName + "', but the version in the bundle's manifest "
                   + "has qualifier '" + version + "'.", Project.MSG_DEBUG);
        } else {
          task.log("Found version '" + nameVersion + "' in the file name '"
View Full Code Here

      if (null == versionS) {
        return Version.emptyVersion;
      }

      try {
        return new Version(versionS);
      } catch (NumberFormatException nfe) {
        if ("1".equals(manifestVersion)) {
          // Pre OSGi R4 bundle with non-standard version format; use
          // the default version.
          return Version.emptyVersion;
View Full Code Here

        }
        if (null == versionS) {
          versionS = "0"; // The default version
        }
        final Object version = range ? (Object) new VersionRange(versionS)
          : (Object) new Version(versionS);

        final Iterator nameIter = ((List) pathMap.get("$keys")).iterator();
        while (nameIter.hasNext()) {
          final String pkgName = (String) nameIter.next();
          res.put(pkgName, version);
View Full Code Here

              line = line.substring(ix + keyWord.length()).trim();
              ix = line.indexOf(" ");
              if (ix!=-1) {
                line = line.substring(0, ix);
              }
              Version version = new Version(line);
              Bundle sysBundle = Activator.getBC().getBundle(0);
              Version sysVersion = new Version((String)sysBundle.getHeaders().get("Bundle-Version"));

              Activator.log.info("sysVersion=" + sysVersion
                                 +", version=" + version);
              if(sysVersion.compareTo(version) < 0) {
                showUpdate(sysVersion, version, notes);
              }
            } else {
              Activator.log.warn("No version info in " + line);
            }
View Full Code Here

   Activator.log.info("showUpdate sysVersion=" + sysVersion + ", version=" + version);
   try {
     String prefsVersionS = prefs.get(KEY_UPDATEVERSION, "");
     if(prefsVersionS != null && !"".equals(prefsVersionS)) {
       Version prefsVersion = new Version(prefsVersionS);
       Activator.log.info("prefsVersion=" + prefsVersion);
       if(prefsVersion.compareTo(version) >= 0) {
         Activator.log.info("skip showUpdate " + version);
         return;
       }
     }
   } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.osgi.framework.Version

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.