org.osgi.framework.Version类的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.osgi.framework.Version类的一些代码示例,展示了Version类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version类的具体详情如下:
包路径:org.osgi.framework.Version
类名称:Version

Version介绍

[英]Version identifier for capabilities such as bundles and packages.

Version identifiers have four components.

  1. Major version. A non-negative integer.
  2. Minor version. A non-negative integer.
  3. Micro version. A non-negative integer.
  4. Qualifier. A text string. See Version(String) for the format of the qualifier string.

Version objects are immutable.
[中]捆绑包和包等功能的版本标识符。
版本标识符有四个组件。
1.主要版本。非负整数。
1.次要版本。非负整数。
1.微型版。非负整数。
1.限定符。文本字符串。有关限定符字符串的格式,请参见版本(字符串)。
版本对象是不可变的。

代码示例

代码示例来源:origin: org.osgi/org.osgi.core

/**
 * Returns the string representation of this version range.
 * 
 * <p>
 * The format of the version range string will be a version string if the
 * right end point is <i>Infinity</i> ({@code null}) or an interval string.
 * 
 * @return The string representation of this version range.
 */
@Override
public String toString() {
  String s = versionRangeString;
  if (s != null) {
    return s;
  }
  String leftVersion = left.toString();
  if (right == null) {
    StringBuffer result = new StringBuffer(leftVersion.length() + 1);
    result.append(left.toString0());
    return versionRangeString = result.toString();
  }
  String rightVerion = right.toString();
  StringBuffer result = new StringBuffer(leftVersion.length() + rightVerion.length() + 5);
  result.append(leftClosed ? LEFT_CLOSED : LEFT_OPEN);
  result.append(left.toString0());
  result.append(ENDPOINT_DELIMITER);
  result.append(right.toString0());
  result.append(rightClosed ? RIGHT_CLOSED : RIGHT_OPEN);
  return versionRangeString = result.toString();
}

代码示例来源:origin: org.osgi/org.osgi.core

if (rightClosed) {
  return left.equals(right);
} else {
  Version adjacent1 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "-");
  return adjacent1.compareTo(right) >= 0;
  Version adjacent1 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "-");
  return adjacent1.equals(right);
} else {
  Version adjacent2 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "--");
  return adjacent2.compareTo(right) >= 0;

代码示例来源:origin: org.osgi/org.osgi.compendium

throw iae;
return Version.parseVersion(version);

代码示例来源:origin: stackoverflow.com

LongJsonDeserializer deserializer = new LongJsonDeserializer();

SimpleModule module =
 new SimpleModule("LongDeserializerModule",
   new Version(1, 0, 0, null));
module.addDeserializer(Long.class, deserializer);

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(module);

代码示例来源:origin: stackoverflow.com

ObjectMapper mapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule("SimpleModule", 
                     new Version(1,0,0,null));
// simpleModule.addSerializer(new ItemSerializer());
simpleModule.addSerializer(Item.class, new ItemSerializer());
mapper.registerModule(simpleModule);

代码示例来源:origin: apache/cxf

private Version getBundleVersion(Bundle bundle) {
  Dictionary<?, ?> headers = bundle.getHeaders();
  String version = (String) headers.get(Constants.BUNDLE_VERSION);
  return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
}

代码示例来源:origin: stackoverflow.com

SimpleModule module =
 new SimpleModule("ProductDeserializerModule",
   new Version(1, 0, 0, null));
module.addDeserializer(Product.class, new ProductJsonDeserializer());

mapper = new ObjectMapper();
mapper.registerModule(module);

代码示例来源:origin: stackoverflow.com

ObjectMapper mapper = new ObjectMapper();

// add module for meta data permissions
SimpleModule module = new SimpleModule("IncludeMetaData", new Version(0, 1, 0, "alpha"));
module.addSerializer(MetaClass.class, new MetaDataSerializer(permissions, p instanceof AbstractBean ? ((AbstractBean) p).isOwner() : false));
mapper.registerModule(module);

// ignore missing filters
mapper.setFilters(new SimpleFilterProvider().setFailOnUnknownId(false));

return mapper.writerWithView(Views.Admin.class).writeValueAsString(p)

代码示例来源:origin: net.osgiliath.framework/net.osgiliath.helper.pax-jpa.tx

private void assignPersistenceUnit(PersistenceUnitInfoImpl puInfo) {
  PersistenceProvider provider = puInfo.getProvider();
  Bundle bundle = puInfo.getBundle();
  EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilderImpl(puInfo);
  Dictionary<String, String> emfBuilderServiceProps = new Hashtable<String, String>();
  emfBuilderServiceProps.put(JPA_UNIT_NAME, puInfo.getPersistenceUnitName());
  emfBuilderServiceProps.put(JPA_UNIT_VERSION, bundle.getVersion().toString());
  emfBuilderServiceProps.put(JPA_UNIT_PROVIDER, provider.getClass().getName());
  ServiceRegistration<EntityManagerFactoryBuilder> builderReg = bundle.getBundleContext()
    .registerService(EntityManagerFactoryBuilder.class, builder, emfBuilderServiceProps);
  puInfo.setEmfBuilderRegistration(builderReg);
  puInfo.setState(PersistenceUnitState.READY);
}

代码示例来源:origin: org.osgi/osgi.enroute.web.simple.provider

private Bundle getBundle(String bsn, String version) {
  Version v = new Version(version);
  BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
  for (Bundle b : context.getBundles()) {
    if (bsn.equals(b.getSymbolicName()) && v.equals(b.getVersion()))
      return b;
  }
  return null;
}

代码示例来源:origin: org.jboss.arquillian.container/arquillian-container-osgi

@Override
public void startBundle(String symbolicName, String version) throws Exception {
  for (Bundle bundle : syscontext.getBundles()) {
    if (bundle.getSymbolicName().equals(symbolicName) && bundle.getVersion().toString().equals(version)) {
      bundle.start();
      return;
    }
  }
  throw new IllegalStateException("Bundle '" + symbolicName + ":" + version + "' was not found");
}

代码示例来源:origin: ontop/ontop

public OSGiJdbcDriver(BundleContext context, JdbcRegistry registry) {
  String versionString = (String) context.getBundle().getHeaders().get(Constants.BUNDLE_VERSION);
  Version version = new Version(versionString);
  majorVersion = version.getMajor();
  minorVersion = version.getMinor();
  this.registry = registry;
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

/**
 * @return the Java Language Server version
 */
public static String getVersion() {
  return context == null ? "Unknown" : context.getBundle().getVersion().toString();
}

代码示例来源:origin: org.eclipse/osgi

public static BundleDTO newBundleDTO(Bundle bundle) {
  if (bundle == null) {
    return null;
  }
  BundleDTO dto = new BundleDTO();
  dto.id = bundle.getBundleId();
  dto.lastModified = bundle.getLastModified();
  dto.state = bundle.getState();
  dto.symbolicName = bundle.getSymbolicName();
  dto.version = bundle.getVersion().toString();
  return dto;
}

代码示例来源:origin: org.sonatype.tycho/maven-osgi-source-plugin

private Version getExpandedVersion(String versionStr)
{
  Version version = Version.parseVersion( versionStr );
  if ( VERSION_QUALIFIER.equals(version.getQualifier()) )
  {
    return new Version(version.getMajor(), version.getMinor(), version.getMicro(), qualifier);
  }
  return version;
}

代码示例来源:origin: org.ops4j.pax.logging/pax-logging-service

public static String getVersion(Bundle bundle) {
  if (osgiVersion >= OSGI_1_5) {
    return bundle.getVersion().toString();
  }
   return (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION);
}

代码示例来源:origin: org.openhab.binding/org.openhab.binding.zwave

@Override
public String getVersion() {
  return FrameworkUtil.getBundle(getClass()).getBundleContext().getBundle().getVersion().toString();
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-tools

private static boolean checkMDCSupport(BundleContext context) {
  //MDC support is present since 1.0.9                     s
  Version versionWithMDCSupport = new Version(1, 0, 9);
  for (Bundle b : context.getBundles()) {
    if ("org.apache.jackrabbit.oak-core".equals(b.getSymbolicName())) {
      return versionWithMDCSupport.compareTo(b.getVersion()) <= 0;
    }
  }
  //By default it is assumed that MDC support is present
  return true;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
  public boolean apply(Bundle input) {
    return input.getSymbolicName() != null && input.getVersion() != null &&
        symbolicName.matcher(input.getSymbolicName()).matches() &&
        (version == null || version.matcher(input.getVersion().toString()).matches());
  }
}

代码示例来源:origin: apache/ace

private URL getEndpoint(URL serverURL, String identification, Version version) {
  try {
    return new URL(serverURL, "agent/" + identification + "/" + m_bundleContext.getBundle().getSymbolicName() + "/versions/" + (version == null ? "" : version.toString()));
  }
  catch (MalformedURLException e) {
    throw new IllegalStateException(e);
  }
}

相关文章