You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2006/05/08 08:07:39 UTC
svn commit: r404940 - in
/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse:
./ api/ config/ config/xml/ core/axis2/ mediators/ mediators/base/
mediators/builtin/ mediators/ext/ mediators/filters/ mediators/transform/
Author: saminda
Date: Sun May 7 23:07:37 2006
New Revision: 404940
URL: http://svn.apache.org/viewcvs?rev=404940&view=rev
Log:
Added validation, switch and set-property mediators
miscellaneous changes
Added:
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseDefaultMediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseMediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java
Modified:
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Util.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/FilterMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactory.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java
incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Util.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Util.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Util.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Util.java Sun May 7 23:07:37 2006
@@ -36,13 +36,13 @@
* Evaluates the given XPath expression against the SOAPEnvelope of the
* current message and returns a String representation of the result
* @param xpath the expression to evaluate
- * @param synMsg the source message which holds the SOAP envelope
+ * @param synCtx the source message which holds the SOAP envelope
* @return a String representation of the result of evaluation
*/
- public static String getStringValue(AXIOMXPath xpath, SynapseMessage synMsg) {
+ public static String getStringValue(AXIOMXPath xpath, SynapseContext synCtx) {
try {
- Object result = xpath.evaluate(synMsg.getEnvelope());
+ Object result = xpath.evaluate(synCtx.getSynapseMessage().getEnvelope());
StringBuffer textValue = new StringBuffer();
if (result instanceof List) {
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/FilterMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/FilterMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/FilterMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/FilterMediator.java Sun May 7 23:07:37 2006
@@ -1,20 +1,20 @@
package org.apache.synapse.api;
-import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
/**
* The filter mediator is a list mediator, which executes the given (sub) list of mediators
* if the specified condition is satisfied
*
- * @see FilterMediator#test(org.apache.synapse.SynapseMessage)
+ * @see FilterMediator#test(org.apache.synapse.SynapseContext)
*/
public interface FilterMediator extends ListMediator {
/**
* Should return true if the sub/child mediators should execute. i.e. if the filter
* condition is satisfied
- * @param sm the current message flowing through
+ * @param synCtx
* @return true if the configured filter condition evaluates to true
*/
- public boolean test(SynapseMessage sm);
+ public boolean test(SynapseContext synCtx);
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java Sun May 7 23:07:37 2006
@@ -16,6 +16,7 @@
package org.apache.synapse.api;
import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
/**
* All Synapse mediators must implement this Mediator interface. As a message passes
@@ -29,10 +30,10 @@
* mediator performs its mediation action, and returns true if mediation
* should continue, or false if further mediation should be aborted.
*
- * @param smc the current message for mediation
+ * @param synCtx the current message for mediation
* @return true if further mediation should continue
*/
- public boolean mediate(SynapseMessage smc);
+ public boolean mediate(SynapseContext synCtx);
/**
* This is used for debugging purposes and exposes the type of the current
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java Sun May 7 23:07:37 2006
@@ -43,4 +43,12 @@
public void setMainMediator(Mediator mainMediator) {
this.mainMediator = mainMediator;
}
+
+ public void addProperty(String name, String value) {
+ globalProps.put(name, value);
+ }
+
+ public String getProperty(String name) {
+ return (String) globalProps.get(name);
+ }
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java Sun May 7 23:07:37 2006
@@ -17,9 +17,29 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.synapse.SynapseException;
+import org.jaxen.JaxenException;
+
+import java.util.Iterator;
/**
* Is the abstract superclass of MediatorFactory's
*/
public abstract class AbstractMediatorFactory implements MediatorFactory {
+ public void addNameSpaces(OMElement elem, AXIOMXPath xp, Log log) {
+ try {
+ Iterator it = elem.getAllDeclaredNamespaces();
+ while (it.hasNext()) {
+ OMNamespace n = (OMNamespace) it.next();
+ xp.addNamespace(n.getPrefix(), n.getName());
+ }
+ } catch (JaxenException je) {
+ String msg = "Error adding declared name spaces of " + elem + " to the XPath : " + xp;
+ log.error(msg);
+ throw new SynapseException(msg, je);
+ }
+ }
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java Sun May 7 23:07:37 2006
@@ -67,7 +67,7 @@
throw new SynapseException(msg);
}
}
- addNameSpaces(elem, filter.getXpath());
+ addNameSpaces(elem, filter.getXpath(), log);
} else if (attSource != null && attRegex != null) {
@@ -94,7 +94,7 @@
throw new SynapseException(msg);
}
}
- addNameSpaces(elem, filter.getSource());
+ addNameSpaces(elem, filter.getSource(), log);
} else {
String msg = "An xpath or (source, regex) attributes are required for a filter";
@@ -108,17 +108,4 @@
return FILTER_Q;
}
- private void addNameSpaces(OMElement elem, AXIOMXPath xp) {
- try {
- Iterator it = elem.getAllDeclaredNamespaces();
- while (it.hasNext()) {
- OMNamespace n = (OMNamespace) it.next();
- xp.addNamespace(n.getPrefix(), n.getName());
- }
- } catch (JaxenException je) {
- String msg = "Error adding declared name spaces " + elem;
- log.error(msg);
- throw new SynapseException(msg, je);
- }
- }
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactory.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactory.java Sun May 7 23:07:37 2006
@@ -30,10 +30,10 @@
public interface MediatorFactory {
/**
* Creates an instance of the mediator using the OMElement
- * @param el
+ * @param elem
* @return the created mediator
*/
- public Mediator createMediator(OMElement el);
+ public Mediator createMediator(OMElement elem);
/**
* The QName of this mediator element in the XML config
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java Sun May 7 23:07:37 2006
@@ -55,7 +55,12 @@
DropMediatorFactory.class,
HeaderMediatorFactory.class,
FaultMediatorFactory.class,
- TransformMediatorFactory.class
+ TransformMediatorFactory.class,
+ ValidateMediatorFactory.class,
+ PropertyMediatorFactory.class,
+ SwitchMediatorFactory.class,
+ SwitchCaseMediatorFactory.class,
+ SwitchCaseDefaultMediatorFactory.class
};
private static MediatorFactoryFinder instance = null;
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java Sun May 7 23:07:37 2006
@@ -0,0 +1,77 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.config.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.PropertyMediator;
+import org.apache.synapse.SynapseException;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jaxen.JaxenException;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Creates a set-property mediator through the supplied XML configuration
+ *
+ * <set-property name="string" (value="literal" | expression="xpath")/>
+ */
+public class PropertyMediatorFactory extends AbstractMediatorFactory {
+
+ private static final Log log = LogFactory.getLog(LogMediatorFactory.class);
+
+ private static final QName PROP_Q = new QName(Constants.SYNAPSE_NAMESPACE, "set-property");
+
+ public Mediator createMediator(OMElement elem) {
+
+ PropertyMediator propMediator = new PropertyMediator();
+ OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
+ OMAttribute value = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "value"));
+ OMAttribute expression = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "expression"));
+
+ if (name == null) {
+ String msg = "The 'name' attribute is required for the configuration of a property mediator";
+ log.error(msg);
+ throw new SynapseException(msg);
+ } else if (value == null && expression == null) {
+ String msg = "Either an 'value' or 'expression' attribute is required for a property mediator";
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ propMediator.setName(name.getAttributeValue());
+ if (value != null) {
+ propMediator.setValue(value.getAttributeValue());
+ } else {
+ try {
+ propMediator.setExpression(new AXIOMXPath(expression.getAttributeValue()));
+ } catch (JaxenException e) {
+ String msg = "Invalid XPath expression for attribute 'expression' : " + expression.getAttributeValue();
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+ }
+
+ return propMediator;
+ }
+
+ public QName getTagQName() {
+ return PROP_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseDefaultMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseDefaultMediatorFactory.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseDefaultMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseDefaultMediatorFactory.java Sun May 7 23:07:37 2006
@@ -0,0 +1,47 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.config.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.SwitchCaseMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Create an instance of a Switch mediators' default case (i.e. a SwitchCaseMedaitor
+ * which returns isDefault() true
+ */
+public class SwitchCaseDefaultMediatorFactory extends AbstractListMediatorFactory {
+
+ private static final Log log = LogFactory.getLog(SwitchCaseDefaultMediatorFactory.class);
+
+ private final QName SWITCH_CASE_DEFAULT_Q = new QName(Constants.SYNAPSE_NAMESPACE, "default");
+
+ public Mediator createMediator(OMElement elem) {
+
+ SwitchCaseMediator switchCaseMediator = new SwitchCaseMediator();
+ switchCaseMediator.setDefaultCase(true);
+ super.addChildren(elem, switchCaseMediator);
+ return switchCaseMediator;
+ }
+
+ public QName getTagQName() {
+ return SWITCH_CASE_DEFAULT_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseMediatorFactory.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchCaseMediatorFactory.java Sun May 7 23:07:37 2006
@@ -0,0 +1,61 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.config.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.SwitchCaseMediator;
+import org.apache.synapse.SynapseException;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+public class SwitchCaseMediatorFactory extends AbstractListMediatorFactory {
+
+ private static final Log log = LogFactory.getLog(SwitchCaseMediatorFactory.class);
+
+ private final QName SWITCH_CASE_Q = new QName(Constants.SYNAPSE_NAMESPACE, "case");
+
+ public Mediator createMediator(OMElement elem) {
+
+ SwitchCaseMediator switchCaseMediator = new SwitchCaseMediator();
+ OMAttribute regex = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "regex"));
+ if (regex == null) {
+ String msg = "The 'regex' attribute is required for a switch case definition";
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ try {
+ switchCaseMediator.setRegex(Pattern.compile(regex.getAttributeValue()));
+ } catch (PatternSyntaxException pse) {
+ String msg = "Invalid Regular Expression for attribute 'regex' : " + regex.getAttributeValue();
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ super.addChildren(elem, switchCaseMediator);
+ return switchCaseMediator;
+ }
+
+ public QName getTagQName() {
+ return SWITCH_CASE_Q;
+ }
+}
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java Sun May 7 23:07:37 2006
@@ -0,0 +1,70 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.config.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.SwitchMediator;
+import org.apache.synapse.mediators.filters.SwitchCaseMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * Constructs a Switch mediator instance from the given XML configuration
+ *
+ * <switch source="xpath">
+ * <case regex="string">
+ * mediator+
+ * </case>+
+ * <default>
+ * mediator+
+ * </default>?
+ * </switch>
+ */
+public class SwitchMediatorFactory extends AbstractMediatorFactory {
+
+ private static final Log log = LogFactory.getLog(SwitchMediatorFactory.class);
+
+ private static final QName SWITCH_Q = new QName(Constants.SYNAPSE_NAMESPACE, "switch");
+ private static final QName CASE_Q = new QName(Constants.SYNAPSE_NAMESPACE, "case");
+ private static final QName DEFAULT_Q = new QName(Constants.SYNAPSE_NAMESPACE, "default");
+
+ public Mediator createMediator(OMElement elem) {
+
+ SwitchMediator switchMediator = new SwitchMediator();
+ Iterator iter = elem.getChildrenWithName(CASE_Q);
+ while (iter.hasNext()) {
+ switchMediator.addCase((SwitchCaseMediator)
+ MediatorFactoryFinder.getInstance().getMediator((OMElement) iter.next()));
+ }
+
+ iter = elem.getChildrenWithName(DEFAULT_Q);
+ while (iter.hasNext()) {
+ switchMediator.addCase((SwitchCaseMediator)
+ MediatorFactoryFinder.getInstance().getMediator((OMElement) iter.next()));
+ break; // add only the *first* default if multiple are specified, ignore rest if any
+ }
+
+ return switchMediator;
+ }
+
+ public QName getTagQName() {
+ return SWITCH_Q;
+ }
+}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java Sun May 7 23:07:37 2006
@@ -17,6 +17,7 @@
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.synapse.SynapseException;
import org.apache.synapse.config.SynapseConfiguration;
@@ -26,10 +27,15 @@
import org.apache.commons.logging.LogFactory;
import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
import java.io.InputStream;
import java.io.IOException;
import java.util.Iterator;
+
+/**
+ * Builds a Synapse Configuration model from an XML input stream.
+ */
public class SynapseConfigurationBuilder {
private static Log log = LogFactory.getLog(SynapseConfigurationBuilder.class);
@@ -53,6 +59,7 @@
}
root.build();
+ // digest defined Sequences
OMContainer definitions = root.getFirstChildWithName(Constants.DEFINITIONS_ELT);
if (definitions != null) {
Iterator iter = definitions.getChildrenWithName(Constants.SEQUENCE_ELT);
@@ -62,6 +69,7 @@
}
}
+ // digest defined Endpoints
OMContainer endpoints = root.getFirstChildWithName(Constants.ENDPOINT_ELT);
if (endpoints != null) {
Iterator iter = endpoints.getChildrenWithName(Constants.ENDPOINT_ELT);
@@ -71,12 +79,13 @@
}
}
+ // digest defined Global properties
OMContainer properties = root.getFirstChildWithName(Constants.PROPERTY_ELT);
if (properties != null) {
Iterator iter = properties.getChildrenWithName(Constants.PROPERTY_ELT);
while (iter.hasNext()) {
OMElement elt = (OMElement) iter.next();
- //defineProperty(synCfg, elt); //TODO process Properties
+ defineProperty(elt);
}
}
@@ -101,6 +110,21 @@
is.close();
} catch (IOException e) {}
}
+ }
+
+ /**
+ * <set-property name="string" value="string"/>
+ * @param elem
+ */
+ private void defineProperty(OMElement elem) {
+ OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
+ OMAttribute value = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "value"));
+ if (name == null || value == null) {
+ String msg = "The 'name' and 'value' attributes are required";
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+ config.addProperty(name.getAttributeValue(), value.getAttributeValue());
}
private void defineSequence(OMElement ele) {
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java Sun May 7 23:07:37 2006
@@ -0,0 +1,88 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.config.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.ValidateMediator;
+import org.apache.synapse.SynapseException;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jaxen.JaxenException;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Creates a validation mediator from the XML configuration
+ *
+ * <validate schema="url" [source="xpath"]>
+ * <on-fail>
+ * mediator+
+ * </on-fail>
+ * </validate>
+ */
+public class ValidateMediatorFactory extends AbstractListMediatorFactory {
+
+ private static final Log log = LogFactory.getLog(TransformMediatorFactory.class);
+ private static final QName VALIDATE_Q = new QName(Constants.SYNAPSE_NAMESPACE, "validate");
+
+ public Mediator createMediator(OMElement elem) {
+
+ ValidateMediator validateMediator = new ValidateMediator();
+ OMAttribute attSchema = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "schema"));
+ OMAttribute attSource = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "source"));
+
+ if (attSchema != null) {
+ validateMediator.setSchemaUrl(attSchema.getAttributeValue());
+ } else {
+ String msg = "The 'schema' attribute is required for the validate mediator configuration";
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ if (attSource != null) {
+ try {
+ AXIOMXPath xp = new AXIOMXPath(attSource.getAttributeValue());
+ validateMediator.setSource(xp);
+ addNameSpaces(elem, xp, log);
+
+ } catch (JaxenException e) {
+ String msg = "Invalid XPath expression specified for attribute 'source'";
+ log.error(msg);
+ throw new SynapseException(msg, e);
+ }
+ }
+
+ OMElement onFail = elem.getFirstElement();
+ if (new QName(Constants.SYNAPSE_NAMESPACE, "on-fail").equals(onFail.getQName()) &&
+ onFail.getChildElements().hasNext()) {
+ super.addChildren(onFail, validateMediator);
+
+ } else {
+ String msg = "A non-empty on-fail element is required for the validate mediator";
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ return validateMediator;
+ }
+
+ public QName getTagQName() {
+ return VALIDATE_Q;
+ }
+}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java Sun May 7 23:07:37 2006
@@ -36,7 +36,7 @@
public void injectMessage(SynapseContext synCtx) {
synCtx.setSynapseEnvironment(this);
- synCtx.getConfiguration().getMainMediator().mediate(synCtx.getSynapseMessage());
+ synCtx.getConfiguration().getMainMediator().mediate(synCtx);
}
public void send(SynapseContext synCtx) {
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java Sun May 7 23:07:37 2006
@@ -16,7 +16,7 @@
package org.apache.synapse.mediators;
-import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.api.Mediator;
import org.apache.synapse.api.ListMediator;
import org.apache.commons.logging.LogFactory;
@@ -37,13 +37,13 @@
protected List mediators = new ArrayList();
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
Iterator it = mediators.iterator();
while (it.hasNext()) {
Mediator m = (Mediator) it.next();
- if (!m.mediate(synMsg)) {
+ if (!m.mediate(synCtx)) {
return false;
}
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java Sun May 7 23:07:37 2006
@@ -17,7 +17,7 @@
import org.apache.synapse.config.xml.Constants;
import org.apache.synapse.Util;
-import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
import org.apache.axiom.om.xpath.AXIOMXPath;
import javax.xml.namespace.QName;
@@ -64,8 +64,8 @@
this.expression = expression;
}
- public String getEvaluatedExpression(SynapseMessage synMsg) {
- return Util.getStringValue(expression, synMsg);
+ public String getEvaluatedExpression(SynapseContext synCtx) {
+ return Util.getStringValue(expression, synCtx);
}
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java Sun May 7 23:07:37 2006
@@ -15,8 +15,8 @@
*/
package org.apache.synapse.mediators.base;
-import org.apache.synapse.SynapseMessage;
import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.api.Mediator;
import org.apache.synapse.mediators.AbstractListMediator;
import org.apache.commons.logging.Log;
@@ -40,22 +40,22 @@
* change of the synapse configuration. It is the responsibility of the
* SynapseConfiguration builder to ensure that dead references are not present.
*
- * @param synMsg the synapse message
+ * @param synCtx the synapse message
* @return as per standard mediator result
*/
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
if (ref == null) {
- return super.mediate(synMsg);
+ return super.mediate(synCtx);
} else {
- Mediator m = synMsg.getSynapseContext().getConfiguration().getNamedMediator(ref);
+ Mediator m = synCtx.getConfiguration().getNamedMediator(ref);
if (m == null) {
String msg = "Sequence mediator instance named " + ref + " cannot be found.";
log.error(msg);
throw new SynapseException(msg);
} else {
- return m.mediate(synMsg);
+ return m.mediate(synCtx);
}
}
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java Sun May 7 23:07:37 2006
@@ -16,7 +16,7 @@
package org.apache.synapse.mediators.builtin;
-import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,15 +30,15 @@
/**
* Halts further mediation of the current message by returning false.
- * @param synMsg the current message
+ * @param synCtx the current message
* @return false always
*/
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
- if (synMsg.getTo() == null) {
+ if (synCtx.getSynapseMessage().getTo() == null) {
return false;
} else {
- synMsg.setTo(null);
+ synCtx.getSynapseMessage().setTo(null);
return false;
}
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java Sun May 7 23:07:37 2006
@@ -18,6 +18,7 @@
import org.apache.axiom.soap.SOAPHeader;
import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.synapse.mediators.MediatorProperty;
import org.apache.commons.logging.Log;
@@ -50,37 +51,38 @@
/**
* Logs the current message according to the supplied semantics
- * @param synMsg (current) message to be logged
+ * @param synCtx (current) message to be logged
* @return true always
*/
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
- log.info(getLogMessage(synMsg));
+ log.info(getLogMessage(synCtx));
return true;
}
- private String getLogMessage(SynapseMessage synMsg) {
+ private String getLogMessage(SynapseContext synCtx) {
switch (logLevel) {
case CUSTOM:
- return getCustomLogMessage(synMsg);
+ return getCustomLogMessage(synCtx);
case SIMPLE:
- return getSimpleLogMessage(synMsg);
+ return getSimpleLogMessage(synCtx);
case HEADERS:
- return getHeadersLogMessage(synMsg);
+ return getHeadersLogMessage(synCtx);
case FULL:
- return getFullLogMessage(synMsg);
+ return getFullLogMessage(synCtx);
default:
return "Invalid log level specified";
}
}
- private String getCustomLogMessage(SynapseMessage synMsg) {
+ private String getCustomLogMessage(SynapseContext synCtx) {
StringBuffer sb = new StringBuffer();
- setCustomProperties(sb, synMsg);
+ setCustomProperties(sb, synCtx);
return sb.toString();
}
- private String getSimpleLogMessage(SynapseMessage synMsg) {
+ private String getSimpleLogMessage(SynapseContext synCtx) {
+ SynapseMessage synMsg = synCtx.getSynapseMessage();
StringBuffer sb = new StringBuffer();
if (synMsg.getTo() != null)
sb.append("To: " + synMsg.getTo().getAddress());
@@ -94,37 +96,39 @@
sb.append(SEP + "ReplyTo: " + synMsg.getReplyTo().getAddress());
if (synMsg.getMessageID() != null)
sb.append(SEP + "MessageID: " + synMsg.getMessageID());
- setCustomProperties(sb, synMsg);
+ setCustomProperties(sb, synCtx);
return sb.toString();
}
- private String getHeadersLogMessage(SynapseMessage synMsg) {
+ private String getHeadersLogMessage(SynapseContext synCtx) {
+ SynapseMessage synMsg = synCtx.getSynapseMessage();
StringBuffer sb = new StringBuffer();
Iterator iter = synMsg.getEnvelope().getHeader().examineAllHeaderBlocks();
while (iter.hasNext()) {
SOAPHeader header = (SOAPHeader) iter.next();
sb.append(SEP + header.getLocalName() + " : " + header.getText());
}
- setCustomProperties(sb, synMsg);
+ setCustomProperties(sb, synCtx);
return sb.toString();
}
- private String getFullLogMessage(SynapseMessage synMsg) {
+ private String getFullLogMessage(SynapseContext synCtx) {
+ SynapseMessage synMsg = synCtx.getSynapseMessage();
StringBuffer sb = new StringBuffer();
- sb.append(getSimpleLogMessage(synMsg));
+ sb.append(getSimpleLogMessage(synCtx));
if (synMsg.getEnvelope() != null)
sb.append(SEP + "Envelope: " + synMsg.getEnvelope());
- setCustomProperties(sb, synMsg);
+ setCustomProperties(sb, synCtx);
return sb.toString();
}
- private void setCustomProperties(StringBuffer sb, SynapseMessage synMsg) {
+ private void setCustomProperties(StringBuffer sb, SynapseContext synCtx) {
if (properties != null && !properties.isEmpty()) {
Iterator iter = properties.iterator();
while (iter.hasNext()) {
MediatorProperty prop = (MediatorProperty) iter.next();
sb.append(SEP + prop.getName() + " = " +
- (prop.getValue() != null ? prop.getValue() : prop.getEvaluatedExpression(synMsg)));
+ (prop.getValue() != null ? prop.getValue() : prop.getEvaluatedExpression(synCtx)));
}
}
}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java Sun May 7 23:07:37 2006
@@ -0,0 +1,68 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators.builtin;
+
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.Util;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+/**
+ * The property mediator would save a named property as a local property
+ * of the Synapse Message Context. Properties set this way could be
+ * extracted through the XPath extension function "synapse:get-property(prop-name)"
+ */
+public class PropertyMediator extends AbstractMediator {
+
+ private String name = null;
+ private String value = null;
+ private AXIOMXPath expression = null;
+
+ /**
+ * Sets a property into the current (local) Synapse Context
+ * @param smc the message context
+ * @return true always
+ */
+ public boolean mediate(SynapseContext smc) {
+ smc.setProperty(getName(),
+ (value != null ? getValue() : Util.getStringValue(getExpression(), smc)));
+ return true;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public AXIOMXPath getExpression() {
+ return expression;
+ }
+
+ public void setExpression(AXIOMXPath expression) {
+ this.expression = expression;
+ }
+}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java Sun May 7 23:07:37 2006
@@ -16,8 +16,7 @@
package org.apache.synapse.mediators.builtin;
-import org.apache.synapse.SynapseMessage;
-import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,14 +35,15 @@
* This is a leaf mediator. i.e. processing stops once send is invoked,
* as it always returns false
*
- * @param synMsg the current message to be sent
+ * @param synCtx the current message to be sent
* @return false always as this is a leaf mediator
*/
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
- log.debug("Sending To: " + (synMsg.getTo() != null ? synMsg.getTo().getAddress() : "null"));
- log.debug("Body : \n" + synMsg.getEnvelope());
- synMsg.getSynapseContext().getSynapseEnvironment().send(synMsg.getSynapseContext());
+ log.debug("Sending To: " + (synCtx.getSynapseMessage().getTo() != null ?
+ synCtx.getSynapseMessage().getTo().getAddress() : "null"));
+ log.debug("Body : \n" + synCtx.getSynapseMessage().getEnvelope());
+ synCtx.getSynapseEnvironment().send(synCtx);
return false;
}
}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java Sun May 7 23:07:37 2006
@@ -0,0 +1,198 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators.builtin;
+
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.AbstractListMediator;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+import org.jaxen.JaxenException;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLOutputFactory;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * Validate a message or an element against a schema
+ */
+public class ValidateMediator extends AbstractListMediator {
+
+ private static final Log log = LogFactory.getLog(ValidateMediator.class);
+
+ private String schemaUrl = null;
+ private AXIOMXPath source = null;
+
+ private static final String SCHEMA_LOCATION_NO_NS =
+ "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
+ private static final String SCHEMA_LOCATION_NS =
+ "http://apache.org/xml/properties/schema/external-schemaLocation";
+ private static final String FULL_CHECKING = "http://apache.org/xml/features/validation/schema-full-checking";
+ private static final String SCHEMA_VALIDATION = "http://apache.org/xml/features/validation/schema";
+ private static final String VALIDATION = "http://xml.org/sax/features/validation";
+
+ public String getSchemaUrl() {
+ return schemaUrl;
+ }
+
+ public void setSchemaUrl(String schemaUrl) {
+ this.schemaUrl = schemaUrl;
+ }
+
+ public AXIOMXPath getSource() {
+ return source;
+ }
+
+ public void setSource(AXIOMXPath source) {
+ this.source = source;
+ }
+
+ private OMNode getValidateSource(SynapseMessage synMsg) {
+
+ if (source == null) {
+ try {
+ source = new AXIOMXPath("//SOAP-ENV:Body");
+ source.addNamespace("SOAP-ENV", synMsg.isSOAP11() ?
+ SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI : SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ } catch (JaxenException e) {}
+ }
+
+ try {
+ Object o = source.evaluate(synMsg.getEnvelope());;
+ if (o instanceof OMNode) {
+ return (OMNode) o;
+ } else if (o instanceof List && !((List) o).isEmpty()) {
+ return (OMNode) ((List) o).get(0); // Always fetches *only* the first
+ } else {
+ String msg = "The evaluation of the XPath expression " + source + " must result in an OMNode";
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ } catch (JaxenException e) {
+ String msg = "Error evaluating XPath " + source + " on message";
+ log.error(msg);
+ throw new SynapseException(msg, e);
+ }
+ }
+
+ public boolean mediate(SynapseContext synCtx) {
+
+ ByteArrayInputStream baisFromSource = null;
+ StringBuffer nsLocations = new StringBuffer();
+
+ try {
+ // create a byte array output stream and serialize the source node into it
+ ByteArrayOutputStream baosForSource = new ByteArrayOutputStream();
+ XMLStreamWriter xsWriterForSource = XMLOutputFactory.newInstance().createXMLStreamWriter(baosForSource);
+
+ // save the list of defined namespaces for validation against the schema
+ OMNode sourceNode = getValidateSource(synCtx.getSynapseMessage());
+ if (sourceNode instanceof OMElement) {
+ Iterator iter = ((OMElement) sourceNode).getAllDeclaredNamespaces();
+ while (iter.hasNext()) {
+ OMNamespace omNS = (OMNamespace) iter.next();
+ nsLocations.append(omNS.getName() + " " + getSchemaUrl());
+ }
+ }
+ sourceNode.serialize(xsWriterForSource);
+ baisFromSource = new ByteArrayInputStream(baosForSource.toByteArray());
+
+ } catch (Exception e) {
+ String msg = "Error accessing source element for validation : " + source;
+ log.error(msg);
+ throw new SynapseException(msg, e);
+ }
+
+ try {
+ SAXParserFactory spFactory = SAXParserFactory.newInstance();
+ spFactory.setNamespaceAware(true);
+ spFactory.setValidating(true);
+ SAXParser parser = spFactory.newSAXParser();
+
+ parser.setProperty(VALIDATION, Boolean.TRUE);
+ parser.setProperty(SCHEMA_VALIDATION, Boolean.TRUE);
+ parser.setProperty(FULL_CHECKING, Boolean.TRUE);
+ parser.setProperty(SCHEMA_LOCATION_NS, nsLocations.toString());
+ parser.setProperty(SCHEMA_LOCATION_NO_NS, getSchemaUrl());
+
+ Validator handler = new Validator();
+ parser.parse(baisFromSource, handler);
+
+ if (handler.isValidationError()) {
+ log.debug("Validation failed :" + handler.getSaxParseException().getMessage());
+ // super.mediate() invokes the "on-fail" sequence of mediators
+ return super.mediate(synCtx);
+ }
+
+ }
+ catch (Exception e) {
+ String msg = "Error validating " + source + " against schema : " + schemaUrl + " : " + e.getMessage();
+ log.error(msg);
+ throw new SynapseException(msg, e);
+ }
+
+ return true;
+ }
+
+ /**
+ * This class handles validation errors to be used for error reporting
+ */
+ private class Validator extends DefaultHandler {
+
+ private boolean validationError = false;
+ private SAXParseException saxParseException = null;
+
+ public void error(SAXParseException exception) throws SAXException {
+ validationError = true;
+ saxParseException = exception;
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException {
+ validationError = true;
+ saxParseException = exception;
+ }
+
+ public void warning(SAXParseException exception) throws SAXException {
+ }
+
+ public boolean isValidationError() {
+ return validationError;
+ }
+
+ public SAXParseException getSaxParseException() {
+ return saxParseException;
+ }
+ }
+
+}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java Sun May 7 23:07:37 2006
@@ -18,7 +18,7 @@
import org.apache.synapse.SynapseException;
-import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.api.Mediator;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.commons.logging.Log;
@@ -37,7 +37,7 @@
private static final Log log = LogFactory.getLog(ClassMediator.class);
- public boolean mediate(SynapseMessage smc) {
+ public boolean mediate(SynapseContext smc) {
log.debug(getType() + " mediate()");
Mediator m = null;
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java Sun May 7 23:07:37 2006
@@ -17,19 +17,14 @@
package org.apache.synapse.mediators.filters;
import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.llom.OMTextImpl;
-import org.apache.axiom.om.impl.llom.OMElementImpl;
-import org.apache.synapse.SynapseMessage;
import org.apache.synapse.Util;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.mediators.AbstractListMediator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jaxen.JaxenException;
import java.util.regex.Pattern;
-import java.util.List;
-import java.util.Iterator;
/**
* The filter mediator combines the regex and xpath filtering functionality. If an xpath
@@ -44,13 +39,13 @@
/**
* Executes the list of sub/child mediators, if the filter condition is satisfied
- * @param synMsg the current message
+ * @param synCtx the current message
* @return true if filter condition fails. else returns as per List mediator semantics
*/
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
- if (test(synMsg)) {
- return super.mediate(synMsg);
+ if (test(synCtx)) {
+ return super.mediate(synCtx);
} else {
return true;
}
@@ -61,16 +56,16 @@
* or Regex (against a source XPath). When a regular expression is supplied
* the source XPath is evaluated into a String value, and matched against
* the given regex
- * @param synMsg the current message for evaluation of the test condition
+ * @param synCtx the current message for evaluation of the test condition
* @return true if evaluation of the XPath/Regex results in true
*/
- public boolean test(SynapseMessage synMsg) {
+ public boolean test(SynapseContext synCtx) {
try {
if (xpath != null) {
- return xpath.booleanValueOf(synMsg.getEnvelope());
+ return xpath.booleanValueOf(synCtx.getSynapseMessage().getEnvelope());
} else if (source != null && regex != null) {
- return regex.matcher(Util.getStringValue(source, synMsg)).matches();
+ return regex.matcher(Util.getStringValue(source, synCtx)).matches();
} else {
log.error("Invalid configuration specified");
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java Sun May 7 23:07:37 2006
@@ -0,0 +1,50 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators.filters;
+
+import org.apache.synapse.mediators.AbstractListMediator;
+
+import java.util.regex.Pattern;
+
+/**
+ * A SwitchCaseMediator is a list mediator which has a regex that is matched by
+ * its owning SwitchMediator for selection
+ */
+public class SwitchCaseMediator extends AbstractListMediator {
+
+ private Pattern regex = null;
+ private boolean defaultCase = false;
+
+ public Pattern getRegex() {
+ return regex;
+ }
+
+ public void setRegex(Pattern regex) {
+ this.regex = regex;
+ }
+
+ public boolean isDefaultCase() {
+ return defaultCase;
+ }
+
+ public void setDefaultCase(boolean defaultCase) {
+ this.defaultCase = defaultCase;
+ }
+
+ public boolean matches(String value) {
+ return regex.matcher(value).matches();
+ }
+}
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java?rev=404940&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java Sun May 7 23:07:37 2006
@@ -0,0 +1,78 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators.filters;
+
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.AbstractListMediator;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.Util;
+import org.apache.synapse.api.Mediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+import java.util.regex.Pattern;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * The switch mediator implements the functionality of the "switch" contruct. It first
+ * evaluates the given XPath expression into a String value, and performs a match against
+ * the given list of cases. This is actually a list of sequences, and depending on the
+ * selected case, the selected sequence gets executed.
+ */
+public class SwitchMediator extends AbstractMediator {
+
+ private static final Log log = LogFactory.getLog(SwitchMediator.class);
+
+ private AXIOMXPath source = null;
+ private List cases = new ArrayList();
+ private SwitchCaseMediator defaultCase = null;
+
+ /**
+ * Iterate over switch cases and find match and execute selected sequence
+ * @param synCtx current context
+ * @return as per standard semantics
+ */
+ public boolean mediate(SynapseContext synCtx) {
+
+ String sourceText = Util.getStringValue(source, synCtx);
+ Iterator iter = cases.iterator();
+
+ while (iter.hasNext()) {
+ SwitchCaseMediator swCase = (SwitchCaseMediator) iter.next();
+ if (swCase.matches(sourceText)) {
+ return swCase.mediate(synCtx);
+ }
+ }
+
+ if (defaultCase != null) {
+ return defaultCase.mediate(synCtx);
+ }
+
+ return true;
+ }
+
+ /**
+ * Adds the given mediator (Should be a SwitchCaseMediator) to the list of cases
+ * of this Switch mediator
+ * @param m the SwitchCaseMediator instance to be added
+ */
+ public void addCase(SwitchCaseMediator m) {
+ cases.add(m);
+ }
+}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java Sun May 7 23:07:37 2006
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.SynapseMessage;
import org.apache.synapse.mediators.AbstractMediator;
@@ -49,8 +50,9 @@
//TODO support SOAP 1.2 fault stuff..
//Node, Role, detail etc
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
+ SynapseMessage synMsg = synCtx.getSynapseMessage();
SOAPEnvelope envelop = synMsg.getEnvelope();
SOAPFactory factory;
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java Sun May 7 23:07:37 2006
@@ -16,9 +16,9 @@
package org.apache.synapse.mediators.transform;
import org.apache.synapse.mediators.AbstractMediator;
-import org.apache.synapse.SynapseMessage;
import org.apache.synapse.HeaderType;
import org.apache.synapse.Util;
+import org.apache.synapse.SynapseContext;
import org.apache.axiom.om.xpath.AXIOMXPath;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,18 +49,19 @@
/**
* Sets/Removes a SOAP header on the current message
*
- * @param synMsg the current message which is altered as necessary
+ * @param synCtx the current message which is altered as necessary
* @return true always
*/
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
if (action == ACTION_SET) {
- headerType.setHeader(synMsg,
- (getValue() != null ? getValue() : Util.getStringValue(getExpression(), synMsg)));
+ headerType.setHeader(synCtx.getSynapseMessage(),
+ (getValue() != null ? getValue() :
+ Util.getStringValue(getExpression(), synCtx)));
} else {
- headerType.removeHeader(synMsg);
+ headerType.removeHeader(synCtx.getSynapseMessage());
}
return true;
}
Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java?rev=404940&r1=404939&r2=404940&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java Sun May 7 23:07:37 2006
@@ -2,17 +2,15 @@
import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.xpath.AXIOMXPath;
import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.synapse.SynapseException;
import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -48,14 +46,14 @@
/**
* Transforms this message (or its element specified as the source) using the
* given XSLT or XQuery transformation
- * @param synMsg the current message where the transformation will apply
+ * @param synCtx the current message where the transformation will apply
* @return true always
*/
- public boolean mediate(SynapseMessage synMsg) {
+ public boolean mediate(SynapseContext synCtx) {
log.debug(getType() + " mediate()");
if (xsltUrl != null) {
- performXLST(synMsg);
+ performXLST(synCtx.getSynapseMessage());
return true;
} else if (xQueryUrl != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org