コード例 #1
0
  /**
   * Returns the EndpointFactory implementation for given endpoint configuration. Throws a
   * SynapseException, if there is no EndpointFactory for given configuration.
   *
   * @param configElement Endpoint configuration.
   * @return EndpointFactory implementation.
   */
  private static EndpointFactory getEndpointFactory(OMElement configElement) {

    if (configElement.getAttribute(new QName("key")) != null) {
      return IndirectEndpointFactory.getInstance();
    }

    if (configElement.getAttribute(new QName("key-expression")) != null) {
      return ResolvingEndpointFactory.getInstance();
    }

    if (configElement.getAttribute(new QName("template")) != null) {
      return new TemplateEndpointFactory();
    }

    OMElement addressElement =
        configElement.getFirstChildWithName(
            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "address"));
    if (addressElement != null) {
      return AddressEndpointFactory.getInstance();
    }

    OMElement wsdlElement =
        configElement.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "wsdl"));
    if (wsdlElement != null) {
      return WSDLEndpointFactory.getInstance();
    }

    OMElement defaultElement =
        configElement.getFirstChildWithName(
            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "default"));
    if (defaultElement != null) {
      return DefaultEndpointFactory.getInstance();
    }

    OMElement lbElement =
        configElement.getFirstChildWithName(
            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "loadbalance"));
    if (lbElement != null) {
      OMElement sessionElement =
          configElement.getFirstChildWithName(
              new QName(SynapseConstants.SYNAPSE_NAMESPACE, "session"));
      if (sessionElement != null) {
        return SALoadbalanceEndpointFactory.getInstance();
      } else {
        return LoadbalanceEndpointFactory.getInstance();
      }
    }

    OMElement dlbElement =
        configElement.getFirstChildWithName(
            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "dynamicLoadbalance"));
    if (dlbElement != null) {
      return DynamicLoadbalanceEndpointFactory.getInstance();
    }

    OMElement sdlbElement =
        configElement.getFirstChildWithName(
            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "serviceDynamicLoadbalance"));
    if (sdlbElement != null) {
      return ServiceDynamicLoadbalanceEndpointFactory.getInstance();
    }

    OMElement foElement =
        configElement.getFirstChildWithName(
            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "failover"));
    if (foElement != null) {
      return FailoverEndpointFactory.getInstance();
    }

    OMElement rcplElement =
        configElement.getFirstChildWithName(
            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "recipientlist"));
    if (rcplElement != null) {
      return RecipientListEndpointFactory.getInstance();
    }

    OMElement httpElement =
        configElement.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "http"));
    if (httpElement != null) {
      return HTTPEndpointFactory.getInstance();
    }

    OMElement classElement =
        configElement.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "class"));
    if (classElement != null) {
      return ClassEndpointFactory.getInstance();
    }

    handleException("Invalid endpoint configuration.");
    // just to make the compiler happy : never executes
    return null;
  }