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

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

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

Bundle.getSymbolicName介绍

[英]Returns the symbolic name of this bundle as specified by its Bundle-SymbolicName manifest header. The bundle symbolic name should be based on the reverse domain name naming convention like that used for java packages.

This method must continue to return this bundle's symbolic name while this bundle is in the UNINSTALLED state.
[中]返回此捆绑包的符号名称,该名称由其捆绑包符号名称清单头指定。捆绑包符号名应基于与java包类似的反向域名命名约定。
此捆绑包处于卸载状态时,此方法必须继续返回此捆绑包的符号名称。

代码示例

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

/**
   * Builds a {@link ClassNotFoundException}.
   *
   * @param clsName Class name.
   * @return The exception.
   */
  protected ClassNotFoundException classNotFoundException(String clsName) {
    String s = "Failed to resolve class [name=" + clsName +
      ", bundleId=" + bundle.getBundleId() +
      ", symbolicName=" + bundle.getSymbolicName() +
      ", fallbackClsLdr=" + clsLdr + ']';

    return new ClassNotFoundException(s);
  }
}

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

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

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

private String getBundleIdentity(final Bundle bundle) {
  if ( bundle.getSymbolicName() == null ) {
    return bundle.getBundleId() + " (" + bundle.getLocation() + ")";
  } else {
    return bundle.getSymbolicName() + ":" + bundle.getVersion() + " (" + bundle.getBundleId() + ")";
  }
}

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

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

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

public Void run() {
    map.put("id", new Long(bundle.getBundleId()));
    map.put("location", bundle.getLocation());
    String name = bundle.getSymbolicName();
    if (name != null) {
      map.put("name", name);
    }
    SignerProperty signer = new SignerProperty(bundle);
    if (signer.isBundleSigned()) {
      map.put("signer", signer);
    }
    return null;
  }
});

代码示例来源: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.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.osgi/org.osgi.core

public Void run() {
    props.put("id", new Long(bundle.getBundleId()));
    props.put("location", bundle.getLocation());
    String name = bundle.getSymbolicName();
    if (name != null) {
      props.put("name", name);
    }
    SignerProperty signer = new SignerProperty(bundle);
    if (signer.isBundleSigned()) {
      props.put("signer", signer);
    }
    return null;
  }
});

代码示例来源: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: apache/felix

private String getInfo(final T service, final ServiceReference<T> ref)
{
  return "Service " + ref.getProperty(Constants.SERVICE_PID) + " from bundle "
      + ref.getBundle().getBundleId()
      + (ref.getBundle().getSymbolicName() != null ? ref.getBundle().getSymbolicName() + ":" + ref.getBundle().getVersion() : "")
      + " class " + service.getClass();
}

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

public Void run() {
    props.put("id", new Long(bundle.getBundleId()));
    props.put("location", bundle.getLocation());
    String name = bundle.getSymbolicName();
    if (name != null) {
      props.put("name", name);
    }
    SignerProperty signer = new SignerProperty(bundle);
    if (signer.isBundleSigned()) {
      props.put("signer", signer);
    }
    return null;
  }
});

代码示例来源: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: 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.osgi/org.osgi.core

public Void run() {
    map.put("id", new Long(bundle.getBundleId()));
    map.put("location", bundle.getLocation());
    String name = bundle.getSymbolicName();
    if (name != null) {
      map.put("name", name);
    }
    SignerProperty signer = new SignerProperty(bundle);
    if (signer.isBundleSigned()) {
      map.put("signer", signer);
    }
    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.felix/org.apache.felix.http.whiteboard

private String getInfo(final T service, final ServiceReference<T> ref)
{
  return "Service " + ref.getProperty(Constants.SERVICE_PID) + " from bundle "
      + ref.getBundle().getBundleId()
      + (ref.getBundle().getSymbolicName() != null ? ref.getBundle().getSymbolicName() + ":" + ref.getBundle().getVersion() : "")
      + " class " + service.getClass();
}

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

public Void run() {
    map.put("id", new Long(bundle.getBundleId()));
    map.put("location", bundle.getLocation());
    String name = bundle.getSymbolicName();
    if (name != null) {
      map.put("name", name);
    }
    SignerProperty signer = new SignerProperty(bundle);
    if (signer.isBundleSigned()) {
      map.put("signer", signer);
    }
    return null;
  }
});

代码示例来源: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.geronimo.framework/geronimo-bundle-recorder

@Override
public long getBundleId(String symbolicName, String version) {
  for (Bundle bundle : bundleContext.getBundles()) {
    if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion().toString())){
      return bundle.getBundleId();
    }
  }
  return -1;
}

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

@Override
public void bundleChanged(final BundleEvent event) {
  if (event.getType() == BundleEvent.RESOLVED) {
    register(event.getBundle());
  } else if (event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
    final Bundle unregisteredBundle = event.getBundle();
    lock.writeLock().lock();
    try {
      factories.remove(unregisteredBundle.getBundleId());
      if (unregisteredBundle.getSymbolicName().equals(CoreBundleSymbolicNAME)) {
        bundleContext.removeBundleListener(this);
        factories.clear();
      }
    } finally {
      lock.writeLock().unlock();
    }
  }
}

相关文章