/**
   * Build service instantiator handler description.
   *
   * @return the handler description
   * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
   */
  public Element getHandlerInfo() {
    Element services = super.getHandlerInfo();
    for (int i = 0; i < m_imports.size(); i++) {
      ServiceImporter imp = (ServiceImporter) m_imports.get(i);
      Element impo = new Element("Requires", "");
      impo.addAttribute(new Attribute("Specification", imp.getSpecification().getName()));
      if (imp.getFilter() != null) {
        impo.addAttribute(new Attribute("Filter", imp.getFilter()));
      }
      if (imp.getState() == DependencyModel.RESOLVED) {
        impo.addAttribute(new Attribute("State", "resolved"));
        for (int j = 0; j < imp.getProviders().size(); j++) {
          Element prov = new Element("Provider", "");
          prov.addAttribute(new Attribute("name", (String) imp.getProviders().get(j)));
          impo.addElement(prov);
        }
      } else {
        impo.addAttribute(new Attribute("State", "unresolved"));
      }
      services.addElement(impo);
    }

    for (int i = 0; i < m_instances.size(); i++) {
      SvcInstance inst = (SvcInstance) m_instances.get(i);
      Element service = new Element("Service", "");
      service.addAttribute(new Attribute("Specification", inst.getServiceSpecification()));
      String state = "unresolved";
      if (inst.getState() == DependencyModel.RESOLVED) {
        state = "resolved";
      }
      service.addAttribute(new Attribute("State", state));
      Map map = inst.getMatchingFactories();
      Set keys = map.keySet();
      Iterator iterator = keys.iterator();
      while (iterator.hasNext()) {
        ServiceReference ref = (ServiceReference) iterator.next();
        Object object = map.get(ref);
        if (object != null) {
          Element fact = new Element("Factory", "");
          fact.addAttribute(
              new Attribute("Name", ((ComponentInstance) object).getFactory().getName()));
          service.addElement(fact);
        }
      }
      services.addElement(service);
    }
    return services;
  }
Пример #2
0
 /**
  * Adds the "implementation-class" attribute to the type description.
  *
  * @return the component type description.
  * @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getDescription()
  */
 public Element getDescription() {
   Element elem = super.getDescription();
   elem.addAttribute(new Attribute("Implementation-Class", m_classname));
   return elem;
 }