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

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

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

import org.apache.axiom.om.OMElement;
import org.wso2.carbon.cep.core.Input;
import org.wso2.carbon.cep.core.exception.CEPConfigurationException;
import org.wso2.carbon.cep.core.internal.util.CEPConstants;

import javax.xml.namespace.QName;

/**
* This class helps to build an Input Object from a given OMElement
*/
public class InputHelper {
    public static Input fromOM(OMElement inputElement)
            throws CEPConfigurationException {

        Input input = new Input();
        String topic = inputElement.getAttributeValue(new QName(CEPConstants.CEP_CONF_ELE_TOPIC));
        input.setTopic(topic);

        String brokerProxy =
                inputElement.getAttributeValue(new QName(CEPConstants.CEP_CONF_ELE_BROKER_NAME));
        input.setBrokerName(brokerProxy);

        OMElement mappingElement =
                inputElement.getFirstChildWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
                        CEPConstants.CEP_CONF_ELE_MAPPING));

        if (mappingElement == null) {
            throw new CEPConfigurationException("no mapping element for topic " + topic);
        }

        input.setMapping(
                MappingHelper.fromOM(mappingElement));

        return input;
    }
}
TOP

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

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.