Package org.apache.synapse.endpoints

Examples of org.apache.synapse.endpoints.TemplateEndpoint


        nullNS = fac.createOMNamespace(XMLConfigConstants.NULL_NAMESPACE, "");

    }

    public OMElement serializeEndpoint(Endpoint epr) {
        TemplateEndpoint endpoints = (TemplateEndpoint) epr;

        OMElement endpointElement = fac.createOMElement(
                new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "endpoint"));

        if (endpoints.getName() != null) {
            endpointElement.addAttribute(
                    fac.createOMAttribute("name", nullNS, endpoints.getName()));
        }

        endpointElement.addAttribute(fac.createOMAttribute("template", nullNS, endpoints.getTemplate()));

        Map<String, String> parameters = endpoints.getParameters();
        for (Map.Entry<String, String> entry : parameters.entrySet()) {
            if (entry.getKey().equals("name")) {
                endpointElement.addAttribute(fac.createOMAttribute("name", nullNS, entry.getValue()));
            } else if (entry.getKey().equals("uri")) {
                endpointElement.addAttribute(fac.createOMAttribute("uri", nullNS, entry.getValue()));
View Full Code Here


        nullNS = fac.createOMNamespace(XMLConfigConstants.NULL_NAMESPACE, "");

    }

    public OMElement serializeEndpoint(Endpoint epr) {
        TemplateEndpoint endpoints = (TemplateEndpoint) epr;

        OMElement endpointElement = fac.createOMElement("endpoint",
                SynapseConstants.SYNAPSE_OMNAMESPACE);

        if (endpoints.getName() != null) {
            endpointElement.addAttribute(
                    fac.createOMAttribute("name", nullNS, endpoints.getName()));
        }

        endpointElement.addAttribute(fac.createOMAttribute("template", nullNS, endpoints.getTemplate()));

        Map<String, String> parameters = endpoints.getParameters();
        for (Map.Entry<String, String> entry : parameters.entrySet()) {
            if (entry.getKey().equals("name")) {
                endpointElement.addAttribute(fac.createOMAttribute("name", nullNS, entry.getValue()));
            } else if (entry.getKey().equals("uri")) {
                endpointElement.addAttribute(fac.createOMAttribute("uri", nullNS, entry.getValue()));
View Full Code Here

import java.util.Iterator;
import java.util.Properties;

public class TemplateEndpointFactory extends EndpointFactory {
    public Endpoint createEndpoint(OMElement endpointElement, boolean a, Properties properties) {
        TemplateEndpoint templateEndpoint = new TemplateEndpoint();

        OMAttribute endpointNameAttribute = endpointElement.getAttribute(
                new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
        if (endpointNameAttribute != null) {
            templateEndpoint.addParameter("name", endpointNameAttribute.getAttributeValue());
            templateEndpoint.setName(endpointNameAttribute.getAttributeValue());
        } else {
            handleException("Error loading the configuration from Template " +
                    "Endpoint, name attribute is missing");
        }

        OMAttribute endpointURIAttribute = endpointElement.getAttribute(
                new QName(XMLConfigConstants.NULL_NAMESPACE, "uri"));
        if (endpointURIAttribute != null) {
            templateEndpoint.addParameter("uri", endpointURIAttribute.getAttributeValue());
        } else {
            handleException("Error loading the configuration from Template Endpoint, " +
                    templateEndpoint.getName() + " uri attribute is missing");
        }

        OMAttribute endpointTemplateAttribute = endpointElement.getAttribute(
                new QName(XMLConfigConstants.NULL_NAMESPACE, "template"));
        if (endpointTemplateAttribute != null) {
            templateEndpoint.setTemplate(endpointTemplateAttribute.getAttributeValue());
        } else {
            handleException("Error loading the configuration from endpoint group, " +
                    templateEndpoint.getName() +
                    " template attribute is missing");
        }

        Iterator paramItr = endpointElement.getChildrenWithName(
                new QName(SynapseConstants.SYNAPSE_NAMESPACE, "parameter"));
        while (paramItr.hasNext()) {
            OMElement paramElement = (OMElement) paramItr.next();

            OMAttribute paramName = paramElement.getAttribute(new QName("name"));
            OMAttribute paramValue = paramElement.getAttribute(new QName("value"));

            if (paramName == null) {
                handleException("parameter name should be present");
            }

            if (paramValue == null) {
                handleException("parameter value should be present");
            }


            assert paramName != null;
            assert paramValue != null;

            templateEndpoint.addParameter(paramName.getAttributeValue(),
                    paramValue.getAttributeValue());
        }

        return templateEndpoint;
    }
View Full Code Here

TOP

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

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.