• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BundleRequirement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.osgi.framework.wiring.BundleRequirement的典型用法代码示例。如果您正苦于以下问题:Java BundleRequirement类的具体用法?Java BundleRequirement怎么用?Java BundleRequirement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BundleRequirement类属于org.osgi.framework.wiring包,在下文中一共展示了BundleRequirement类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addingBundle

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
@Override
public Bundle addingBundle(final Bundle bundle, final BundleEvent event) {
  Collection<BundleRequirement> wiredRequirements = resolveWiredRequirements(bundle);

  if (wiredRequirements.size() == 0) {
    return null;
  }

  List<ComponentContainerInstance<?>> containers;
  try {
    containers = addBundleRequirements(bundle, wiredRequirements);
  } catch (RuntimeException e) {
    logService.log(LogService.LOG_ERROR, "Error during processing requirements of bundle: "
        + bundle.getSymbolicName() + ":" + bundle.getVersion(), e);
    return null;
  }

  activeComponentContainers.put(bundle, containers);

  return bundle;
}
 
开发者ID:everit-org,项目名称:ecm-extender-ri,代码行数:22,代码来源:ECMCapabilityTracker.java


示例2: resolveWiredRequirements

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
private Collection<BundleRequirement> resolveWiredRequirements(final Bundle bundle) {
  BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
  List<BundleRequirement> result = new ArrayList<>();

  List<BundleWire> extenderWires =
      bundleWiring.getRequiredWires(ExtenderNamespace.EXTENDER_NAMESPACE);

  Bundle extenderBundle = context.getBundle();

  for (BundleWire bundleWire : extenderWires) {
    if (extenderBundle.equals(bundleWire.getProviderWiring().getBundle())) {

      Map<String, Object> capabilityAttributes = bundleWire.getCapability().getAttributes();
      if (ECMExtenderConstants.EXTENDER_SYMBOLIC_NAME
          .equals(capabilityAttributes.get(ExtenderNamespace.EXTENDER_NAMESPACE))) {
        BundleRequirement requirement = bundleWire.getRequirement();
        result.add(requirement);
      }
    }
  }
  return result;
}
 
开发者ID:everit-org,项目名称:ecm-extender-ri,代码行数:23,代码来源:ECMCapabilityTracker.java


示例3: createMockBundle

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
private BundleInfo createMockBundle( long bundleId, BundleState bundleState, String[] missingDependencies,
    BundleContext bundleContext, BundleService bundleService ) {
  Bundle bundle = mock( Bundle.class );
  when( bundle.getBundleId() ).thenReturn( bundleId );
  String bundleName = WatchersTestUtils.getBundleName( bundleId );
  when( bundle.getSymbolicName() ).thenReturn( bundleName );
  org.apache.karaf.bundle.core.BundleInfo bundleInfo = mock( org.apache.karaf.bundle.core.BundleInfo.class );
  when( bundleInfo.getState() ).thenReturn( bundleState );
  when( bundleService.getInfo( bundle ) ).thenReturn( bundleInfo );

  List<BundleRequirement> unsatisfiedRquirements = null;
  if ( missingDependencies != null ) {
    unsatisfiedRquirements = new ArrayList<BundleRequirement>();
    for ( String missingDependency : missingDependencies ) {
      BundleRequirement requirement = mock( BundleRequirement.class );
      when( requirement.toString() ).thenReturn( missingDependency );
      unsatisfiedRquirements.add( requirement );
    }
  }
  when( bundleService.getUnsatisfiedRquirements( bundle, null ) ).thenReturn( unsatisfiedRquirements );

  BundleInfo featureBundleInfo = mock( BundleInfo.class );
  when( featureBundleInfo.getLocation() ).thenReturn( bundleName );
  when( bundleContext.getBundle( bundleName ) ).thenReturn( bundle );
  return featureBundleInfo;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:27,代码来源:KarafFeatureWatcherImplTest.java


示例4: uniqueRequirementId

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
/**
 * Generates a unique id for given bundle requirement
 *
 * @param bundleRequirement requirement
 * @return unique id in string
 */
public static String uniqueRequirementId(BundleRequirement bundleRequirement) {
    long bundleId = bundleRequirement.getRevision().getBundle().getBundleId();
    String requirementString = "";
    Object requirementName = bundleRequirement.getDirectives().get(REQUIREMENT_FILTER_ATTRIBUTE);
    if (requirementName != null) { // you never know
        requirementString = requirementName.toString();
    }
    StringBuilder sb = new StringBuilder();
    sb.append(bundleId);
    sb.append(PACKAGE_ID_SEPARATOR);
    sb.append(bundleRequirement.getNamespace());
    sb.append(PACKAGE_ID_SEPARATOR);
    sb.append(requirementString);
    return sb.toString();
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:22,代码来源:OsgiResourceUtils.java


示例5: filterMatches

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
@Override
public void filterMatches(BundleRequirement bundleRequirement, Collection<BundleCapability> bundleCapabilities) {
    Bundle bundle = bundleRequirement.getRevision().getBundle();
    String symbolicName = bundle.getSymbolicName();

    log.log(LogLevel.DEBUG, "Filtering matches for " + symbolicName);

    if (symbolicName.startsWith("com.fasterxml.jackson.jaxrs"))
        removeBundlesMatching(bundleCapabilities, JacksonJaxrsResolverHook::isJaxRs1Bundle);
    else if (symbolicName.equals("jackson-jaxrs") && bundle.getVersion().getMajor() == 1) {
        removeBundlesMatching(bundleCapabilities, JacksonJaxrsResolverHook::isJaxRs2Bundle);
    }
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:14,代码来源:JacksonJaxrsResolverHook.java


示例6: hasRequirement

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
private boolean hasRequirement(BundleWiring wiring, String packageName) {
    List<BundleRequirement> reqs = wiring.getRequirements(null);
    for (BundleRequirement req : reqs) {
        String filter = req.getDirectives().get(FILTER);
        if (filter.contains(packageName)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:motech,项目名称:motech,代码行数:11,代码来源:ValidationWeavingHook.java


示例7: getBundleReport

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
private String getBundleReport( BundleService bundleService, List<BundleStateService> bundleStateServices,
    Bundle bundle ) {
  BundleState bundleState = bundleService.getInfo( bundle ).getState();
  long bundleId = bundle.getBundleId();
  String bundleName = bundle.getSymbolicName();

  String bundleReport =
      "Bundle '" + bundleName + "':" + System.lineSeparator() + "\t Bundle State: " + bundleState + System
          .lineSeparator() + "\t Bundle ID: " + bundleId;
  // We loop through the available Bundle State Services and gather diagnostic information, if it exists. Usually,
  // there are two Bundle State Services, the BlueprintStateService and the SpringStateService.
  for ( BundleStateService bundleStateService : bundleStateServices ) {
    String part = bundleStateService.getDiag( bundle );
    if ( part != null ) {
      bundleReport += bundleStateService.getName() + "\n";
      bundleReport += part.replaceAll( "\n", "\n\t" );
    }
  }

  // Unsatisfied Requirements for this bundle, includes optional requirements
  List<BundleRequirement> missingDependencies = bundleService.getUnsatisfiedRquirements( bundle, null );
  if ( missingDependencies != null && missingDependencies.isEmpty() == false ) {
    bundleReport += System.lineSeparator() + "\t Unsatisfied Requirements:";
    for ( BundleRequirement missDependency : missingDependencies ) {
      bundleReport += System.lineSeparator() + "\t\t" + missDependency;
    }
  }

  return bundleReport;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:31,代码来源:KarafFeatureWatcherImpl.java


示例8: metadataFrom

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
/**
 * Write metadata for a bundle requirement
 *
 * @param metadataBuilder   metadata builder object
 * @param bundleRequirement bundle requirement
 * @return the passed builder object with modifications
 */
public static ImmutableResourceMetadata.Builder metadataFrom(ImmutableResourceMetadata.Builder metadataBuilder, BundleRequirement bundleRequirement) {
    ImmutableResourceMetadata.Builder builder = new ImmutableResourceMetadata.Builder();
    for (Map.Entry<String, Object> att : bundleRequirement.getAttributes().entrySet()) {
        builder.set(att.getKey(), att.getValue());
    }
    metadataBuilder.set("attributes",builder.build());
    builder = new ImmutableResourceMetadata.Builder();
    for (Map.Entry<String, String> dir : bundleRequirement.getDirectives().entrySet()) {
        builder.set(dir.getKey(), dir.getValue());
    }
    metadataBuilder.set("directives",builder.build());
    return metadataBuilder;
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:21,代码来源:OsgiResourceUtils.java


示例9: adaptTo

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
@Override
public <A> A adaptTo(Class<A> clazz) {
    if (BundleRequirement.class.equals(clazz)) {
        return (A) m_requirement;
    } else if (BundleRequirementResource.class.equals(clazz)) {
        return (A) this;
    } else {
        return null;
    }
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:11,代码来源:BundleRequirementResource.java


示例10: requirementSatisfiable

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
private boolean requirementSatisfiable(final BundleRequirement requirement,
    final List<BundleCapability> availableCapabilities) {
  for (BundleCapability bundleCapability : availableCapabilities) {
    if (requirement.matches(bundleCapability)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:everit-org,项目名称:eosgi-maven-plugin,代码行数:10,代码来源:AnalyzeMojo.java


示例11: MissingClassAttributeException

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
public MissingClassAttributeException(final BundleRequirement requirement) {
  super("Could not find required '" + ECMExtenderConstants.REQUIREMENT_ATTR_CLASS
      + "' attribute in requirement: " + requirement.toString());
}
 
开发者ID:everit-org,项目名称:ecm-extender-ri,代码行数:5,代码来源:MissingClassAttributeException.java


示例12: ComponentClassNotFoundException

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
public ComponentClassNotFoundException(final BundleRequirement requirement,
    final ClassNotFoundException cause) {
  super("The class defined in requirement could not be found: " + requirement.toString(), cause);
}
 
开发者ID:everit-org,项目名称:ecm-extender-ri,代码行数:5,代码来源:ComponentClassNotFoundException.java


示例13: printMissingRequirements

import org.osgi.framework.wiring.BundleRequirement; //导入依赖的package包/类
private void printMissingRequirements(final Framework osgiContainer) {
  BundleContext systemBundleContext = osgiContainer.getBundleContext();

  ServiceReference<PlatformAdmin> platformServiceSR = systemBundleContext
      .getServiceReference(PlatformAdmin.class);

  PlatformAdmin platformAdmin = systemBundleContext.getService(platformServiceSR);
  State state = platformAdmin.getState();
  Bundle[] bundles = systemBundleContext.getBundles();
  List<BundleCapability> availableCapabilities = getAllCapabilities(bundles, state);

  Map<Bundle, List<ImportPackageSpecification>> requiredMissingByBundle = new TreeMap<>();
  Map<Bundle, List<ImportPackageSpecification>> optionalMissingByBundle = new TreeMap<>();

  for (Bundle bundle : bundles) {
    if (bundle.getState() == Bundle.INSTALLED) {
      List<ImportPackageSpecification> requiredMissings = new ArrayList<>();
      List<ImportPackageSpecification> optionalMissings = new ArrayList<>();

      BundleDescription bundleDescription = state.getBundle(bundle.getBundleId());

      ImportPackageSpecification[] allImports = bundleDescription.getImportPackages();

      for (ImportPackageSpecification importPackage : allImports) {
        BundleRequirement requirement = importPackage.getRequirement();
        if (!requirementSatisfiable(requirement, availableCapabilities)) {
          if (Constants.RESOLUTION_OPTIONAL
              .equals(requirement.getDirectives().get(Constants.RESOLUTION_DIRECTIVE))) {

            optionalMissings.add(importPackage);
          } else {
            requiredMissings.add(importPackage);
          }
        }
      }
      if (optionalMissings.size() > 0) {
        optionalMissingByBundle.put(bundle, optionalMissings);
      }
      if (requiredMissings.size() > 0) {
        requiredMissingByBundle.put(bundle, requiredMissings);
      }
    }
  }

  getLog().info("----- Missing required packages by bundles -----");
  Set<String> requiredSum = printBundlesWithMissingImportsAndSummarize(requiredMissingByBundle);
  getLog().info("");
  getLog().info("");
  getLog().info("----- Missing optional packages by bundles -----");
  Set<String> optionalSum = printBundlesWithMissingImportsAndSummarize(optionalMissingByBundle);
  getLog().info("");
  getLog().info("");
  getLog().info("----- Missing required packages (summary) -----");
  printMissingSummary(requiredSum);
  getLog().info("");
  getLog().info("");
  getLog().info("----- Missing optional packages (summary) -----");
  printMissingSummary(optionalSum);
  getLog().info("");
  getLog().info("");

}
 
开发者ID:everit-org,项目名称:eosgi-maven-plugin,代码行数:63,代码来源:AnalyzeMojo.java



注:本文中的org.osgi.framework.wiring.BundleRequirement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpResponseDecoder类代码示例发布时间:2022-05-23
下一篇:
Java CommandPermissionException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap