aQute.bnd.osgi.Analyzer.findClasspathEntry()方法的使用及代码示例

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

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

Analyzer.findClasspathEntry介绍

[英]Find a class path entry based on bsn and versionrange
[中]根据bsn和versionrange查找类路径条目

代码示例

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * Get the packages from the host if this is a fragment bundle
 * 
 * @return the host packages or an empty set if not a fragment
 */
public Optional<Set<PackageRef>> getHostPackages() {
  Entry<String, Attrs> host = getFragmentHost();
  if (host != null) {
    String bsn = host.getKey();
    String v = host.getValue()
      .get(Constants.BUNDLE_VERSION_ATTRIBUTE);
    Jar jar = findClasspathEntry(bsn, v);
    if (jar != null) {
      return Optional.of(jar.getDirectories()
        .keySet()
        .stream()
        .map(this::getPackageRef)
        .filter(pRef -> !(pRef.isJava() || pRef.isMetaData() || pRef.isDefaultPackage()))
        .collect(Collectors.toSet()));
    }
    warning("Host %s for this fragment cannot be found on the classpath", host);
  }
  return Optional.empty();
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

/**
 * Get the packages from the host if this is a fragment bundle
 * 
 * @return the host packages or an empty set if not a fragment
 */
public Optional<Set<PackageRef>> getHostPackages() {
  Entry<String, Attrs> host = getFragmentHost();
  if (host != null) {
    String bsn = host.getKey();
    String v = host.getValue()
      .get(Constants.BUNDLE_VERSION_ATTRIBUTE);
    Jar jar = findClasspathEntry(bsn, v);
    if (jar != null) {
      return Optional.of(jar.getDirectories()
        .keySet()
        .stream()
        .map(this::getPackageRef)
        .filter(pRef -> !(pRef.isJava() || pRef.isMetaData() || pRef.isDefaultPackage()))
        .collect(Collectors.toSet()));
    }
    warning("Host %s for this fragment cannot be found on the classpath", host);
  }
  return Optional.empty();
}

相关文章

Analyzer类方法