org.osgi.framework.Bundle.getVersion()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(140)

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

Bundle.getVersion介绍

[英]Returns the version of this bundle as specified by its Bundle-Version manifest header. If this bundle does not have a specified version then Version#emptyVersion is returned.

This method must continue to return this bundle's version while this bundle is in the UNINSTALLED state.
[中]返回此捆绑包版本清单头指定的捆绑包版本。如果此捆绑包没有指定的版本,则返回版本#emptyVersion。
此捆绑包处于卸载状态时,此方法必须继续返回此捆绑包的版本。

代码示例

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

Bundle getBundle(BundleContext bundleContext, String symbolicName) {
  Bundle result = null;
  for (Bundle candidate : bundleContext.getBundles()) {
    if (candidate.getSymbolicName().equals(symbolicName)) {
      if (result == null || result.getVersion().compareTo(candidate.getVersion()) < 0) {
        result = candidate;
      }
    }
  }
  return result;
}

代码示例来源:origin: org.wisdom-framework/wisdom-monitor

/**
 * @return the display name of the bundle.
 */
public String getName() {
  return bundle.getSymbolicName() + " - " + bundle.getVersion();
}

代码示例来源:origin: org.everit.osgi/org.everit.osgi.loglistener.slf4j

private Logger getLogger(final Bundle bundle) {
  String name = bundle.getSymbolicName();
  Version version = bundle.getVersion();
  if (version == null) {
    version = Version.emptyVersion;
  }
  Logger logger = LoggerFactory.getLogger(name + '.' + version);
  return logger;
}

代码示例来源:origin: com.b2international.snowowl/com.b2international.snowowl.core

/**
 * Logs an error message and Throwable for a bundle.
 * @param bundle in which the error happened
 * @param message error message
 * @param t throwable
 */
public static void logError(final Bundle bundle, final Object message, final Throwable t) {
  final String pluginString = bundle.getSymbolicName() +"("+ bundle.getVersion()+ ")";
  logger.error(message+" in bundle: " + pluginString, t);
}

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

public String toString()
  {
   String shortName = bundle.getSymbolicName() + "-" + bundle.getVersion();
   return "BundleClassLoader[id=" + bundle.getBundleId() + "," + shortName + "]";
  }
}

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

public ExtendedBundleContext(BundleContext paxBundleContext) {
  this.requirePAXWicketBundle =
    createMapWithVersion(OSGI_WIRING_BUNDLE_NAMESPACE, paxBundleContext.getBundle().getSymbolicName(),
      paxBundleContext.getBundle().getVersion());
  this.importPAXWicketAPI =
    createMapWithVersion(OSGI_WIRING_PACKAGE_NAMESPACE, Constants.class.getPackage().getName(),
      paxBundleContext.getBundle().getVersion());
  this.paxBundleContext = paxBundleContext;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.installer.core

private BundleInfo(Bundle b) {
  this.symbolicName = b.getSymbolicName();
  this.version = b.getVersion();
  this.state = b.getState();
  this.id = b.getBundleId();
}

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

public static String[] bundleIds(Bundle bundle) {
    return new String[] {
      String.valueOf(bundle.getBundleId()), bundle.getSymbolicName(), bundle.getVersion().toString()
    };
  }
}

代码示例来源:origin: org.ops4j.pax.web/pax-web-runtime

@Override
public Object addingBundle(Bundle bundle, BundleEvent event) {
  if (symbolicName.equals(bundle.getSymbolicName())) {
    // we have a bundle!
    this.bundle = bundle;
    this.version = bundle.getVersion();
    LOG.info("Found bundle \"" + symbolicName + "\", scheduling customization of its WebContainer");
    configExecutor.execute(this::processContext);
  }
  // we don't actually customize the bundle, so let's not return anything
  return null;
}

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

@Override
  public String call() throws Exception {
    BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
    Bundle sysBundle = context.getBundle(0);
    return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
  }
};

代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.commands

@Override
  public String call() throws Exception {
    BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
    Bundle sysBundle = context.getBundle(0);
    return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
  }
};

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.m2e.core.ui

private String getSourceLabel(Bundle bundle, boolean detailed) {
 StringBuilder sb = new StringBuilder("extension"); //$NON-NLS-1$
 if(detailed) {
  sb.append('(').append(bundle.getSymbolicName()).append('_').append(bundle.getVersion()).append(')');
 }
 return sb.toString();
}

代码示例来源:origin: org.apache.geronimo.samples.osgi/wab-sample

protected void performTask(HttpServletRequest request, HttpServletResponse response){
  PrintWriter pw = null;
  try {
    pw = response.getWriter();
    bundleContext = (BundleContext) sc.getAttribute("osgi-bundlecontext");
    pw.println("Current wab id: " + bundleContext.getBundle().getBundleId() + "\n" + "wab symbolic name : " + bundleContext.getBundle().getSymbolicName() + "\n" + "wab version :" + bundleContext.getBundle().getVersion() +"\n");
      } catch (IOException io){
    
  }
}

代码示例来源:origin: org.apache.aries.blueprint/org.apache.aries.blueprint.core

private void printWarning(Object immutable, String processingType) {
  StringBuilder sb = new StringBuilder("The property placeholder processor for ");
  sb.append(placeholderPrefix).append(',').append(" ").append(placeholderSuffix)
  .append(" in bundle ").append(blueprintBundle.getSymbolicName()).append("/")
  .append(blueprintBundle.getVersion()).append(" found an immutable ").append(processingType)
  .append(" at location ");
  
  for(String s : processingStack) {
    sb.append(s);
  }
  
  sb.append(". This may prevent properties, beans, or other items referenced by this component from being properly processed.");
  
  LOGGER.info(sb.toString());
}

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

public String toString() {
  Bundle b = getBundle();
  StringBuffer result = new StringBuffer(super.toString());
  if (b == null)
    return result.toString();
  return result.append('[').append(b.getSymbolicName()).append(':').append(b.getVersion()).append("(id=").append(b.getBundleId()).append(")]").toString(); //$NON-NLS-1$//$NON-NLS-2$
}

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

public String toString() {
  Bundle b = getBundle();
  StringBuffer result = new StringBuffer(super.toString());
  if (b == null)
    return result.toString();
  return result.append('[').append(b.getSymbolicName()).append(':').append(b.getVersion()).append("(id=").append(b.getBundleId()).append(")]").toString(); //$NON-NLS-1$//$NON-NLS-2$
}

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

public String toString() {
  Bundle b = getBundle();
  StringBuffer result = new StringBuffer(super.toString());
  if (b == null)
    return result.toString();
  return result.append('[').append(b.getSymbolicName()).append(':').append(b.getVersion()).append("(id=").append(b.getBundleId()).append(")]").toString(); //$NON-NLS-1$//$NON-NLS-2$
}

代码示例来源:origin: com.yahoo.vespa/container-core

private String installedBundlesMessage() {
    StringBuilder sb = new StringBuilder("Installed bundles: {" );
    for (Bundle b : osgi.getBundles())
      sb.append("[" + b.getBundleId() + "]" + b.getSymbolicName() + ":" + b.getVersion() + ", ");
    sb.setLength(sb.length() - 2);
    sb.append("}");
    return sb.toString();
  }
}

代码示例来源:origin: de.objekt-kontor/wsc-netty-protocol

@Override
  public void stop(BundleContext context) throws Exception {
    Bundle bundle = context.getBundle();
    log.debug("Stopping bundle: " + bundle.getSymbolicName() + " (" + bundle.getVersion() + " )");
  }
}

代码示例来源:origin: org.eclipse.kura/org.eclipse.kura.core.configuration

synchronized void onBundleRemoved(final Bundle bundle) {
  this.factoryPids.removeIf(factory -> {
    final Bundle provider = factory.getProviderBundle();
    return provider.getSymbolicName().equals(bundle.getSymbolicName())
        && provider.getVersion().equals(bundle.getVersion());
  });
}

相关文章