You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by pz...@apache.org on 2006/06/01 11:28:27 UTC
svn commit: r410809 [5/10] - in /incubator/synapse/tags/M2: ./ bin/ etc/
modules/ modules/core/ modules/core/conf/ modules/core/src/
modules/core/src/org/ modules/core/src/org/apache/
modules/core/src/org/apache/synapse/ modules/core/src/org/apache/syn...
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,59 @@
+/*
+ * 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.core.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+
+/**
+ * This message receiver should be configured in the Axis2 configuration as the
+ * default message receiver, which will handle all incoming messages through the
+ * synapse mediation
+ */
+public class SynapseMessageReceiver implements MessageReceiver {
+
+ private static final Log log = LogFactory.getLog(SynapseMessageReceiver.class);
+
+ public void receive(org.apache.axis2.context.MessageContext mc) throws AxisFault {
+
+ log.debug("Synapse received a new message...");
+ log.debug("Received To: " + (mc.getTo() != null ?
+ mc.getTo().getAddress() : "null"));
+ log.debug("SOAPAction: " + (mc.getWSAAction() != null ?
+ mc.getWSAAction() : "null"));
+ log.debug("Body : \n" + mc.getEnvelope());
+
+ MessageContext synCtx = Axis2MessageContextFinder.getSynapseMessageContext(mc);
+ synCtx.getEnvironment().injectMessage(synCtx);
+
+ // Response handling mechanism for 200/202 and 5XX
+ // if smc.isResponse = true then the response will be handled with 200 OK
+ // else, response will be 202 OK without an http body
+ // if smc.isFaultRespose = true then the response is a fault with 500 Internal Server Error
+
+ if (synCtx.isResponse()) {
+ mc.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+ }
+ if (synCtx.isFaultResponse()) {
+ // todo: is there a better way to inject faultSoapEnv to the Axis2 Transport
+ throw new AxisFault("Synapse Encountered an Error - See Log for More Details");
+ }
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.ListMediator;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This class implements the base functionality of a List mediator
+ *
+ * @see ListMediator
+ */
+public abstract class AbstractListMediator extends AbstractMediator implements ListMediator {
+
+ private static final Log log = LogFactory.getLog(AbstractListMediator.class);
+
+ protected List mediators = new ArrayList();
+
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Implicit Sequence <" + getType() + "> :: mediate()");
+
+ Iterator it = mediators.iterator();
+ while (it.hasNext()) {
+ Mediator m = (Mediator) it.next();
+ if (!m.mediate(synCtx)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public List getList() {
+ return mediators;
+ }
+
+ public boolean addChild(Mediator m) {
+ return mediators.add(m);
+ }
+
+ public boolean addAll(List c) {
+ return mediators.addAll(c);
+ }
+
+ public Mediator getChild(int pos) {
+ return (Mediator) mediators.get(pos);
+ }
+
+ public boolean removeChild(Mediator m) {
+ return mediators.remove(m);
+ }
+
+ public Mediator removeChild(int pos) {
+ return (Mediator) mediators.remove(pos);
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,40 @@
+/*
+* 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.api.Mediator;
+
+/**
+ * This class is an abstract Mediator, that defines the logging and debugging
+ * elements of a mediator class.
+ */
+public abstract class AbstractMediator implements Mediator {
+
+ /**
+ * Returns the class name of the mediator
+ * @return the class name of the mediator
+ */
+ public String getType() {
+ String cls = getClass().getName();
+ int p = cls.lastIndexOf(".");
+ if (p == -1)
+ return cls;
+ else
+ return cls.substring(p+1);
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,86 @@
+/*
+* 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;
+
+import org.jaxen.Function;
+import org.jaxen.Context;
+import org.jaxen.FunctionCallException;
+import org.jaxen.Navigator;
+import org.jaxen.function.StringFunction;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.HeaderType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * Implements the XPath extension function synapse:get-property(prop-name)
+ */
+public class GetPropertyFunction implements Function {
+
+ private static final Log log = LogFactory.getLog(GetPropertyFunction.class);
+
+ private MessageContext synCtx = null;
+
+ public MessageContext getSynCtx() {
+ return synCtx;
+ }
+
+ public void setSynCtx(MessageContext synCtx) {
+ this.synCtx = synCtx;
+ }
+
+ public Object call(Context context, List args) throws FunctionCallException {
+ if (args.isEmpty()) {
+ log.warn("Property key value for lookup was not specified");
+ return null;
+ } else if (synCtx == null) {
+ log.warn("Synapse context has not been set for the XPath extension function" +
+ "'synapse:get-property(prop-name)'");
+ return null;
+
+ } else {
+ Navigator navigator = context.getNavigator();
+ Iterator iter = args.iterator();
+ while (iter.hasNext()) {
+ String key = StringFunction.evaluate(iter.next(), navigator);
+ // ignore if more than one argument has been specified
+ Object result = synCtx.getProperty(key);
+
+ if (result != null) {
+ return result;
+ } else {
+ if (HeaderType.STR_TO.equals(key) && synCtx.getTo() != null) {
+ return synCtx.getTo().getAddress();
+ } else if (HeaderType.STR_FROM.equals(key) && synCtx.getFrom() != null) {
+ return synCtx.getFrom().getAddress();
+ } else if (HeaderType.STR_ACTION.equals(key) && synCtx.getWSAAction() != null) {
+ return synCtx.getWSAAction();
+ } else if (HeaderType.STR_FAULT.equals(key) && synCtx.getFaultTo() != null) {
+ return synCtx.getFaultTo().getAddress();
+ } else if (HeaderType.STR_REPLY_TO.equals(key) && synCtx.getReplyTo() != null) {
+ return synCtx.getReplyTo().getAddress();
+ } else {
+ return null;
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,71 @@
+/*
+* 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;
+
+import org.apache.synapse.config.xml.Constants;
+import org.apache.synapse.Util;
+import org.apache.synapse.MessageContext;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+import javax.xml.namespace.QName;
+
+/**
+ * A mediator property is a name-value or name-expression pair which could be supplied
+ * for certain mediators. If expressions are supplied they are evaluated at the runtime
+ * against the current message into literal String values.
+ */
+public class MediatorProperty {
+
+ public static final QName PROPERTY_Q = new QName(Constants.SYNAPSE_NAMESPACE, "property");
+ public static final QName ATT_NAME_Q = new QName(Constants.NULL_NAMESPACE, "name");
+ public static final QName ATT_VALUE_Q = new QName(Constants.NULL_NAMESPACE, "value");
+ public static final QName ATT_EXPR_Q = new QName(Constants.NULL_NAMESPACE, "expression");
+
+ private String name;
+ private String value;
+ private AXIOMXPath expression;
+
+ public MediatorProperty() {}
+
+ 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;
+ }
+
+ public String getEvaluatedExpression(MessageContext synCtx) {
+ return Util.getStringValue(expression, synCtx);
+ }
+
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java Thu Jun 1 02:28:13 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.base;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.AbstractListMediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Sequence mediator either refers to another Sequence mediator instance
+ * or is a *Named* list/sequence of other (child) Mediators
+ */
+public class SequenceMediator extends AbstractListMediator {
+
+ private static final Log log = LogFactory.getLog(SequenceMediator.class);
+ private String name = null;
+ private String ref = null;
+
+ /**
+ * If this mediator refers to another named Sequence, execute that. Else
+ * execute the list of mediators (children) contained within this. If a referenced
+ * named sequence mediator instance cannot be found at runtime, an exception is
+ * thrown. This may occur due to invalid configuration of an erroneous runtime
+ * change of the synapse configuration. It is the responsibility of the
+ * SynapseConfiguration builder to ensure that dead references are not present.
+ *
+ * @param synCtx the synapse message
+ * @return as per standard mediator result
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Sequence mediator <" + (name == null? "anonymous" : name ) +"> :: mediate()");
+ if (ref == null) {
+ return super.mediate(synCtx);
+
+ } else {
+ 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(synCtx);
+ }
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRef() {
+ return ref;
+ }
+
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,46 @@
+/*
+ * 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.base;
+
+import org.apache.synapse.mediators.AbstractListMediator;
+import org.apache.synapse.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The SynapseMediator is the "mainmediator" of the synapse engine. It is
+ * given each message on arrival at the synapse engine. The synapse configuration
+ * holds a reference to this special mediator instance. The SynapseMediator
+ * holds the list of mediators supplied within the <rules> element of an XML
+ * based Synapse configuration
+ *
+ * @see org.apache.synapse.config.SynapseConfiguration#getMainMediator()
+ */
+public class SynapseMediator extends AbstractListMediator {
+
+ private static final Log log = LogFactory.getLog(SynapseMediator.class);
+
+ /**
+ * Perform the mediation specified by the rule set
+ * @param synCtx the message context
+ * @return as per standard mediate() semantics
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Synapse main mediator :: mediate()");
+ return super.mediate(synCtx);
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,45 @@
+/*
+ * 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.MessageContext;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Halts further processing/mediation of the current message. i.e. returns false
+ */
+public class DropMediator extends AbstractMediator {
+
+ private static final Log log = LogFactory.getLog(LogMediator.class);
+
+ /**
+ * Halts further mediation of the current message by returning false.
+ * @param synCtx the current message
+ * @return false always
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Drop mediator :: mediate()");
+ if (synCtx.getTo() == null) {
+ return false;
+ } else {
+ synCtx.setTo(null);
+ return false;
+ }
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,158 @@
+/*
+ * 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.axiom.soap.SOAPHeader;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.MediatorProperty;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+
+/**
+ * Logs the specified message into the configured logger. The log levels specify
+ * which attributes would be logged, and is configurable. Additionally custom
+ * properties may be defined to the logger, where literal values or expressions
+ * could be specified for logging. The custom properties are printed into the log
+ * using the defined seperator (\n, "," etc)
+ */
+public class LogMediator extends AbstractMediator {
+
+ private static final Log log = LogFactory.getLog(LogMediator.class);
+
+ public static final int CUSTOM = 0;
+ public static final int SIMPLE = 1;
+ public static final int HEADERS = 2;
+ public static final int FULL = 3;
+
+ private int logLevel = SIMPLE;
+ private String SEP = ", ";
+ private List properties = new ArrayList();
+
+ /**
+ * Logs the current message according to the supplied semantics
+ * @param synCtx (current) message to be logged
+ * @return true always
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Log mediator :: mediate()");
+ log.info(getLogMessage(synCtx));
+ return true;
+ }
+
+ private String getLogMessage(MessageContext synCtx) {
+ switch (logLevel) {
+ case CUSTOM:
+ return getCustomLogMessage(synCtx);
+ case SIMPLE:
+ return getSimpleLogMessage(synCtx);
+ case HEADERS:
+ return getHeadersLogMessage(synCtx);
+ case FULL:
+ return getFullLogMessage(synCtx);
+ default:
+ return "Invalid log level specified";
+ }
+ }
+
+ private String getCustomLogMessage(MessageContext synCtx) {
+ StringBuffer sb = new StringBuffer();
+ setCustomProperties(sb, synCtx);
+ return sb.toString();
+ }
+
+ private String getSimpleLogMessage(MessageContext synCtx) {
+ StringBuffer sb = new StringBuffer();
+ if (synCtx.getTo() != null)
+ sb.append("To: " + synCtx.getTo().getAddress());
+ else
+ sb.append("To: ");
+ if (synCtx.getFrom() != null)
+ sb.append(SEP + "From: " + synCtx.getFrom().getAddress());
+ if (synCtx.getWSAAction() != null)
+ sb.append(SEP + "WSAction: " + synCtx.getWSAAction());
+ if (synCtx.getSoapAction() != null)
+ sb.append(SEP + "SOAPAction: " + synCtx.getSoapAction());
+ if (synCtx.getReplyTo() != null)
+ sb.append(SEP + "ReplyTo: " + synCtx.getReplyTo().getAddress());
+ if (synCtx.getMessageID() != null)
+ sb.append(SEP + "MessageID: " + synCtx.getMessageID());
+ setCustomProperties(sb, synCtx);
+ return sb.toString();
+ }
+
+ private String getHeadersLogMessage(MessageContext synCtx) {
+ StringBuffer sb = new StringBuffer();
+ Iterator iter = synCtx.getEnvelope().getHeader().examineAllHeaderBlocks();
+ while (iter.hasNext()) {
+ SOAPHeader header = (SOAPHeader) iter.next();
+ sb.append(SEP + header.getLocalName() + " : " + header.getText());
+ }
+ setCustomProperties(sb, synCtx);
+ return sb.toString();
+ }
+
+ private String getFullLogMessage(MessageContext synCtx) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getSimpleLogMessage(synCtx));
+ if (synCtx.getEnvelope() != null)
+ sb.append(SEP + "Envelope: " + synCtx.getEnvelope());
+ setCustomProperties(sb, synCtx);
+ return sb.toString();
+ }
+
+ private void setCustomProperties(StringBuffer sb, MessageContext 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(synCtx)));
+ }
+ }
+ }
+
+ public int getLogLevel() {
+ return logLevel;
+ }
+
+ public void setLogLevel(int logLevel) {
+ this.logLevel = logLevel;
+ }
+
+ public String getSeperator() {
+ return SEP;
+ }
+
+ public void setSeperator(String SEP) {
+ this.SEP = SEP;
+ }
+
+ public void addProperty(MediatorProperty p) {
+ properties.add(p);
+ }
+
+ public void addAllProperties(List list) {
+ properties.addAll(list);
+ }
+
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/PropertyMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,74 @@
+/*
+* 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.MessageContext;
+import org.apache.synapse.Util;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * 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;
+
+ private static final Log log = LogFactory.getLog(PropertyMediator.class);
+
+ /**
+ * Sets a property into the current (local) Synapse Context
+ * @param smc the message context
+ * @return true always
+ */
+ public boolean mediate(MessageContext smc) {
+ log.debug("Set-Property mediator :: mediate()");
+ String value = (getValue() != null ? getValue() : Util.getStringValue(getExpression(), smc));
+ log.debug("Setting property : " + getName() + " = " + value);
+ smc.setProperty(getName(), value);
+ 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;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,109 @@
+/*
+ * 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.MessageContext;
+import org.apache.synapse.config.Endpoint;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.addressing.EndpointReference;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The Send mediator sends the message using the following semantics.
+ * <p/>
+ * This is a leaf mediator (i.e. further processing halts after this mediator completes)
+ * <p/>
+ * TODO support loadbalancing and failover
+ */
+public class SendMediator extends AbstractMediator {
+
+ private static final Log log = LogFactory.getLog(SendMediator.class);
+
+ /** The list of endpoints to which the message should be sent to. If none
+ * are specified, the message is sent where its implicitly stated in the
+ * current message */
+ private List endpoints = new ArrayList();
+
+ /**
+ * This is a leaf mediator. i.e. processing stops once send is invoked,
+ * as it always returns false
+ *
+ * @param synCtx the current message to be sent
+ * @return false always as this is a leaf mediator
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Send mediator :: mediate()");
+
+ // TODO this may be really strange but true.. unless you call the below, sometimes it
+ // results in an unbound URI exception for no credible reason - needs more investigation
+ // seems like a woodstox issue. Use hack for now
+ synCtx.getEnvelope().build();
+
+ // if no endpoints are defined, send where implicitly stated
+ if (endpoints.isEmpty()) {
+ log.debug("Sending message using implicit message properties..");
+ log.debug("Sending To: " + (synCtx.getTo() != null ?
+ synCtx.getTo().getAddress() : "null"));
+ log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
+ synCtx.getWSAAction() : "null"));
+ log.debug("Body : \n" + synCtx.getEnvelope());
+ synCtx.getEnvironment().send(synCtx);
+
+ } else if (endpoints.size() == 1) {
+ Endpoint singleEndpoint = (Endpoint) endpoints.get(0);
+ String eprAddress = null;
+ if (singleEndpoint.getAddress() != null) {
+ eprAddress = singleEndpoint.getAddress().toString();
+ } else {
+ singleEndpoint = synCtx.getConfiguration().getNamedEndpoint(
+ singleEndpoint.getRef());
+ eprAddress = singleEndpoint.getAddress().toString();
+ }
+
+ log.debug("Sending message to endpoint :: name = " +
+ singleEndpoint.getName() + " resolved address = " + eprAddress);
+
+ synCtx.setTo(new EndpointReference(eprAddress));
+ log.debug("Sending To: " + (synCtx.getTo() != null ?
+ synCtx.getTo().getAddress() : "null"));
+ log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
+ synCtx.getWSAAction() : "null"));
+ log.debug("Body : \n" + synCtx.getEnvelope());
+
+ synCtx.getEnvironment().send(synCtx);
+
+ } else {
+ String msg = "The send mediator currently supports only one endpoint";
+ log.error(msg);
+ throw new UnsupportedOperationException(msg);
+ }
+ return false;
+ }
+
+ /**
+ * Add the given Endpoint as an endpoint for this Send mediator instance
+ * @param e the Endpoint to be added
+ * @return true if the endpoint list was updated
+ */
+ public boolean addEndpoint(Endpoint e) {
+ return endpoints.add(e);
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,114 @@
+/*
+ * 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.ext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.MediatorProperty;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.lang.reflect.Method;
+
+/**
+ * The class mediator delegates the mediation to a new instance of a specified class. The specified class
+ * must implement the Mediator interface
+ *
+ * @see Mediator
+ */
+public class ClassMediator extends AbstractMediator {
+
+ private static final Log log = LogFactory.getLog(ClassMediator.class);
+
+ private Class clazz = null;
+ private List properties = new ArrayList();
+
+ /**
+ * Delegate mediation to a new instance of the specified class
+ * @param synCtx the message context
+ * @return as per standard semantics
+ */
+ public boolean mediate(MessageContext synCtx) {
+
+ log.debug("Class mediator <" + clazz.getName() + ">:: mediate()");
+ Mediator m = null;
+ try {
+ m = (Mediator) clazz.newInstance();
+
+ } catch (Exception e) {
+ String msg = "Error while creating an instance of the specified mediator class : " + clazz.getName();
+ log.error(msg, e);
+ throw new SynapseException(msg, e);
+ }
+
+ setProperties(m, synCtx);
+
+ return m.mediate(synCtx);
+ }
+
+ /**
+ * Only String properties are supported
+ * @param m the mediator
+ */
+ private void setProperties(Mediator m, MessageContext synCtx) {
+
+ Iterator iter = properties.iterator();
+ while (iter.hasNext()) {
+
+ MediatorProperty mProp = (MediatorProperty) iter.next();
+
+ String mName = "set" + Character.toUpperCase(mProp.getName().charAt(0)) + mProp.getName().substring(1);
+ String value = (mProp.getValue() != null ?
+ mProp.getValue() :
+ Util.getStringValue(mProp.getExpression(), synCtx));
+
+ try {
+ Method method = m.getClass().getMethod(mName, new Class[] {String.class});
+ log.debug("Setting property :: invoking method " + mName + "(" + value + ")");
+ method.invoke(m, new Object[] { value });
+
+ } catch (Exception e) {
+ String msg = "Error setting property : " + mProp.getName() + " as a String property into class" +
+ " mediator : " + m.getClass() + " : " + e.getMessage();
+ log.error(msg);
+ throw new SynapseException(msg, e);
+ }
+ }
+ }
+
+ public void setClazz(Class clazz) {
+ this.clazz = clazz;
+ }
+
+ public Class getClazz() {
+ return clazz;
+ }
+
+ public void addProperty(MediatorProperty p) {
+ properties.add(p);
+ }
+
+ public void addAllProperties(List list) {
+ properties.addAll(list);
+ }
+
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.axiom.om.xpath.AXIOMXPath;
+import org.apache.synapse.Util;
+import org.apache.synapse.MessageContext;
+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;
+
+/**
+ * The filter mediator combines the regex and xpath filtering functionality. If an xpath
+ * is set, it is evaluated; else the given regex is evaluated against the source xpath.
+ */
+public class FilterMediator extends AbstractListMediator implements org.apache.synapse.api.FilterMediator {
+
+ private static final Log log = LogFactory.getLog(FilterMediator.class);
+ private AXIOMXPath source = null;
+ private Pattern regex = null;
+ private AXIOMXPath xpath = null;
+
+ /**
+ * Executes the list of sub/child mediators, if the filter condition is satisfied
+ * @param synCtx the current message
+ * @return true if filter condition fails. else returns as per List mediator semantics
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Filter mediator mediate()");
+ if (test(synCtx)) {
+ log.debug("Filter condition satisfied.. executing child mediators");
+ return super.mediate(synCtx);
+ } else {
+ log.debug("Filter condition failed.. will skip executing child mediators");
+ return true;
+ }
+ }
+
+ /**
+ * Tests the supplied condition after evaluation against the given XPath
+ * 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 synCtx the current message for evaluation of the test condition
+ * @return true if evaluation of the XPath/Regex results in true
+ */
+ public boolean test(MessageContext synCtx) {
+ try {
+ if (xpath != null) {
+ log.debug("Evaluating XPath expression : " + xpath);
+ return xpath.booleanValueOf(synCtx.getEnvelope());
+
+ } else if (source != null && regex != null) {
+ log.debug("Evaluating regular expression : " + regex + " against source : " + source);
+ return regex.matcher(Util.getStringValue(source, synCtx)).matches();
+
+ } else {
+ log.error("Invalid configuration specified");
+ return false;
+ }
+
+ } catch (JaxenException e) {
+ log.error("XPath error : " + e.getMessage());
+ return false;
+ }
+ }
+
+
+ public AXIOMXPath getSource() {
+ return source;
+ }
+
+ public void setSource(AXIOMXPath source) {
+ this.source = source;
+ }
+
+ public Pattern getRegex() {
+ return regex;
+ }
+
+ public void setRegex(Pattern regex) {
+ this.regex = regex;
+ }
+
+ public AXIOMXPath getXpath() {
+ return xpath;
+ }
+
+ public void setXpath(AXIOMXPath xpath) {
+ this.xpath = xpath;
+ }
+
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,59 @@
+/*
+* 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.AbstractListMediator;
+
+/**
+ * The In Mediator acts only on "incoming" messages into synapse. This is
+ * performed by looking at the result of MessageContext#isResponse()
+ *
+ * @see org.apache.synapse.MessageContext#isResponse()
+ */
+public class InMediator extends AbstractListMediator implements org.apache.synapse.api.FilterMediator {
+
+ private static final Log log = LogFactory.getLog(InMediator.class);
+
+ /**
+ * Executes the list of sub/child mediators, if the filter condition is satisfied
+ *
+ * @param synCtx the current message
+ * @return true if filter condition fails. else returns as per List mediator semantics
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("In mediator mediate()");
+ if (test(synCtx)) {
+ log.debug("Current message is incoming.. executing child mediators");
+ return super.mediate(synCtx);
+ } else {
+ log.debug("Current message is not incoming.. skip executing child mediators");
+ return true;
+ }
+ }
+
+ /**
+ * Apply mediation only on request messages
+ *
+ * @param synCtx the message context
+ * @return MessageContext#isResponse()
+ */
+ public boolean test(MessageContext synCtx) {
+ return !synCtx.isResponse();
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,59 @@
+/*
+* 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.AbstractListMediator;
+
+/**
+ * The Out Mediator acts only on "outgoing" messages from synapse. This is
+ * performed by looking at the result of MessageContext#isResponse()
+ *
+ * @see org.apache.synapse.MessageContext#isResponse()
+ */
+public class OutMediator extends AbstractListMediator implements org.apache.synapse.api.FilterMediator {
+
+ private static final Log log = LogFactory.getLog(OutMediator.class);
+
+ /**
+ * Executes the list of sub/child mediators, if the filter condition is satisfied
+ *
+ * @param synCtx the current message
+ * @return true if filter condition fails. else returns as per List mediator semantics
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Out mediator mediate()");
+ if (test(synCtx)) {
+ log.debug("Current message is outgoing.. executing child mediators");
+ return super.mediate(synCtx);
+ } else {
+ log.debug("Current message is not outgoing.. executing child mediators");
+ return true;
+ }
+ }
+
+ /**
+ * Apply mediation only on response messages
+ *
+ * @param synCtx the message context
+ * @return MessageContext#isResponse()
+ */
+ public boolean test(MessageContext synCtx) {
+ return synCtx.isResponse();
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,71 @@
+/*
+* 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.regex.Pattern;
+import java.util.List;
+
+/**
+ * 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 static final Log log = LogFactory.getLog(SwitchCaseMediator.class);
+
+ /** The regular expression pattern to be used */
+ private Pattern regex = null;
+ /** Is this the default case? */
+ private boolean defaultCase = false;
+
+ public SwitchCaseMediator() {}
+
+ public SwitchCaseMediator(Pattern regex, boolean defaultCase, List children) {
+ this.regex = regex;
+ this.defaultCase = defaultCase;
+ this.addAll(children);
+ }
+
+ 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) {
+ if (isDefaultCase()) {
+ log.debug("This is the default case of the switch");
+ return true;
+ }
+ boolean retVal = regex.matcher(value).matches();
+ log.debug("Case : " + regex + " evaluated to : " + retVal);
+ return retVal;
+ }
+}
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,97 @@
+/*
+* 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.MessageContext;
+import org.apache.synapse.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+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);
+
+ /** The XPath expression specifying the source element to apply the switch case expressions against */
+ private AXIOMXPath source = null;
+ /** The list of switch cases */
+ private List cases = new ArrayList();
+ /** The default switch case, if any */
+ 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(MessageContext synCtx) {
+
+ log.debug("Switch mediator :: mediate()");
+ String sourceText = Util.getStringValue(source, synCtx);
+ log.debug("Applying switch case regex patterns against evaluated source value : " + sourceText);
+ Iterator iter = cases.iterator();
+
+ while (iter.hasNext()) {
+ SwitchCaseMediator swCase = (SwitchCaseMediator) iter.next();
+ if (swCase.matches(sourceText)) {
+ return swCase.mediate(synCtx);
+ }
+ }
+
+ if (defaultCase != null) {
+ log.debug("Executing default switch case");
+ 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);
+ }
+
+ /**
+ * Return the source XPath expression set
+ * @return thje source XPath expression
+ */
+ public AXIOMXPath getSource() {
+ return source;
+ }
+
+ /**
+ * Sets the source XPath expression
+ * @param source the XPath expression to be used as the source
+ */
+ public void setSource(AXIOMXPath source) {
+ this.source = source;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,303 @@
+/*
+ * 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.transform;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.axiom.soap.*;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.Util;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.jaxen.JaxenException;
+
+import javax.xml.namespace.QName;
+import java.net.URI;
+
+/**
+ * This transforms the current message instance into a SOAP Fault message. The
+ * SOAP version for the fault message could be explicitly specified. Else if the
+ * original message was SOAP 1.1 the fault will also be SOAP 1.1 else, SOAP 1.2
+ *
+ * This class exposes methods to set SOAP 1.1 and 1.2 fault elements and uses
+ * these as required.
+ */
+public class FaultMediator extends AbstractMediator {
+
+ private static final Log log = LogFactory.getLog(FaultMediator.class);
+
+ /** Make a SOAP 1.1 fault */
+ public static final int SOAP11 = 1;
+ /** Make a SOAP 1.2 fault */
+ public static final int SOAP12 = 2;
+ /** Holds the SOAP version to be used to make the fault, if specified */
+ private int soapVersion;
+
+ // -- fault elements --
+ /** The fault code QName to be used */
+ private QName faultCodeValue = null;
+ /** An XPath expression that will give the fault code QName at runtime */
+ private AXIOMXPath faultCodeExpr = null;
+ /** The fault reason to be used */
+ private String faultReasonValue = null;
+ /** An XPath expression that will give the fault reason string at runtime */
+ private AXIOMXPath faultReasonExpr = null;
+ /** The fault node URI to be used */
+ private URI faultNode = null;
+ /** The fault role URI to be used - if applicable */
+ private URI faultRole = null;
+ /** The fault detail to be used */
+ private String faultDetail = null;
+
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Fault mediator mediate()");
+ SOAPEnvelope envelop = synCtx.getEnvelope();
+
+ switch (soapVersion) {
+ case SOAP11:
+ return makeSOAPFault(synCtx, SOAP11);
+ case SOAP12:
+ return makeSOAPFault(synCtx, SOAP12);
+ default : {
+ if (envelop != null) {
+ if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelop.getNamespace().getName())) {
+ return makeSOAPFault(synCtx, SOAP12);
+ } else {
+ return makeSOAPFault(synCtx, SOAP11);
+ }
+ } else {
+ return makeSOAPFault(synCtx, SOAP11);
+ }
+ }
+ }
+ }
+
+ private boolean makeSOAPFault(MessageContext synCtx, int soapVersion) {
+
+ log.debug("Creating a SOAP fault using SOAP " + (soapVersion == SOAP11 ? "1.1" : "1.2"));
+ // get the correct SOAP factory to be used
+ SOAPFactory factory = (
+ soapVersion == SOAP11 ? OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory());
+
+ // create the SOAP fault document and envelope
+ OMDocument soapFaultDocument = factory.createOMDocument();
+ SOAPEnvelope faultEnvelope = factory.getDefaultFaultEnvelope();
+ soapFaultDocument.addChild(faultEnvelope);
+
+ // create the fault element
+ SOAPFault fault = factory.createSOAPFault();
+
+ // populate it
+ setFaultCode(synCtx, factory, fault);
+ setFaultResaon(synCtx, factory, fault);
+ setFaultNode(factory, fault);
+ setFaultRole(factory, fault);
+ setFaultDetail(factory, fault);
+
+ // set the fault element
+ faultEnvelope.getBody().setFirstChild(fault);
+ log.debug("Setting the fault message as : " + fault);
+
+ // set the fault message "to" header to the "faultTo" of the original message if
+ // such a header existed on the original message, else set it to the "replyTo" of the original
+
+ EndpointReference toEPR = synCtx.getTo();
+ EndpointReference faultToEPR = synCtx.getFaultTo();
+ if (faultToEPR != null) {
+ log.debug("Setting fault message To : " + faultToEPR);
+ log.debug("Setting fault message ReplyTo : " + toEPR);
+ synCtx.setTo(faultToEPR);
+ synCtx.setReplyTo(toEPR);
+ } else {
+ EndpointReference replyToEPR = synCtx.getReplyTo();
+ log.debug("Setting fault message To : " + replyToEPR);
+ log.debug("Setting fault message ReplyTo : " + toEPR);
+ synCtx.setTo(replyToEPR);
+ synCtx.setReplyTo(toEPR);
+ }
+ synCtx.setResponse(true);
+
+ // overwrite current message envelope with new fault envelope
+ try {
+ synCtx.setEnvelope(faultEnvelope);
+ } catch (AxisFault af) {
+ String msg = "Error replacing SOAP envelope with a fault envelope " + af.getMessage();
+ log.error(msg);
+ throw new SynapseException(af);
+ }
+
+ return true;
+ }
+
+ private void setFaultCode(MessageContext synCtx, SOAPFactory factory, SOAPFault fault) {
+
+ QName fault_code = null;
+
+ if (faultCodeValue == null && faultCodeExpr == null) {
+ handleException("A valid fault code QName value or expression is required");
+ } else if (faultCodeValue != null) {
+ fault_code = faultCodeValue;
+ } else {
+ fault_code = QName.valueOf(Util.getStringValue(faultCodeExpr, synCtx));
+ }
+
+ SOAPFaultCode code = factory.createSOAPFaultCode();
+ SOAPFaultValue value = factory.createSOAPFaultValue(code);
+ value.setText(fault_code);
+ fault.setCode(code);
+ }
+
+ private void setFaultResaon(MessageContext synCtx, SOAPFactory factory, SOAPFault fault) {
+ String reasonString = null;
+
+ if (faultReasonValue == null && faultReasonExpr == null) {
+ handleException("A valid fault reason value or expression is required");
+ } else if (faultReasonValue != null) {
+ reasonString = faultReasonValue;
+ } else {
+ reasonString = Util.getStringValue(faultReasonExpr, synCtx);
+ }
+
+ SOAPFaultReason reason = factory.createSOAPFaultReason();
+ SOAPFaultText text = factory.createSOAPFaultText();
+ text.setText(reasonString);
+ reason.addSOAPText(text);
+ fault.setReason(reason);
+ }
+
+ private void setFaultNode(SOAPFactory factory, SOAPFault fault) {
+ if (faultNode != null) {
+ SOAPFaultNode faultNode = factory.createSOAPFaultNode();
+ faultNode.setNodeValue(faultNode.toString());
+ fault.setNode(faultNode);
+ }
+ }
+
+ private void setFaultRole(SOAPFactory factory, SOAPFault fault) {
+ if (faultRole != null) {
+ SOAPFaultRole soapFaultRole = factory.createSOAPFaultRole();
+ soapFaultRole.setRoleValue(faultRole.toString());
+ fault.setRole(soapFaultRole);
+ }
+ }
+
+ private void setFaultDetail(SOAPFactory factory, SOAPFault fault) {
+ if (faultDetail != null) {
+ SOAPFaultDetail soapFaultDetail = factory.createSOAPFaultDetail();
+ soapFaultDetail.setText(faultDetail);
+ fault.setDetail(soapFaultDetail);
+ }
+ }
+
+ private void handleException(String msg) {
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ public int getSoapVersion() {
+ return soapVersion;
+ }
+
+ public void setSoapVersion(int soapVersion) {
+ this.soapVersion = soapVersion;
+ }
+
+ public QName getFaultCodeValue() {
+ return faultCodeValue;
+ }
+
+ public void setFaultCodeValue(QName faultCodeValue) {
+
+ if (soapVersion == SOAP11) {
+ this.faultCodeValue = faultCodeValue;
+
+ } else {
+ if (
+ SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(faultCodeValue.getNamespaceURI()) &&
+
+ (SOAP12Constants.FAULT_CODE_DATA_ENCODING_UNKNOWN.equals(faultCodeValue.getLocalPart()) ||
+ SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND.equals(faultCodeValue.getLocalPart()) ||
+ SOAP12Constants.FAULT_CODE_RECEIVER.equals(faultCodeValue.getLocalPart()) ||
+ SOAP12Constants.FAULT_CODE_SENDER.equals(faultCodeValue.getLocalPart()) ||
+ SOAP12Constants.FAULT_CODE_VERSION_MISMATCH.equals(faultCodeValue.getLocalPart())) ){
+
+ this.faultCodeValue = faultCodeValue;
+
+ } else {
+ String msg = "Invalid Fault code value for a SOAP 1.2 fault : " + faultCodeValue;
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+ }
+ }
+
+ public AXIOMXPath getFaultCodeExpr() {
+ return faultCodeExpr;
+ }
+
+ public void setFaultCodeExpr(AXIOMXPath faultCodeExpr) {
+ this.faultCodeExpr = faultCodeExpr;
+ }
+
+ public String getFaultReasonValue() {
+ return faultReasonValue;
+ }
+
+ public void setFaultReasonValue(String faultReasonValue) {
+ this.faultReasonValue = faultReasonValue;
+ }
+
+ public AXIOMXPath getFaultReasonExpr() {
+ return faultReasonExpr;
+ }
+
+ public void setFaultReasonExpr(AXIOMXPath faultReasonExpr) {
+ this.faultReasonExpr = faultReasonExpr;
+ }
+
+ public URI getFaultNode() {
+ return faultNode;
+ }
+
+ public void setFaultNode(URI faultNode) {
+ if (soapVersion == SOAP11) {
+ handleException("A fault node does not apply to a SOAP 1.1 fault");
+ }
+ this.faultNode = faultNode;
+ }
+
+ public URI getFaultRole() {
+ return faultRole;
+ }
+
+ public void setFaultRole(URI faultRole) {
+ this.faultRole = faultRole;
+ }
+
+ public String getFaultDetail() {
+ return faultDetail;
+ }
+
+ public void setFaultDetail(String faultDetail) {
+ this.faultDetail = faultDetail;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,107 @@
+/*
+* 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.transform;
+
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.HeaderType;
+import org.apache.synapse.Util;
+import org.apache.synapse.MessageContext;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The header mediator is able to set a given value as a SOAP header, or remove a given
+ * header from the current message instance. This supports the headers currently
+ * supported by the HeaderType class. If an expression is supplied, its runtime value
+ * is evaluated using the current message. Unless the action is set to remove, the
+ * default behaviour of this mediator is to set a header value.
+ *
+ * @see HeaderType
+ */
+public class HeaderMediator extends AbstractMediator {
+
+ private static final Log log = LogFactory.getLog(HeaderMediator.class);
+
+ public static final int ACTION_SET = 0;
+ public static final int ACTION_REMOVE = 1;
+
+ /** The name of the header @see HeaderType */
+ private String name = null;
+ /** The literal value to be set as the header (if one was specified) */
+ private String value = null;
+ /** Set the header (ACTION_SET) or remove it (ACTION_REMOVE). Defaults to ACTION_SET */
+ private int action = ACTION_SET;
+ /** An expression which should be evaluated, and the result set as the header value */
+ private AXIOMXPath expression = null;
+ /** The header type to which this mediator applies to */
+ private HeaderType headerType = new HeaderType();
+
+ /**
+ * Sets/Removes a SOAP header on the current message
+ *
+ * @param synCtx the current message which is altered as necessary
+ * @return true always
+ */
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Header mediator <" + (action == ACTION_SET ? "Set" : "Remove") + "> :: mediate()");
+
+ if (action == ACTION_SET) {
+ String value = (getValue() != null ? getValue() :
+ Util.getStringValue(getExpression(), synCtx));
+ log.debug("Setting header : " + headerType.getHeaderType() + " to : " + value);
+ headerType.setHeader(synCtx, value);
+
+ } else {
+ log.debug("Removing header : " + headerType.getHeaderType() + " from current message");
+ headerType.removeHeader(synCtx);
+ }
+ return true;
+ }
+
+ public int getAction() {
+ return action;
+ }
+
+ public void setAction(int action) {
+ this.action = action;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ this.headerType.setHeaderType(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;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/axis2.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/axis2.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/axis2.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/axis2.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,150 @@
+<axisconfig name="AxisJava2.0_Provider_Endpint">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">true</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">true</parameter>
+ <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="enableREST" locked="false">true</parameter>-->
+
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">http://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6061</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/synapse.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/synapse.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/synapse.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/axis2/conf/synapse.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,18 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+ <stage name="logall">
+ <engage-addressing-in/>
+ <log/>
+ </stage>
+ <stage name="service-specific" >
+ <regex message-address="to" pattern="http://xmethods.*">
+ <header type="to" value="http://64.124.140.30:9090/soap"/>
+ <xpath expr="//*[Symbol='MSFT']">
+ <fault/>
+ </xpath>
+ </regex>
+ </stage>
+ <stage name="sender">
+ <send/>
+ </stage>
+</synapse>
+
Added: incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/emptymediator/META-INF/services.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/emptymediator/META-INF/services.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/emptymediator/META-INF/services.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/emptymediator/META-INF/services.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,6 @@
+<service name="emptymediator">
+ <operation name="mediate" >
+ <messageReceiver class="org.apache.synapse.core.axis2.EmptyMessageReceiver" />
+ </operation>
+</service>
+
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/synapse/META-INF/services.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/synapse/META-INF/services.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/synapse/META-INF/services.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/axis2/services/synapse/META-INF/services.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,8 @@
+ <service name="synapse">
+
+ <operation name="mediate" >
+ <messageReceiver class="org.apache.synapse.core.axis2.SynapseMessageReceiver" />
+ </operation>
+
+ </service>
+
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/misc/transform.xslt
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/misc/transform.xslt?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/misc/transform.xslt (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/misc/transform.xslt Thu Jun 1 02:28:13 2006
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
+ xmlns:m0="http://www.apache-synapse.org/test"
+ exclude-result-prefixes="m0 fn">
+<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
+
+<xsl:template match="/">
+ <xsl:apply-templates select="//m0:CheckPriceRequest" />
+</xsl:template>
+
+<xsl:template match="m0:CheckPriceRequest">
+
+<m:GetQuote xmlns:m="http://www.webserviceX.NET/">
+ <m:symbol><xsl:value-of select="m0:Code"/></m:symbol>
+</m:GetQuote>
+
+</xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/misc/validate.xsd
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/misc/validate.xsd?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/misc/validate.xsd (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/misc/validate.xsd Thu Jun 1 02:28:13 2006
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.apache-synapse.org/test" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.apache-synapse.org/test">
+ <xs:element name="CheckPriceRequest">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Code" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/misc/validate2.xsd
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/misc/validate2.xsd?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/misc/validate2.xsd (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/misc/validate2.xsd Thu Jun 1 02:28:13 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m1="http://www.apache-synapse.org/test" xmlns:m2="http://www.apache-synapse.org/test2" targetNamespace="http://www.apache-synapse.org/test2" elementFormDefault="qualified" attributeFormDefault="unqualified">
+ <xs:import namespace="http://www.apache-synapse.org/test" schemaLocation="validate.xsd"/>
+
+ <xs:element name="CheckPriceRequest2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Code2" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="Outer">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="m1:CheckPriceRequest"/>
+ <xs:element ref="m2:CheckPriceRequest2"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org