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 2005/11/24 12:31:54 UTC

svn commit: r348713 [18/18] - in /incubator/synapse/trunk/scratch/prototype3: ./ .settings/ doc/ doc/index-files/ doc/org/ doc/org/apache/ doc/org/apache/synapse/ doc/org/apache/synapse/api/ doc/org/apache/synapse/api/class-use/ doc/org/apache/synapse/...

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/AddressingProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/AddressingProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/AddressingProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/AddressingProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,83 @@
+package org.apache.synapse.processors.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.OperationContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+
+import org.apache.synapse.axis2.Axis2SOAPMessageContext;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ * @author Paul Fremantle
+ *         <p>
+ *         This class turns on the addressing module and then calls an empty
+ *         service There's probably a better way but this should work!
+ * 
+ */
+public class AddressingProcessor extends AbstractProcessor {
+	private static final QName ADD_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+			"addressing");
+
+	private Log log = LogFactory.getLog(getClass());
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+		log.debug("process");
+		try {
+			MessageContext mc = ((Axis2SOAPMessageContext) smc)
+					.getMessageContext();
+			ConfigurationContext cc = mc.getSystemContext();
+			AxisConfiguration ac = cc.getAxisConfiguration();
+			AxisEngine ae = new AxisEngine(cc);
+			AxisService as = ac.getService(Constants.EMPTYMEDIATOR);
+			if (as == null)
+				throw new SynapseException("cannot locate service "
+						+ Constants.EMPTYMEDIATOR);
+			ac.engageModule(new QName(
+					org.apache.axis2.Constants.MODULE_ADDRESSING));
+			AxisOperation ao = as
+					.getOperation(Constants.MEDIATE_OPERATION_NAME);
+			OperationContext oc = OperationContextFactory
+					.createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+			ao.registerOperationContext(mc, oc);
+
+			ServiceContext sc = Utils.fillContextInformation(ao, as, cc);
+			oc.setParent(sc);
+
+			mc.setOperationContext(oc);
+			mc.setServiceContext(sc);
+
+			mc.setAxisOperation(ao);
+			mc.setAxisService(as);
+
+			ae.receive(mc);
+
+		} catch (AxisFault e) {
+			throw new SynapseException(e);
+		}
+		return true;
+	}
+
+	public QName getTagQName() {
+
+		return ADD_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/ClassMediatorProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/ClassMediatorProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/ClassMediatorProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/ClassMediatorProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,51 @@
+package org.apache.synapse.processors.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+import org.apache.synapse.processors.AbstractProcessor;
+
+public class ClassMediatorProcessor extends AbstractProcessor {
+	private static final QName CLM_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+			"classmediator");
+
+	private Class clazz = null;
+
+	public void compile(SynapseEnvironment se, OMElement el) {
+		super.compile(se, el);
+
+		OMAttribute clsName = el.getAttribute(new QName("class"));
+		if (clsName == null)
+			throw new SynapseException("missing class attribute on element"
+					+ el.toString());
+		try {
+			clazz = se.getClassLoader().loadClass(clsName.getAttributeValue());
+		} catch (ClassNotFoundException e) {
+			throw new SynapseException("class loading error", e);
+		}
+
+	}
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+		Mediator m = null;
+
+		try {
+			m = (Mediator) clazz.newInstance();
+		} catch (Exception e) {
+			throw new SynapseException(e);
+		}
+		return m.mediate(smc);
+
+	}
+
+	public QName getTagQName() {
+		return CLM_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/FaultProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/FaultProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/FaultProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/FaultProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,75 @@
+package org.apache.synapse.processors.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.om.OMAbstractFactory;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+import org.apache.synapse.axis2.Axis2SOAPMessageContext;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ * @author Paul Fremantle
+ *         <p>
+ *         <xmp><synapse:fault/> </xmp>
+ * 
+ * 
+ */
+public class FaultProcessor extends AbstractProcessor {
+	private static final QName HEADER_Q = new QName(
+			Constants.SYNAPSE_NAMESPACE, "fault");
+
+	private Log log = LogFactory.getLog(getClass());
+
+	
+	public void compile(SynapseEnvironment se, OMElement el) {
+		super.compile(se, el);
+	}
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+		log.debug("process");
+		try {
+
+			MessageContext messageContext = ((Axis2SOAPMessageContext) smc)
+					.getMessageContext();
+			MessageContext outMC = Utils
+					.createOutMessageContext(messageContext);
+			outMC.setConfigurationContext(messageContext.getSystemContext());
+			outMC.setServerSide(true);
+
+			outMC.setEnvelope(OMAbstractFactory.getSOAP11Factory()
+					.getDefaultFaultEnvelope());
+
+			AxisEngine ae = new AxisEngine(messageContext.getSystemContext());
+			Object os = messageContext
+					.getProperty(MessageContext.TRANSPORT_OUT);
+			outMC.setProperty(MessageContext.TRANSPORT_OUT, os);
+			Object ti = messageContext
+					.getProperty(HTTPConstants.HTTPOutTransportInfo);
+			outMC.setProperty(HTTPConstants.HTTPOutTransportInfo, ti);
+
+			ae.send(outMC);
+		} catch (AxisFault e) {
+			throw new SynapseException(e);
+		}
+		return false;
+	}
+
+	public QName getTagQName() {
+		return HEADER_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/HeaderProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/HeaderProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/HeaderProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/HeaderProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,109 @@
+package org.apache.synapse.processors.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ * @author Paul Fremantle
+ *         <p>
+ *         <xmp><synapse:header type="to|from|faultto|replyto|action"
+ *         value="newvalue"/> </xmp>
+ * 
+ * 
+ */
+public class HeaderProcessor extends AbstractProcessor {
+	private static final QName HEADER_Q = new QName(
+			Constants.SYNAPSE_NAMESPACE, "header");
+
+	private Log log = LogFactory.getLog(getClass());
+
+	private int headerType = 0;
+
+	private String value = null;
+
+	private static final QName TYPE_ATT_Q = new QName("type"),
+			VALUE_ATT_Q = new QName("value");
+
+	private final static int TO = 1, FROM = 2, FAULT = 3, ACTION = 4,
+			REPLYTO = 5;
+
+	private final static String STRTO = "to", STRFROM = "from",
+			STRFAULT = "faultto", STRACTION = "action", STRREPLYTO = "replyto";
+
+	public void compile(SynapseEnvironment se, OMElement el) {
+		super.compile(se, el);
+
+		OMAttribute val = el.getAttribute(VALUE_ATT_Q);
+		OMAttribute type = el.getAttribute(TYPE_ATT_Q);
+		if (val == null || type == null) {
+			throw new SynapseException("<header> must have both " + VALUE_ATT_Q
+					+ " and " + TYPE_ATT_Q + " attributes: " + el.toString());
+		}
+
+		String header = type.getAttributeValue();
+		if (header.equalsIgnoreCase(STRTO))
+			headerType = TO;
+		else if (header.equalsIgnoreCase(STRFROM))
+			headerType = FROM;
+		else if (header.equalsIgnoreCase(STRFAULT))
+			headerType = FAULT;
+		else if (header.equalsIgnoreCase(STRACTION))
+			headerType = ACTION;
+		else if (header.equalsIgnoreCase(STRREPLYTO))
+			headerType = REPLYTO;
+		else
+			throw new SynapseException(
+					"unknown header attribute value in <header>: " + header);
+		value = val.getAttributeValue();
+	}
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+
+		switch (headerType) {
+		case 0: {
+			log.debug("unknown header type");
+			return true;
+		}
+
+		case TO: {
+			log.debug("set to: " + value);
+			smc.setTo(new EndpointReference(value));
+			break;
+		}
+		case FROM: {
+			log.debug("set from: " + value);
+			smc.setFrom(new EndpointReference(value));
+			break;
+		}
+		case REPLYTO: {
+			log.debug("set replyto: " + value);
+			smc.setReplyTo(new EndpointReference(value));
+			break;
+		}
+		case ACTION: {
+			log.debug("set action: " + value);
+			smc.setWSAAction(value);
+			break;
+		}
+
+		}
+
+		return true;
+	}
+
+	public QName getTagQName() {
+		return HEADER_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/LogProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/LogProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/LogProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/LogProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,35 @@
+package org.apache.synapse.processors.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+public class LogProcessor extends AbstractProcessor {
+	private static final QName LOG_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+			"log");
+
+	private Log log = LogFactory.getLog(getClass());
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+		if (smc.getTo() != null)
+			log.info("To: " + smc.getTo().getAddress());
+		if (smc.getFrom() != null)
+			log.info("From: " + smc.getFrom().getAddress());
+		if (smc.getReplyTo() != null)
+			log.info("ReplyTo: " + smc.getReplyTo().getAddress());
+		if (smc.getEnvelope() != null)
+			log.info("Envelope: " + smc.getEnvelope().toString());
+		return true;
+	}
+
+	public QName getTagQName() {
+		return LOG_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/SendProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/SendProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/SendProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/mediators/SendProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,44 @@
+package org.apache.synapse.processors.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+import org.apache.synapse.processors.AbstractProcessor;
+import org.apache.synapse.Constants;
+
+public class SendProcessor extends AbstractProcessor {
+	
+
+	private static final QName SEND_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+			"send");
+
+	private Log log = LogFactory.getLog(getClass());
+
+	public void compile(SynapseEnvironment se, OMElement el) {
+		super.compile(se, el);
+		
+	}
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+		log.debug("process");
+		if (smc.isResponse()) {
+			log.debug("sendback");
+			se.sendBack(smc);
+		} else {
+			log.debug("sendon");
+			se.sendOn(smc);
+		}
+		return false;
+
+	}
+
+	public QName getTagQName() {
+
+		return SEND_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/RegexProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/RegexProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/RegexProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/RegexProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,137 @@
+package org.apache.synapse.processors.rules;
+
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+import org.apache.synapse.processors.AllProcessor;
+
+/**
+ * @author Paul Fremantle
+ * 
+ */
+public class RegexProcessor extends AllProcessor {
+	private static final String REGEX = "regex";
+
+	private static final QName REGEX_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+			REGEX);
+
+	private static final QName REGEX_PATTERN_ATT_Q = new QName("pattern");
+
+	private static final QName REGEX_PROPERTY_ATT_Q = new QName("property");
+
+	private static final QName REGEX_HEADER_ATT_Q = new QName("message-address");
+
+	private Pattern pattern = null;
+
+	private Log log = LogFactory.getLog(getClass());
+
+	private int headerType = 0;
+
+	private String property = null;
+
+	private final static int TO = 1, FROM = 2, FAULT = 3, ACTION = 4;
+
+	private final static String STRTO = "to", STRFROM = "from",
+			STRFAULT = "faultto", STRACTION = "action";
+
+	public void compile(SynapseEnvironment se, OMElement el) {
+		super.compile(se, el);
+		OMAttribute patt = el.getAttribute(REGEX_PATTERN_ATT_Q);
+		if (patt == null) {
+			throw new SynapseException(REGEX + " must have "
+					+ REGEX_PATTERN_ATT_Q + " attribute: " + el.toString());
+		}
+
+		OMAttribute prop = el.getAttribute(REGEX_PROPERTY_ATT_Q);
+		OMAttribute head = el.getAttribute(REGEX_HEADER_ATT_Q);
+		if (prop == null && head == null) {
+			throw new SynapseException(REGEX + " must have either "
+					+ REGEX_PROPERTY_ATT_Q + " or " + REGEX_HEADER_ATT_Q
+					+ " attributes: " + el.toString());
+		}
+		pattern = Pattern.compile(patt.getAttributeValue());
+		if (prop != null) {
+			property = prop.getAttributeValue();
+		} else {
+			String header = head.getAttributeValue();
+			if (header.equalsIgnoreCase(STRTO))
+				headerType = TO;
+			else if (header.equalsIgnoreCase(STRFROM))
+				headerType = FROM;
+			else if (header.equalsIgnoreCase(STRFAULT))
+				headerType = FAULT;
+			else if (header.equalsIgnoreCase(STRACTION))
+				headerType = ACTION;
+			else
+				throw new SynapseException(
+						"unknown header attribute value in regex: " + header);
+
+		}
+	}
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+
+		if (pattern == null) {
+			log.debug("trying to process with empty pattern");
+			return true;
+		}
+		String toMatch = null;
+		if (property != null) {
+			toMatch = smc.getProperty(property).toString();
+		} else {
+			// must be header type if we got here
+
+			switch (headerType) {
+			case 0: {
+				log.debug("trying to process with empty property and header");
+				return true;
+			}
+			case TO: {
+				if (smc.getTo() == null)
+					return true;
+				toMatch = smc.getTo().getAddress();
+				break;
+			}
+			case FROM: {
+				if (smc.getFrom() == null)
+					return true;
+				toMatch = smc.getFrom().getAddress();
+				break;
+			}
+			case FAULT: {
+				if (smc.getFaultTo() == null)
+					return true;
+				toMatch = smc.getFaultTo().getAddress();
+				break;
+			}
+			case ACTION: {
+				if (smc.getWSAAction() == null)
+					return true;
+				toMatch = smc.getWSAAction();
+				break;
+			}
+			}
+		}
+		if (pattern.matcher(toMatch).matches()) {
+			log.debug("Regex pattern " + pattern.toString() + " matched "
+					+ toMatch);
+			return super.process(se, smc);
+		}
+		return true;
+	}
+
+	public QName getTagQName() {
+		return REGEX_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/XPathProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/XPathProcessor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/XPathProcessor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/processors/rules/XPathProcessor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,85 @@
+package org.apache.synapse.processors.rules;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.om.xpath.AXIOMXPath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+import org.apache.synapse.processors.AllProcessor;
+import org.jaxen.JaxenException;
+
+/**
+ * @author Paul Fremantle
+ * 
+ * <p>
+ * This class executes a test and then processes all subsequent rules/mediations
+ * if the test is true
+ * 
+ */
+public class XPathProcessor extends AllProcessor {
+	private static final String XPATH = "xpath";
+
+	private static final QName XPATH_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+			"xpath");
+
+	private static final QName XPATH_EXPRESSION_ATT_Q = new QName("expr");
+
+	private Log log = LogFactory.getLog(getClass());
+
+	private AXIOMXPath xp = null;
+
+	public void compile(SynapseEnvironment se, OMElement el) {
+		super.compile(se, el);
+		OMAttribute xpath = el.getAttribute(XPATH_EXPRESSION_ATT_Q);
+		if (xpath == null) {
+			throw new SynapseException(XPATH + " must have "
+					+ XPATH_EXPRESSION_ATT_Q + " attribute: " + el.toString());
+		}
+
+		try {
+			xp = new AXIOMXPath(xpath.getAttributeValue());
+			Iterator it = el.getAllDeclaredNamespaces();
+			while (it.hasNext()) {
+				OMNamespace n = (OMNamespace) it.next();
+				xp.addNamespace(n.getPrefix(), n.getName());
+			}
+		} catch (JaxenException e) {
+			throw new SynapseException("Problem with xpath expression "
+					+ xpath.getAttributeValue(), e);
+		}
+	}
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc) {
+		if (xp == null) {
+			log.debug("trying to process xpath without being set");
+			return true;
+		}
+		try {
+			if (xp.booleanValueOf(smc.getEnvelope())) {
+				log.debug("matched xpath: " + xp.toString());
+				// now do "all"
+				return super.process(se, smc);
+			}
+
+		} catch (JaxenException je) {
+			throw new SynapseException("Problem evaluating " + xp.toString(),
+					je);
+		}
+		return true;
+	}
+
+	public QName getTagQName() {
+
+		return XPATH_Q;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/MediatorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/MediatorConfigurator.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/MediatorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/MediatorConfigurator.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,24 @@
+/*
+ * 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.spi;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.api.MediatorConfiguration;
+
+public interface MediatorConfigurator {
+	public MediatorConfiguration parse(OMElement el, ClassLoader cl);
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/Processor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/Processor.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/Processor.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/spi/Processor.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,29 @@
+package org.apache.synapse.spi;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+
+/**
+ * @author Paul Fremantle This interface implements the core of Synapse. The
+ *         processor is bootstrapped from a piece of config XML (the el
+ *         OMElement).
+ * 
+ * The processor then deals with a message. It returns false if no further
+ * processing is desired It can have a name (or null)
+ * 
+ * Processors can either devolve processing to other processors (e.g. a rule,
+ * stage, etc) or deal with the message itself (e.g. mediator)
+ * 
+ */
+public interface Processor {
+	public void compile(SynapseEnvironment se, OMElement el);
+
+	public boolean process(SynapseEnvironment se, SOAPMessageContext smc);
+
+	public String getName();
+
+	public QName getTagQName();
+}

Added: incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/Logger.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/Logger.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/Logger.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/Logger.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,52 @@
+/*
+ * 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 sampleMediators;
+
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.SOAPMessageContext;
+
+/**
+ * @author Ant Elder
+ * @author Paul Fremantle
+ * <p>A sample Mediator that logs the message
+ * 
+ */
+public class Logger implements Mediator {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.synapse.mediator.Mediator#mediate(org.apache.axis2.context.MessageContext)
+	 */
+	public boolean mediate(SOAPMessageContext mc) {
+		System.out.println("Logger.mediate:");
+		if (mc.getTo() != null && mc.getTo().getAddress() != null)
+			System.out.println("Logger.mediate to:" + mc.getTo().getAddress());
+		else
+			System.out.println("Empty To");
+		if (mc.getReplyTo() != null && mc.getReplyTo().getAddress() != null)
+			System.out.println("Logger.mediate ReplyTo:"
+					+ mc.getReplyTo().getAddress());
+		else
+			System.out.println("Empty ReplyTo");
+		SOAPEnvelope env = mc.getEnvelope();
+		System.out.println(env.toString());
+		System.out.println();
+		return true;
+	}
+
+}
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SpringRedirect.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SpringRedirect.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SpringRedirect.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SpringRedirect.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,36 @@
+/*
+ * 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 sampleMediators;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.SOAPMessageContext;
+
+public class SpringRedirect implements Mediator {
+	private String uri = null;
+
+	public void setUri(String uri) {
+		this.uri = uri;
+	}
+
+	public boolean mediate(SOAPMessageContext mc) {
+
+		System.out.println("Redirect.mediate: " + uri);
+
+		mc.setTo(new EndpointReference(uri));
+		return true;
+	}
+}
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/engine/SynapseEngineRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/engine/SynapseEngineRuleTest.java?rev=348713&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/engine/SynapseEngineRuleTest.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/engine/SynapseEngineRuleTest.java Thu Nov 24 03:30:06 2005
@@ -0,0 +1,86 @@
+package org.apache.synapse.spi.engine;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMDocument;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.axis2.SynapseMessageReceiver;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+
+import junit.framework.TestCase;
+
+/*
+ * 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.
+ *
+ */
+
+public class SynapseEngineRuleTest extends TestCase {
+	private MessageContext msgCtx;
+
+	private ConfigurationContext configCtx;
+
+	public void setUp() throws Exception {
+		ConfigurationContextFactory conFac = new ConfigurationContextFactory();
+		File path = new File("./repo");
+		configCtx = conFac.buildClientConfigurationContext(path
+				.getAbsolutePath());
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		SOAPEnvelope dumEnv = OMAbstractFactory.getSOAP11Factory()
+				.getDefaultEnvelope();
+		OMDocument doc = fac.createOMDocument();
+		doc.addChild(dumEnv);
+
+		OMElement ele = fac.createOMElement("text", "urn:text-body", "t");
+		dumEnv.getBody().addChild(ele);
+
+		msgCtx = new MessageContext(configCtx);
+		msgCtx.setEnvelope(dumEnv);
+		msgCtx.setServerSide(true);
+
+		// ------------------
+		AxisConfiguration axisConfiguration = msgCtx.getSystemContext()
+				.getAxisConfiguration();
+		AxisService service = new AxisService(new QName("se"));
+		msgCtx.setAxisService(service);
+		service.setClassLoader(axisConfiguration.getServiceClassLoader());
+		AxisOperation axisOp = new InOutAxisOperation(new QName("op"));
+		msgCtx.setAxisOperation(axisOp);
+		axisOp.setMessageReceiver(new SynapseMessageReceiver());
+		service.addOperation(axisOp);
+		axisConfiguration.addService(service);
+
+		msgCtx.setTo(new EndpointReference("/axis2/services/" + "se" + "/"
+				+ "op"));
+		msgCtx.setSoapAction("op");
+
+	}
+
+	public void testAllAndXpath() throws Exception {
+		AxisEngine engine = new AxisEngine(configCtx);
+		engine.receive(msgCtx);
+	}
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org