예제 #1
0
  /*
   * Work down the children tree
   * @param parent
   * @param el
   */
  private void processChildren(ESBNodeWithChildren parent, Element el) {
    el.normalize();
    parent.setData(el);

    if (parent.getEsbObjectType() == null) {
      String tag = el.getTagName();
      if (tag.endsWith("-bus") && el.getAttribute("busid") != null) { // $NON-NLS-1$ //$NON-NLS-2$
        parent.setEsbObjectType(ESBType.BUS);
      } else if (tag.endsWith("-listener")
          && el.getAttribute("busidref") != null) { // $NON-NLS-1$ //$NON-NLS-2$
        parent.setEsbObjectType(ESBType.LISTENER);
      } else if (tag.endsWith("-provider")) { // $NON-NLS-1$
        parent.setEsbObjectType(ESBType.PROVIDER);
      } else if (tag.equalsIgnoreCase("service")) { // $NON-NLS-1$
        parent.setEsbObjectType(ESBType.SERVICE);
      } else if (tag.equalsIgnoreCase("listeners")) { // $NON-NLS-1$
        parent.setEsbObjectType(ESBType.LISTENER);
      } else if (tag.equalsIgnoreCase("Actions")) { // $NON-NLS-1$
        parent.setEsbObjectType(ESBType.ACTION);
      } else if (tag.equalsIgnoreCase("action")) { // $NON-NLS-1$
        parent.setEsbObjectType(ESBType.ACTION);
      } else if (tag.equalsIgnoreCase("property")) { // $NON-NLS-1$
        parent.setEsbObjectType(ESBType.PROPERTY);
        return;
      }
    }
    NodeList children = el.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      if (children.item(i) instanceof Element) {
        Element child = (Element) children.item(i);
        String name = child.getAttribute("name"); // $NON-NLS-1$
        if (name == null || name.trim().length() == 0) {
          name = child.getAttribute("busid"); // $NON-NLS-1$
        }
        if (name == null || name.trim().length() == 0) {
          name = child.getAttribute("dest-name"); // $NON-NLS-1$
        }
        if (name == null || name.trim().length() == 0) {
          name = child.getTagName();
        }
        if (name.equalsIgnoreCase("actions")) { // $NON-NLS-1$
          name = JBossESBUIMessages.ESBDomParser_Actions_Node_Label;
        } else if (name.equalsIgnoreCase("listeners")) { // $NON-NLS-1$
          name = JBossESBUIMessages.ESBDomParser_Listeners_Node_Label;
        }

        ESBNodeWithChildren childNode = new ESBNodeWithChildren(name);
        String ref = child.getAttribute("busidref"); // $NON-NLS-1$
        if (ref != null && ref.trim().length() > 0) {
          childNode.setRef(ref);
        }
        processChildren(childNode, child);
        if (childNode.getEsbObjectType() != null
            && !childNode.getEsbObjectType().equals(ESBType.PROPERTY)) {
          parent.addChild(childNode);
          childNode.setEsbObjectType(parent.getEsbObjectType());
        }
      }
    }
  }
예제 #2
0
  /*
   * Work through the configuration
   */
  private void parseDocument() {
    // get the root elememt
    Element docEle = dom.getDocumentElement();

    // get a nodelist of <providers> elements
    NodeList nl = docEle.getElementsByTagName("providers"); // $NON-NLS-1$
    if (nl != null && nl.getLength() > 0) {
      Element providersElement = null;
      for (int j = 0; j < nl.getLength(); j++) {
        if (nl.item(j) instanceof Element) {
          providersElement = (Element) nl.item(j);
          break;
        }
      }
      if (providersElement != null) {
        ESBNodeWithChildren providersRoot =
            new ESBNodeWithChildren(JBossESBUIMessages.ESBDomParser_Providers_Label);
        providersRoot.setEsbObjectType(ESBNode.ESBType.PROVIDER);
        processChildren(providersRoot, providersElement);
        root.addChild(providersRoot);
      }
    }

    // get a nodelist of <services> elements
    NodeList nl2 = docEle.getElementsByTagName("services"); // $NON-NLS-1$
    if (nl2 != null && nl2.getLength() > 0) {
      Element servicesElement = null;
      for (int j = 0; j < nl2.getLength(); j++) {
        if (nl2.item(j) instanceof Element) {
          servicesElement = (Element) nl2.item(j);
          break;
        }
      }
      if (servicesElement != null) {
        ESBNodeWithChildren servicesRoot =
            new ESBNodeWithChildren(JBossESBUIMessages.ESBDomParser_Services_Label);
        servicesRoot.setEsbObjectType(ESBNode.ESBType.SERVICE);
        processChildren(servicesRoot, servicesElement);
        root.addChild(servicesRoot);
      }
    }
  }