Package org.wso2.carbon.cep.core.internal.config

Source Code of org.wso2.carbon.cep.core.internal.config.OutputHelper

package org.wso2.carbon.cep.core.internal.config;

import org.apache.axiom.om.OMElement;
import org.wso2.carbon.cep.core.Output;
import org.wso2.carbon.cep.core.internal.util.CEPConstants;

import javax.xml.namespace.QName;

/**
* This class will help to build Output Object from a given OMELement
*/
public class OutputHelper {
    public static Output fromOM(OMElement outputElement) {
        Output output = new Output();

        String topic = outputElement.getAttributeValue(new QName(CEPConstants.CEP_CONF_ATTR_TOPIC));
        output.setTopic(topic);

        String brokerProxy = outputElement.getAttributeValue(new QName(CEPConstants.CEP_CONF_ELE_BROKER_NAME));
        output.setBrokerName(brokerProxy);

        OMElement elementMappingElement = outputElement.getFirstChildWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
                CEPConstants.CEP_CONF_ELE_EMAPPING));

        if (elementMappingElement != null) {
            output.setElementMapping(ElementMappingHelper.fromOM(elementMappingElement));
        }

        OMElement xmlMappingElement = outputElement.getFirstChildWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
                CEPConstants.CEP_CONF_ELE_XML_MAPPING));
        if (xmlMappingElement != null) {
            output.setXmlMapping(XMLMappingHelper.fromOM(xmlMappingElement));
        }
        return output;
    }
}
TOP

Related Classes of org.wso2.carbon.cep.core.internal.config.OutputHelper

TOP
Copyright © 2018 www.massapi.com. 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.