Example #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;
  }
Example #2
0
  public void destroy() {

    for (Target target : targets) {
      ManagedLifecycle seq = target.getSequence();
      if (seq != null) {
        seq.destroy();
      } else if (target.getSequenceRef() != null) {
        SequenceMediator targetSequence =
            (SequenceMediator)
                synapseEnv.getSynapseConfiguration().getSequence(target.getSequenceRef());

        if (targetSequence == null || targetSequence.isDynamic()) {
          synapseEnv.removeUnavailableArtifactRef(target.getSequenceRef());
        }
      }
      Endpoint endpoint = target.getEndpoint();
      if (endpoint != null) {
        endpoint.destroy();
      }
    }
  }
Example #3
0
  public void init(SynapseEnvironment se) {

    synapseEnv = se;
    for (Target target : targets) {
      ManagedLifecycle seq = target.getSequence();
      if (seq != null) {
        seq.init(se);
      } else if (target.getSequenceRef() != null) {
        SequenceMediator targetSequence =
            (SequenceMediator) se.getSynapseConfiguration().getSequence(target.getSequenceRef());

        if (targetSequence == null || targetSequence.isDynamic()) {
          se.addUnavailableArtifactRef(target.getSequenceRef());
        }
      }
      Endpoint endpoint = target.getEndpoint();
      if (endpoint != null) {
        endpoint.init(se);
      }
    }
  }