Exemple #1
0
  /**
   * This static method will be used to build the Target from the specified element
   *
   * @param elem - OMElement describing the xml configuration of the target
   * @return Target built by parsing the given element
   */
  public static Target createTarget(OMElement elem) {

    if (!TARGET_Q.equals(elem.getQName())) {
      handleException("Element does not match with the target QName");
    }

    Target target = new Target();
    OMAttribute toAttr = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "to"));
    if (toAttr != null && toAttr.getAttributeValue() != null) {
      target.setToAddress(toAttr.getAttributeValue());
    }

    OMAttribute soapAction =
        elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "soapAction"));
    if (soapAction != null && soapAction.getAttributeValue() != null) {
      target.setSoapAction(soapAction.getAttributeValue());
    }

    OMAttribute sequenceAttr =
        elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "sequence"));
    if (sequenceAttr != null && sequenceAttr.getAttributeValue() != null) {
      target.setSequenceRef(sequenceAttr.getAttributeValue());
    }

    OMAttribute endpointAttr =
        elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "endpoint"));
    if (endpointAttr != null && endpointAttr.getAttributeValue() != null) {
      target.setEndpointRef(endpointAttr.getAttributeValue());
    }

    OMElement sequence =
        elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "sequence"));
    if (sequence != null) {
      SequenceMediatorFactory fac = new SequenceMediatorFactory();
      target.setSequence(fac.createAnonymousSequence(sequence));
    }

    OMElement endpoint =
        elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "endpoint"));
    if (endpoint != null) {
      target.setEndpoint(EndpointFactory.getEndpointFromElement(endpoint, true));
    }

    return target;
  }