diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorFactory.java b/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorFactory.java index b630259471..3af458912e 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorFactory.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorFactory.java @@ -35,13 +35,11 @@ * *
  * <scatter-gather parallel-execution=(true | false)>
- *   <aggregation value-to-aggregate="expression" condition="expression" timeout="long"
+ *   <aggregation value="expression" condition="expression" timeout="long"
  *     min-messages="expression" max-messages="expression"/>
- *   <target>
- *     <sequence>
- *       (mediator)+
- *     </sequence>
- *   </target>+
+ *   <sequence>
+ *     (mediator)+
+ *   </sequence>+
  * </scatter-gather>
  * 
*/ @@ -54,14 +52,16 @@ public class ScatterGatherMediatorFactory extends AbstractMediatorFactory { = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "scatter-gather"); private static final QName ELEMENT_AGGREGATE_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "aggregation"); - private static final QName ATT_VALUE_TO_AGGREGATE = new QName("value-to-aggregate"); + private static final QName ATT_VALUE_TO_AGGREGATE = new QName("value"); private static final QName ATT_CONDITION = new QName("condition"); private static final QName ATT_TIMEOUT = new QName("timeout"); private static final QName ATT_MIN_MESSAGES = new QName("min-messages"); private static final QName ATT_MAX_MESSAGES = new QName("max-messages"); - private static final QName TARGET_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "target"); + private static final QName SEQUENCE_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "sequence"); private static final QName PARALLEL_EXEC_Q = new QName("parallel-execution"); + private static final SequenceMediatorFactory fac = new SequenceMediatorFactory(); + public Mediator createSpecificMediator(OMElement elem, Properties properties) { boolean asynchronousExe = true; @@ -76,11 +76,15 @@ public Mediator createSpecificMediator(OMElement elem, Properties properties) { mediator.setParallelExecution(asynchronousExe); - Iterator targetElements = elem.getChildrenWithName(TARGET_Q); - while (targetElements.hasNext()) { - Target target = TargetFactory.createTarget((OMElement) targetElements.next(), properties); - target.setAsynchronous(asynchronousExe); - mediator.addTarget(target); + Iterator sequenceListElements = elem.getChildrenWithName(SEQUENCE_Q); + while (sequenceListElements.hasNext()) { + OMElement sequence = (OMElement) sequenceListElements.next(); + if (sequence != null) { + Target target = new Target(); + target.setSequence(fac.createAnonymousSequence(sequence, properties)); + target.setAsynchronous(asynchronousExe); + mediator.addTarget(target); + } } OMElement aggregateElement = elem.getFirstChildWithName(ELEMENT_AGGREGATE_Q); diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializer.java b/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializer.java index b585078f9a..78e3e8e44d 100755 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializer.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializer.java @@ -46,7 +46,7 @@ public OMElement serializeSpecificMediator(Mediator m) { OMElement aggregationElement = fac.createOMElement("aggregation", synNS); SynapsePathSerializer.serializePath( - scatterGatherMediator.getAggregationExpression(), aggregationElement, "value-to-aggregate"); + scatterGatherMediator.getAggregationExpression(), aggregationElement, "value"); if (scatterGatherMediator.getCorrelateExpression() != null) { SynapsePathSerializer.serializePath( @@ -68,8 +68,9 @@ public OMElement serializeSpecificMediator(Mediator m) { scatterGatherElement.addChild(aggregationElement); for (Target target : scatterGatherMediator.getTargets()) { - if (target != null) { - scatterGatherElement.addChild(TargetSerializer.serializeTarget(target)); + if (target != null && target.getSequence() != null) { + SequenceMediatorSerializer serializer = new SequenceMediatorSerializer(); + serializer.serializeAnonymousSequence(scatterGatherElement, target.getSequence()); } } serializeComments(scatterGatherElement, scatterGatherMediator.getCommentsList()); diff --git a/modules/core/src/test/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializationTest.java b/modules/core/src/test/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializationTest.java index bcef1aec66..a8572a5256 100644 --- a/modules/core/src/test/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializationTest.java +++ b/modules/core/src/test/java/org/apache/synapse/config/xml/ScatterGatherMediatorSerializationTest.java @@ -37,14 +37,14 @@ public ScatterGatherMediatorSerializationTest() { public void testScatterGatherSerialization() { String inputXML = "" + - "" + + "" + "{ \"pet\": { " + "\"name\": \"pet1\", \"type\": \"dog\" }, " + "\"status\": \"success\" }" + - "" + - "" + + "" + + "" + "" + - ""; + ""; assertTrue(serialization(inputXML, scatterGatherMediatorFactory, scatterGatherMediatorSerializer)); }