Search in sources :

Example 51 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project wso2-synapse by wso2.

the class TemplateMediatorFactory method createSpecificMediator.

protected Mediator createSpecificMediator(OMElement elem, Properties properties) {
    TemplateMediator templateTemplateMediator = new TemplateMediator();
    OMAttribute nameAttr = elem.getAttribute(ATT_NAME);
    if (nameAttr != null) {
        templateTemplateMediator.setName(nameAttr.getAttributeValue());
        processAuditStatus(templateTemplateMediator, elem);
        initParameters(elem, templateTemplateMediator);
        OMElement templateBodyElem = elem.getFirstChildWithName(TEMPLATE_BODY_Q);
        addChildren(templateBodyElem, templateTemplateMediator, properties);
    } else {
        String msg = "A EIP template should be a named mediator .";
        log.error(msg);
        throw new SynapseException(msg);
    }
    return templateTemplateMediator;
}
Also used : TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) SynapseException(org.apache.synapse.SynapseException) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 52 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project wso2-synapse by wso2.

the class TransactionMediatorFactory method createSpecificMediator.

/**
 * Create a Transaction mediator instance referring to the bean and configuration given
 * by the OMElement declaration
 *
 * @param elem the OMElement that specifies the Transaction mediator configuration
 * @param properties
 * @return the Transaction mediator instance created
 */
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
    TransactionMediator tm = new TransactionMediator();
    OMAttribute action = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "action"));
    if (action == null) {
        handleException("The 'action' attribute " + "is required for Transaction mediator definition");
    } else {
        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processAuditStatus(tm, elem);
        tm.setAction(action.getAttributeValue());
        return tm;
    }
    return null;
}
Also used : TransactionMediator(org.apache.synapse.mediators.transaction.TransactionMediator) QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 53 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project wso2-synapse by wso2.

the class AddressEndpointFactory method createEndpoint.

@Override
protected Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint, Properties properties) {
    AddressEndpoint addressEndpoint = new AddressEndpoint();
    OMAttribute name = epConfig.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
    if (name != null) {
        addressEndpoint.setName(name.getAttributeValue());
    }
    OMElement addressElement = epConfig.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "address"));
    if (addressElement != null) {
        EndpointDefinition definition = createEndpointDefinition(addressElement);
        addressEndpoint.setDefinition(definition);
        processAuditStatus(definition, addressEndpoint.getName(), addressElement);
    }
    processProperties(addressEndpoint, epConfig);
    return addressEndpoint;
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) QName(javax.xml.namespace.QName) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 54 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project wso2-synapse by wso2.

the class ClassEndpointFactory method createEndpoint.

protected Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint, Properties properties) {
    ClassEndpoint clazzEndpoint = new ClassEndpoint();
    OMAttribute endpointName = epConfig.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
    if (endpointName != null) {
        clazzEndpoint.setName(endpointName.getAttributeValue());
    }
    OMElement classElement = epConfig.getFirstChildWithName(CLASS_QNAME);
    if (classElement == null) {
        return null;
    }
    String nameAttr = classElement.getAttributeValue(NAME_QNAME);
    if (nameAttr == null) {
        return null;
    }
    Endpoint endpoint = null;
    try {
        Class clazz = Class.forName(nameAttr);
        endpoint = (Endpoint) clazz.newInstance();
        for (Iterator iter = classElement.getChildrenWithName(PARAMETER_QNAME); iter.hasNext(); ) {
            OMElement paramEle = (OMElement) iter.next();
            setParameter(endpoint, paramEle, clazzEndpoint);
        }
    } catch (Exception e) {
        handleException("Cannot create class endpoint", e);
    }
    clazzEndpoint.setClassEndpoint(endpoint);
    return clazzEndpoint;
}
Also used : Endpoint(org.apache.synapse.endpoints.Endpoint) ClassEndpoint(org.apache.synapse.endpoints.ClassEndpoint) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) OMElement(org.apache.axiom.om.OMElement) ClassEndpoint(org.apache.synapse.endpoints.ClassEndpoint) OMAttribute(org.apache.axiom.om.OMAttribute) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 55 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project wso2-synapse by wso2.

the class DefaultEndpointFactory method extractSpecificEndpointProperties.

@Override
protected void extractSpecificEndpointProperties(EndpointDefinition definition, OMElement elem) {
    OMAttribute format = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "format"));
    if (format != null) {
        String forceValue = format.getAttributeValue().trim().toLowerCase();
        if (SynapseConstants.FORMAT_POX.equals(forceValue)) {
            definition.setForcePOX(true);
            definition.setFormat(SynapseConstants.FORMAT_POX);
        } else if (SynapseConstants.FORMAT_GET.equals(forceValue)) {
            definition.setForceGET(true);
            definition.setFormat(SynapseConstants.FORMAT_GET);
        } else if (SynapseConstants.FORMAT_SOAP11.equals(forceValue)) {
            definition.setForceSOAP11(true);
            definition.setFormat(SynapseConstants.FORMAT_SOAP11);
        } else if (SynapseConstants.FORMAT_SOAP12.equals(forceValue)) {
            definition.setForceSOAP12(true);
            definition.setFormat(SynapseConstants.FORMAT_SOAP12);
        } else if (SynapseConstants.FORMAT_REST.equals(forceValue)) {
            definition.setForceREST(true);
            definition.setFormat(SynapseConstants.FORMAT_REST);
        }
    /*else if(!TemplateMappingsPopulator.populateMapping(definition, EndpointDefinition.EndpointDefKey.format, forceValue)) {
                handleException("force value -\"" + forceValue + "\" not yet implemented");
            }*/
    }
}
Also used : QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Aggregations

OMAttribute (org.apache.axiom.om.OMAttribute)187 OMElement (org.apache.axiom.om.OMElement)116 QName (javax.xml.namespace.QName)82 Iterator (java.util.Iterator)41 OMFactory (org.apache.axiom.om.OMFactory)31 OMNamespace (org.apache.axiom.om.OMNamespace)28 SynapseException (org.apache.synapse.SynapseException)28 JaxenException (org.jaxen.JaxenException)28 OMNode (org.apache.axiom.om.OMNode)13 Value (org.apache.synapse.mediators.Value)12 SynapseXPath (org.apache.synapse.util.xpath.SynapseXPath)11 ArrayList (java.util.ArrayList)8 Endpoint (org.apache.synapse.endpoints.Endpoint)7 IOException (java.io.IOException)6 List (java.util.List)6 OMText (org.apache.axiom.om.OMText)6 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)6 StringReader (java.io.StringReader)5 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)5 EndpointDefinition (org.apache.synapse.endpoints.EndpointDefinition)5