docs: private String evaluateReference(String id, ExtendedAttributeDefinition attrDef, EvaluationContext context) throws ConfigEvaluatorException {
  
          if (attrDef.getReferencePid() != null) {
              String referencePid = attrDef.getReferencePid();
              if (metatypeRegistry.getRegistryEntry(referencePid) == null) {
                  //We don't know about this reference pid.  If it shows up later, we will reprocess this configuration
                  return null;
              }
              ConfigID referenceId = new ConfigID(referencePid, id);
              String pid = lookupPid(referenceId);
  
              if (pid == null) {
                  UnresolvedReference ref = new UnresolvedReference(referencePid, attrDef, id, context.getConfigElement().getConfigID());
                  context.addUnresolvedReference(ref);
              }
  
              context.getEvaluationResult().addReference(referenceId);
  
              return pid;
          } else if (attrDef.getService() != null) {
              List<RegistryEntry> exposers = metatypeRegistry.getEntriesExposingService(attrDef.getService());
              List<String> matchedPids = new ArrayList<String>();
              if (exposers != null) {
                  if (attrDef.getServiceFilter() == null) {
                      for (RegistryEntry entry : exposers) {
                          ConfigID referenceId = new ConfigID(entry.getPid(), id);
                          context.getEvaluationResult().addReference(referenceId);//what?
                          String pid = lookupPid(referenceId);
                          if (pid != null)
                              matchedPids.add(pid);
                      }
                  } else {
                      String idClause = FilterUtils.createPropertyFilter("id", id);
                      for (RegistryEntry entry : exposers) {
                          String pidClause = FilterUtils.createPropertyFilter(ConfigurationAdmin.SERVICE_FACTORYPID, entry.getPid());
                          String filter = "(&" + pidClause + idClause + attrDef.getServiceFilter() + ")";
                          try {
                              Configuration[] configs = configRetriever.listConfigurations(filter);
                              if (configs != null)
                                  for (Configuration config : configs) {
                                      matchedPids.add(config.getPid());
                                  }
                          } catch (ConfigRetrieverException e) {
                              throw new ConfigEvaluatorException("Failed retrieving configuration for " + attrDef, e);
                          }
                      }
                  }
              }
              if (matchedPids.size() == 1) {
                  return matchedPids.get(0);
              } else {
                  // If matchedPids > 1, there is more than one possible reference.
                  // If matchedPids == 0, there are no resolved instances yet.
                  // In either case, add it to the unresolved list to check later
                  UnresolvedPidType ref = new UnresolvedService(attrDef.getService(), attrDef, id, context.getConfigElement().getConfigID(), matchedPids.size());
                  context.addUnresolvedReference(ref);
                  return null;
              }
          }
  
          throw new ConfigEvaluatorException("Reference pid is not defined for " + attrDef);
      }