Package org.apache.synapse.endpoints

Examples of org.apache.synapse.endpoints.RecipientListEndpoint


        fac = OMAbstractFactory.getOMFactory();
        OMElement endpointElement
                = fac.createOMElement("endpoint", SynapseConstants.SYNAPSE_OMNAMESPACE);
       
        RecipientListEndpoint recipientListEndpoint = (RecipientListEndpoint) endpoint;

        // serialize the parameters
        serializeProperties(recipientListEndpoint, endpointElement);

        serializeCommonAttributes(endpoint,endpointElement);

        OMElement recipientListElement
                = fac.createOMElement("recipientlist", SynapseConstants.SYNAPSE_OMNAMESPACE);
        endpointElement.addChild(recipientListElement);
       
    // Serialize endpoint elements which are children of the recipientlist
    // element
    if (recipientListEndpoint.getChildren() != null) {
      for (Endpoint childEndpoint : recipientListEndpoint.getChildren()) {
        recipientListElement.addChild(EndpointSerializer
            .getElementFromEndpoint(childEndpoint));
      }
    } else if (recipientListEndpoint.getMembers() != null) {
            for (Member member : recipientListEndpoint.getMembers()) {
                OMElement memberEle = fac.createOMElement(
                        "member", SynapseConstants.SYNAPSE_OMNAMESPACE, recipientListElement);
                memberEle.addAttribute(fac.createOMAttribute(
                        "hostName", null, member.getHostName()));
                memberEle.addAttribute(fac.createOMAttribute(
                        "httpPort", null, String.valueOf(member.getHttpPort())));
                memberEle.addAttribute(fac.createOMAttribute(
                        "httpsPort", null, String.valueOf(member.getHttpsPort())));
                recipientListElement.addChild(memberEle);
            }
        } else {
            OMElement dynamicEpEle = fac.createOMElement(
                    "endpoints", SynapseConstants.SYNAPSE_OMNAMESPACE, recipientListElement);
            new ValueSerializer().serializeValue(recipientListEndpoint.getDynamicEndpointSet(),
                    "value", dynamicEpEle);
            dynamicEpEle.addAttribute(fac.createOMAttribute("max-cache", null,
                    String.valueOf(recipientListEndpoint.getCurrentPoolSize())));
            recipientListElement.addChild(dynamicEpEle);
        }

        return endpointElement;
    }
View Full Code Here


                new QName(SynapseConstants.SYNAPSE_NAMESPACE, "recipientlist"));
   
    if(recipientListElement != null){
     
      //create endpoint
      RecipientListEndpoint recipientListEndpoint = new RecipientListEndpoint();
     
      // set endpoint name
            OMAttribute name = epConfig.getAttribute(new QName(
                    org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "name"));

            if (name != null) {
              recipientListEndpoint.setName(name.getAttributeValue());
            }
           
      // set endpoints or members
      if (recipientListElement.
                    getFirstChildWithName(XMLConfigConstants.ENDPOINT_ELT) != null) {
        if (recipientListElement.getChildrenWithName((MEMBER)).hasNext()) {
          String msg = "Invalid Synapse configuration. child elements";
          log.error(msg);
          throw new SynapseException(msg);
        }
        List<Endpoint> endpoints = getEndpoints(recipientListElement,
            recipientListEndpoint, properties);
        recipientListEndpoint.setChildren(endpoints);

      } else if (recipientListElement.getFirstChildWithName(MEMBER) != null) {
        if(recipientListElement.
                        getChildrenWithName((XMLConfigConstants.ENDPOINT_ELT)).hasNext()){
                    String msg =
                            "Invalid Synapse configuration. " +
                            "recipientListElement element cannot have both member & endpoint " +
                            "child elements";
                    log.error(msg);
                    throw new SynapseException(msg);
                }
       
              List<Member> members = getMembers(recipientListElement);
              recipientListEndpoint.setMembers(members);

            } else if (recipientListElement.getFirstChildWithName(DYNAMIC_SET) != null) {
                OMElement dynamicSetElement = recipientListElement.getFirstChildWithName(DYNAMIC_SET);
                Value dynamicEndpointSet = new ValueFactory().createValue("value", dynamicSetElement);
                String maxCacheStr = dynamicSetElement.getAttributeValue(new QName("max-cache"));
                int maxCache = RecipientListEndpoint.DEFAULT_MAX_POOL ;
                if (maxCacheStr != null) {
                    maxCache = Integer.parseInt(maxCacheStr);
                }
                recipientListEndpoint = new RecipientListEndpoint(maxCache);
                if (name != null) {
                    recipientListEndpoint.setName(name.getAttributeValue());
                }
                recipientListEndpoint.setDynamicEndpointSet(dynamicEndpointSet);
            }

            if (recipientListEndpoint.getChildren() == null &&
                recipientListEndpoint.getMembers() == null &&
                    recipientListEndpoint.getDynamicEndpointSet() == null) {
                String msg = "A RecipientListEndpoint must have child/member elements, but the " +
                        "RecipientListEndpoint " + "'" + recipientListEndpoint.getName() + "' " +
                        "does not have any child/member/dynamic endpoint elements.";
                log.error(msg);
                throw new SynapseException(msg);
            }
View Full Code Here

TOP

Related Classes of org.apache.synapse.endpoints.RecipientListEndpoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.