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);
}
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;
}
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;
}
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);
}
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;
}
Aggregations