01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.synapse.config.xml;
21:
22: import org.apache.axiom.om.OMAttribute;
23: import org.apache.axiom.om.OMElement;
24: import org.apache.synapse.Mediator;
25: import org.apache.synapse.mediators.eip.splitter.CloneMediator;
26:
27: import javax.xml.namespace.QName;
28: import java.util.Iterator;
29:
30: /**
31: * The <clone> element is used to copy messages in Synapse to simillar messages but with
32: * different message contexts and mediated using the specified targets
33: *
34: * <pre>
35: * <clone [continueParent=(true | false)]>
36: * <target [to="uri"] [soapAction="qname"] [sequence="sequence_ref"]
37: * [endpoint="endpoint_ref"]>
38: * <sequence>
39: * (mediator)+
40: * </sequence>?
41: * <endpoint>
42: * endpoint
43: * </endpoint>?
44: * </target>+
45: * </clone>
46: * </pre>
47: */
48: public class CloneMediatorFactory extends AbstractMediatorFactory {
49:
50: /**
51: * This will hold the QName of the clone mediator element in the xml configuration
52: */
53: private static final QName CLONE_Q = new QName(
54: XMLConfigConstants.SYNAPSE_NAMESPACE, "clone");
55: private static final QName ATT_CONTPAR = new QName("continueParent");
56: private static final QName TARGET_Q = new QName(
57: XMLConfigConstants.SYNAPSE_NAMESPACE, "target");
58:
59: /**
60: * This method implements the createMediator method of the MediatorFactory interface
61: *
62: * @param elem - OMElement describing the element which will be parsed
63: * to build the CloneMediator
64: * @return Mediator of the type CloneMediator built from the config element
65: */
66: public Mediator createMediator(OMElement elem) {
67:
68: CloneMediator mediator = new CloneMediator();
69: processTraceState(mediator, elem);
70:
71: OMAttribute continueParent = elem.getAttribute(ATT_CONTPAR);
72: if (continueParent != null) {
73: mediator.setContinueParent(Boolean.valueOf(
74: continueParent.getAttributeValue()).booleanValue());
75: }
76:
77: Iterator targetElements = elem.getChildrenWithName(TARGET_Q);
78: while (targetElements.hasNext()) {
79: mediator.addTarget(TargetFactory
80: .createTarget((OMElement) targetElements.next()));
81: }
82:
83: return mediator;
84: }
85:
86: /**
87: * This method will implement the getTagQName method of the MediatorFactory interface
88: *
89: * @return QName of the clone element in xml configuraiton
90: */
91: public QName getTagQName() {
92: return CLONE_Q;
93: }
94: }
|