private static List<BundleCapability> aliasSymbolicName(List<BundleCapability> caps) {
    if (caps == null) {
      return new ArrayList<BundleCapability>(0);
    }

    List<BundleCapability> aliasCaps = new ArrayList<BundleCapability>(caps);

    String[] aliases = {
      FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME, Constants.SYSTEM_BUNDLE_SYMBOLICNAME
    };

    for (int capIdx = 0; capIdx < aliasCaps.size(); capIdx++) {
      BundleCapability cap = aliasCaps.get(capIdx);

      // Need to alias bundle and host capabilities.
      if (cap.getNamespace().equals(BundleRevision.BUNDLE_NAMESPACE)
          || cap.getNamespace().equals(BundleRevision.HOST_NAMESPACE)) {
        // Make a copy of the attribute array.
        Map<String, Object> aliasAttrs = new HashMap<String, Object>(cap.getAttributes());
        // Add the aliased value.
        aliasAttrs.put(cap.getNamespace(), aliases);
        // Create the aliased capability to replace the old capability.
        cap =
            new BundleCapabilityImpl(
                cap.getRevision(), cap.getNamespace(), cap.getDirectives(), aliasAttrs);
        aliasCaps.set(capIdx, cap);
      }

      // Further, search attributes for bundle symbolic name and alias it too.
      for (Entry<String, Object> entry : cap.getAttributes().entrySet()) {
        // If there is a bundle symbolic name attribute, add the
        // standard alias as a value.
        if (entry.getKey().equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE)) {
          // Make a copy of the attribute array.
          Map<String, Object> aliasAttrs = new HashMap<String, Object>(cap.getAttributes());
          // Add the aliased value.
          aliasAttrs.put(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, aliases);
          // Create the aliased capability to replace the old capability.
          aliasCaps.set(
              capIdx,
              new BundleCapabilityImpl(
                  cap.getRevision(), cap.getNamespace(), cap.getDirectives(), aliasAttrs));
          // Continue with the next capability.
          break;
        }
      }
    }

    return aliasCaps;
  }
Ejemplo n.º 2
0
 private CapabilityRefDTO getCapabilityRefDTO(BundleCapability cap) {
   if (cap == null) {
     return null;
   }
   CapabilityRefDTO dto = new CapabilityRefDTO();
   dto.capability = identifier(cap);
   dto.resource = getResourceId(cap.getRevision());
   return dto;
 }
Ejemplo n.º 3
0
 private CapabilityDTO getCapabilityDTO(BundleCapability cap) {
   if (cap == null) {
     return null;
   }
   CapabilityDTO dto = new CapabilityDTO();
   dto.id = identifier(cap);
   dto.namespace = cap.getNamespace();
   dto.resource = getResourceId(cap.getRevision());
   dto.attributes = newAttributesMapDTO(cap.getAttributes());
   dto.directives = newDirectivesMapDTO(cap.getDirectives());
   return dto;
 }