Search in sources :

Example 1 with DropMediator

use of org.apache.synapse.mediators.builtin.DropMediator in project wso2-synapse by wso2.

the class SynapseConfigUtils method setDefaultFaultSequence.

/**
 * Return the fault sequence if one is not defined. This implementation defaults to
 * a simple sequence :
 * <log level="full">
 *   <property name="MESSAGE" value="Executing default "fault" sequence"/>
 *   <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
 *   <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
 * </log>
 * <drop/>
 *
 * @param config the configuration to be updated
 */
public static void setDefaultFaultSequence(SynapseConfiguration config) {
    SequenceMediator fault = new SequenceMediator();
    fault.setName(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY);
    LogMediator log = new LogMediator();
    log.setLogLevel(LogMediator.FULL);
    MediatorProperty mp = new MediatorProperty();
    mp.setName("MESSAGE");
    mp.setValue("Executing default \"fault\" sequence");
    log.addProperty(mp);
    mp = new MediatorProperty();
    mp.setName("ERROR_CODE");
    try {
        mp.setExpression(new SynapseXPath("get-property('ERROR_CODE')"));
    } catch (JaxenException ignore) {
    }
    log.addProperty(mp);
    mp = new MediatorProperty();
    mp.setName("ERROR_MESSAGE");
    try {
        mp.setExpression(new SynapseXPath("get-property('ERROR_MESSAGE')"));
    } catch (JaxenException ignore) {
    }
    log.addProperty(mp);
    fault.addChild(log);
    fault.addChild(new DropMediator());
    // set aspect configuration
    AspectConfiguration configuration = new AspectConfiguration(fault.getName());
    fault.configure(configuration);
    config.addSequence(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY, fault);
}
Also used : SynapseXPath(org.apache.synapse.util.xpath.SynapseXPath) MediatorProperty(org.apache.synapse.mediators.MediatorProperty) JaxenException(org.jaxen.JaxenException) LogMediator(org.apache.synapse.mediators.builtin.LogMediator) DropMediator(org.apache.synapse.mediators.builtin.DropMediator) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration)

Example 2 with DropMediator

use of org.apache.synapse.mediators.builtin.DropMediator in project wso2-synapse by wso2.

the class DropMediatorFactory method createSpecificMediator.

public Mediator createSpecificMediator(OMElement el, Properties properties) {
    Mediator dropMediator = new DropMediator();
    // after successfully creating the mediator
    // set its common attributes such as tracing etc
    processAuditStatus(dropMediator, el);
    return dropMediator;
}
Also used : DropMediator(org.apache.synapse.mediators.builtin.DropMediator) Mediator(org.apache.synapse.Mediator) DropMediator(org.apache.synapse.mediators.builtin.DropMediator)

Example 3 with DropMediator

use of org.apache.synapse.mediators.builtin.DropMediator in project wso2-synapse by wso2.

the class DropMediatorSerializer method serializeSpecificMediator.

public OMElement serializeSpecificMediator(Mediator m) {
    if (!(m instanceof DropMediator)) {
        handleException("Unsupported mediator passed in for serialization : " + m.getType());
    }
    DropMediator mediator = (DropMediator) m;
    OMElement drop = fac.createOMElement("drop", synNS);
    saveTracingState(drop, mediator);
    return drop;
}
Also used : DropMediator(org.apache.synapse.mediators.builtin.DropMediator) OMElement(org.apache.axiom.om.OMElement)

Example 4 with DropMediator

use of org.apache.synapse.mediators.builtin.DropMediator in project wso2-synapse by wso2.

the class SynapseConfigUtils method setDefaultMainSequence.

/**
 * Return the main sequence if one is not defined. This implementation defaults to
 * a simple sequence with a <send/>
 *
 * @param config the configuration to be updated
 */
public static void setDefaultMainSequence(SynapseConfiguration config) {
    SequenceMediator main = new SequenceMediator();
    main.setName(SynapseConstants.MAIN_SEQUENCE_KEY);
    main.addChild(new LogMediator());
    main.addChild(new DropMediator());
    config.addSequence(SynapseConstants.MAIN_SEQUENCE_KEY, main);
    // set the aspect configuration
    AspectConfiguration configuration = new AspectConfiguration(main.getName());
    main.configure(configuration);
}
Also used : LogMediator(org.apache.synapse.mediators.builtin.LogMediator) DropMediator(org.apache.synapse.mediators.builtin.DropMediator) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration)

Example 5 with DropMediator

use of org.apache.synapse.mediators.builtin.DropMediator in project wso2-synapse by wso2.

the class AggregateMediatorFactory method createSpecificMediator.

public Mediator createSpecificMediator(OMElement elem, Properties properties) {
    AggregateMediator mediator = new AggregateMediator();
    processAuditStatus(mediator, elem);
    OMAttribute id = elem.getAttribute(ID_Q);
    if (id != null) {
        mediator.setId(id.getAttributeValue());
    }
    OMElement corelateOn = elem.getFirstChildWithName(CORELATE_ON_Q);
    if (corelateOn != null) {
        OMAttribute corelateExpr = corelateOn.getAttribute(EXPRESSION_Q);
        if (corelateExpr != null) {
            try {
                mediator.setCorrelateExpression(SynapseXPathFactory.getSynapseXPath(corelateOn, EXPRESSION_Q));
            } catch (JaxenException e) {
                handleException("Unable to load the corelate XPATH expression", e);
            }
        }
    }
    OMElement completeCond = elem.getFirstChildWithName(COMPLETE_CONDITION_Q);
    if (completeCond != null) {
        OMAttribute completeTimeout = completeCond.getAttribute(TIMEOUT_Q);
        if (completeTimeout != null) {
            mediator.setCompletionTimeoutMillis(Long.parseLong(completeTimeout.getAttributeValue()) * 1000);
        }
        OMElement messageCount = completeCond.getFirstChildWithName(MESSAGE_COUNT_Q);
        if (messageCount != null) {
            OMAttribute min = messageCount.getAttribute(MIN_Q);
            if (min != null) {
                mediator.setMinMessagesToComplete(new ValueFactory().createValue("min", messageCount));
            }
            OMAttribute max = messageCount.getAttribute(MAX_Q);
            if (max != null) {
                mediator.setMaxMessagesToComplete(new ValueFactory().createValue("max", messageCount));
            }
        }
    }
    OMElement onComplete = elem.getFirstChildWithName(ON_COMPLETE_Q);
    if (onComplete != null) {
        OMAttribute aggregateExpr = onComplete.getAttribute(EXPRESSION_Q);
        if (aggregateExpr != null) {
            try {
                mediator.setAggregationExpression(SynapseXPathFactory.getSynapseXPath(onComplete, EXPRESSION_Q));
            } catch (JaxenException e) {
                handleException("Unable to load the aggregating XPATH", e);
            }
        }
        OMAttribute enclosingElementPropertyName = onComplete.getAttribute(ENCLOSING_ELEMENT_PROPERTY);
        if (enclosingElementPropertyName != null) {
            mediator.setEnclosingElementPropertyName(enclosingElementPropertyName.getAttributeValue());
        }
        OMAttribute onCompleteSequence = onComplete.getAttribute(SEQUENCE_Q);
        if (onCompleteSequence != null) {
            mediator.setOnCompleteSequenceRef(onCompleteSequence.getAttributeValue());
        } else if (onComplete.getFirstElement() != null) {
            mediator.setOnCompleteSequence((new SequenceMediatorFactory()).createAnonymousSequence(onComplete, properties));
        } else {
            SequenceMediator sequence = new SequenceMediator();
            sequence.addChild(new DropMediator());
            mediator.setOnCompleteSequence(sequence);
        }
    }
    addAllCommentChildrenToList(elem, mediator.getCommentsList());
    return mediator;
}
Also used : AggregateMediator(org.apache.synapse.mediators.eip.aggregator.AggregateMediator) JaxenException(org.jaxen.JaxenException) DropMediator(org.apache.synapse.mediators.builtin.DropMediator) OMElement(org.apache.axiom.om.OMElement) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) OMAttribute(org.apache.axiom.om.OMAttribute)

Aggregations

DropMediator (org.apache.synapse.mediators.builtin.DropMediator)5 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)3 OMElement (org.apache.axiom.om.OMElement)2 AspectConfiguration (org.apache.synapse.aspects.AspectConfiguration)2 LogMediator (org.apache.synapse.mediators.builtin.LogMediator)2 JaxenException (org.jaxen.JaxenException)2 OMAttribute (org.apache.axiom.om.OMAttribute)1 Mediator (org.apache.synapse.Mediator)1 MediatorProperty (org.apache.synapse.mediators.MediatorProperty)1 AggregateMediator (org.apache.synapse.mediators.eip.aggregator.AggregateMediator)1 SynapseXPath (org.apache.synapse.util.xpath.SynapseXPath)1