use of org.apache.synapse.mediators.store.MessageStoreMediator in project wso2-synapse by wso2.
the class MessageStoreMediatorSerializer method serializeSpecificMediator.
@Override
protected OMElement serializeSpecificMediator(Mediator m) {
if (!(m instanceof MessageStoreMediator)) {
handleException("Unsupported mediator passed in for serialization : " + m.getType());
}
MessageStoreMediator messageStoreMediator = (MessageStoreMediator) m;
SynapsePath messageStoreExp = messageStoreMediator.getMessageStoreExp();
String messageStoreName = messageStoreMediator.getMessageStoreName();
OMElement storeElem = fac.createOMElement("store", synNS);
String name = messageStoreMediator.getName();
if (name != null) {
OMAttribute nameAtt = fac.createOMAttribute("name", nullNS, name);
storeElem.addAttribute(nameAtt);
}
// But we do a null check here since in run time there can be manual modifications
if (messageStoreExp != null) {
SynapsePathSerializer.serializePathWithBraces(messageStoreExp, storeElem, "messageStore");
} else if (messageStoreName != null) {
OMAttribute msName = fac.createOMAttribute(ATT_MESSAGE_STORE, nullNS, messageStoreName);
storeElem.addAttribute(msName);
} else {
handleException("Can't serialize MessageStore Mediator message store is null ");
}
String sequence = messageStoreMediator.getOnStoreSequence();
// sequence is an optional parameter
if (sequence != null) {
OMAttribute sequenceAtt = fac.createOMAttribute(ATT_SEQUENCE, nullNS, sequence);
storeElem.addAttribute(sequenceAtt);
}
return storeElem;
}
use of org.apache.synapse.mediators.store.MessageStoreMediator in project wso2-synapse by wso2.
the class MessageStoreMediatorFactory method createSpecificMediator.
@Override
protected Mediator createSpecificMediator(OMElement elem, Properties properties) {
MessageStoreMediator messageStoreMediator = new MessageStoreMediator();
processAuditStatus(messageStoreMediator, elem);
OMAttribute nameAtt = elem.getAttribute(ATT_NAME);
if (nameAtt != null) {
messageStoreMediator.setName(nameAtt.getAttributeValue());
}
OMAttribute messageStoreNameAtt = elem.getAttribute(ATT_MESSAGE_STORE);
if (messageStoreNameAtt != null) {
if (checkForExpression(messageStoreNameAtt)) {
String path = messageStoreNameAtt.getAttributeValue().substring(1, messageStoreNameAtt.getAttributeValue().length() - 1);
try {
messageStoreMediator.setMessageStoreExp(SynapsePathFactory.getSynapsePath(elem, path));
} catch (JaxenException e) {
String msg = "Invalid XPath expression for attribute 'messageStore' : " + messageStoreNameAtt.getAttributeValue();
throw new SynapseException(msg, e);
}
} else {
messageStoreMediator.setMessageStoreName(messageStoreNameAtt.getAttributeValue());
}
} else {
throw new SynapseException("Message Store mediator must have a Message store defined");
}
OMAttribute sequenceAtt = elem.getAttribute(ATT_SEQUENCE);
if (sequenceAtt != null) {
messageStoreMediator.setOnStoreSequence(sequenceAtt.getAttributeValue());
}
return messageStoreMediator;
}
Aggregations