public void buildFromXMLElement()

in uimaj-ep-runtime-deployeditor/src/main/java/org/apache/uima/aae/deployment/impl/AEService_Impl.java [123:233]


  public void buildFromXMLElement(Element aElement, XMLParser aParser,
          XMLParser.ParsingOptions aOptions) throws InvalidXMLException {
    // Trace.trace();
    NodeList childNodes = aElement.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
      Node curNode = childNodes.item(i);
      if (curNode instanceof Element) {
        Element elem = (Element) curNode;

        if (TAG_INPUT_QUEUE.equalsIgnoreCase(elem.getTagName())) {
          checkAndSetInputQueueAttributes(elem);

        } else if (TAG_TOP_DESCRIPTOR.equalsIgnoreCase(elem.getTagName())) {
          // setTopDescriptor(XMLUtils.getText(elem));
          // setImportByLocation("");
          NodeList nodes = elem.getChildNodes();
          if (nodes.getLength() > 0) {
            // Should be an "import"
            for (int k = 0; k < nodes.getLength(); ++k) {
              Node n = nodes.item(k);
              if (!(n instanceof Element)) {
                // Trace.err("NOT an import");
                // setImportByLocation("");
                continue;
              } else if (!((Element) n).getTagName().equalsIgnoreCase(TAG_IMPORT)) {
                throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT,
                        new Object[]{((Element) n).getTagName()});
              } else {
                importDescriptor = (Import) aParser.buildObject((Element) n, aOptions);
              }
            }
          }
        } else if (TAG_ANALYSIS_ENGINE.equalsIgnoreCase(elem.getTagName())) {
          analysisEngineDeploymentMetaData = (AEDeploymentMetaData) aParser.buildObject(elem,
                  aOptions);
          analysisEngineDeploymentMetaData.setTopAnalysisEngine(true);
          
        } else if (TAG_CUSTOM.equalsIgnoreCase(elem.getTagName())) {
          // Check for "name"
          NamedNodeMap map = elem.getAttributes();
          if (map != null) {
            for (int k=0; k<map.getLength(); ++k) {
              Node item = map.item(k);
              String name = item.getNodeName();
              String val = item.getNodeValue();
              if (val == null) {
                val = "";
              } else {
                val = val.trim();
              }
              if (TAG_ATTR_NAME.equalsIgnoreCase(name)) {
                // set "name = ..." attribute
                customValue = val;
              } else {
                throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT,
                        new Object[]{name});
              }
            }
          }
          
        } else if (TAG_ENV_VARS.equalsIgnoreCase(elem.getTagName())) {
          // delegates = new AEDelegates_Impl(this);
          NodeList nodes = elem.getChildNodes();
          if (nodes.getLength() > 0) {
            // Look for "environmentVariable"
            for (int k = 0; k < nodes.getLength(); ++k) {
              Node n = nodes.item(k);
              if (!(n instanceof Element)) {
                continue;
              }

              Element e = (Element) n;
              if (TAG_ENV_VAR.equalsIgnoreCase(e.getTagName())) {
                String envName = getValueOfNameAttribute(e);
                if (envName == null) {
                  throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT,
                          new Object[]{e.getTagName()});
                }
                if (environmentVariables == null) {
                  environmentVariables = new ArrayList<NameValue>();
                }
                environmentVariables.add(new NameValue(envName, e.getTextContent()));
              } else {     
                throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT,
                        new Object[]{e.getTagName()});
              }
            }
          }
          
        } else {
            throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT,
                    new Object[]{elem.getTagName()});
        }
      }
    }

    // Create DEFAULT AEDeploymentMetaData for TOP AE
    if (analysisEngineDeploymentMetaData == null) {
      analysisEngineDeploymentMetaData = new AEDeploymentMetaData_Impl();
      analysisEngineDeploymentMetaData.setTopAnalysisEngine(true);
    }
    if (analysisEngineDeploymentMetaData.getAsyncAEErrorConfiguration() == null) {
      // Create a new Error Config
      Object obj = UIMAFramework.getResourceSpecifierFactory().createObject(
              AsyncPrimitiveErrorConfiguration.class);
      if (obj == null) {
        Trace.err("Cannot create AsyncPrimitiveErrorConfiguration for TOP");
      }
      analysisEngineDeploymentMetaData.setAsyncAEErrorConfiguration((AsyncPrimitiveErrorConfiguration) obj);
    }
  }