if (sequenceElement != null && sequenceElement.getLocalName().equals(
XMLConfigConstants.SEQUENCE_ELT.getLocalPart())) {
String sequenceName = sequenceElement.getAttributeValue(new QName("name"));
SynapseConfiguration config = getSynapseConfiguration();
log.debug("Saving sequence : " + sequenceName);
SequenceMediator preSeq = config.getDefinedSequences().get(sequenceName);
if (preSeq == null) {
handleException("Unable to save sequence " + sequenceName + ". Does not exist");
} else {
// we should first try to build the new sequence. if exception we return
Mediator mediator = MediatorFactoryFinder.getInstance().getMediator(
sequenceElement, getSynapseConfiguration().getProperties());
boolean statisticsEnable = preSeq.isStatisticsEnable();
// if everything went successfully we remove the sequence
config.removeSequence(sequenceName);
if (mediator instanceof SequenceMediator) {
if (statisticsEnable) {
((SequenceMediator) mediator).enableStatistics();
}
((SequenceMediator)mediator).setFileName(preSeq.getFileName());
}
config.addSequence(sequenceName, mediator);
log.debug("Saved sequence : " + sequenceName + " to the configuration");
SequenceMediator seq = config.getDefinedSequences().get(sequenceName);
if (seq != null) {
seq.init(getSynapseEnvironment());
persistSequence(seq);
}
}
} else {
handleException("Unable to save sequence. Invalid definition");