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/16 12:29:27 UTC

svn commit: r344984 [1/2] - in /incubator/synapse/trunk/scratch/prototype2: ./ src/ src/org/ src/org/apache/ src/org/apache/synapse/ src/org/apache/synapse/api/ src/org/apache/synapse/axis2/ src/org/apache/synapse/mediators/ src/org/apache/synapse/rule...

Author: pzf
Date: Wed Nov 16 03:27:13 2005
New Revision: 344984

URL: http://svn.apache.org/viewcvs?rev=344984&view=rev
Log:
yomsp2 tidied up.. description in mailing list

Added:
    incubator/synapse/trunk/scratch/prototype2/
    incubator/synapse/trunk/scratch/prototype2/axis2.xml
    incubator/synapse/trunk/scratch/prototype2/log4j.properties
    incubator/synapse/trunk/scratch/prototype2/src/
    incubator/synapse/trunk/scratch/prototype2/src/org/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/Constants.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngine.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngineConfigurator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseException.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/ConfigurationAware.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/EnvironmentAware.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/Mediator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/MediatorConfiguration.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SOAPMessageContext.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SynapseEnvironment.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2Sender.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironment.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironmentFinder.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ClassMessageReceiver.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/E4XMediatorMessageReceiver.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ServiceMessageReceiver.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SpringMessageReceiver.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseDispatcher.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseMessageReceiver.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfiguration.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfigurator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfiguration.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfigurator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/E4XMediatorConfigurator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/LogMediator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/MediatorTypes.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SendMediator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ServiceMediatorConfigurator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfiguration.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfigurator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/AllRuleEngine.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/OnceRuleEngine.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/RegexRuleEngine.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/Rule.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/RuleCondition.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/RuleEngineTypes.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/XPathRuleEngine.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/spi/
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/spi/MediatorConfigurator.java
    incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/spi/RuleEngine.java
    incubator/synapse/trunk/scratch/prototype2/src/sampleMediators/
    incubator/synapse/trunk/scratch/prototype2/src/sampleMediators/Logger.java
    incubator/synapse/trunk/scratch/prototype2/src/sampleMediators/SpringRedirect.java
    incubator/synapse/trunk/scratch/prototype2/synapse.xml

Added: incubator/synapse/trunk/scratch/prototype2/axis2.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/axis2.xml?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/axis2.xml (added)
+++ incubator/synapse/trunk/scratch/prototype2/axis2.xml Wed Nov 16 03:27:13 2005
@@ -0,0 +1,140 @@
+<axisconfig name="AxisJava2.0">
+	<!-- ================================================= -->
+	<!-- Parameters -->
+	<!-- ================================================= -->
+	<parameter name="hotdeployment" locked="false">true</parameter>
+	<parameter name="hotupdate" locked="false">false</parameter>
+	<parameter name="enableMTOM" 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>
+
+	<parameter name="seralizeLocation" locked="false">.</parameter>
+
+	<parameter name="SynapseConfiguration" locked="false">synapse.xml</parameter>  
+
+	<!--if you want to extract the service archive file and work with that please uncomment this-->
+	<!--else , it wont extract archive file or does not take into consideration if someone drop-->
+	<!--exploded directory into /service directory-->
+	<!--<parameter name="extractServiceArchive" locked="false">true</parameter>-->
+
+
+	<!--    The way of adding listener to the system-->
+	<!--    <listener class="org.apache.axis2.ObserverIMPL">-->
+	<!--        <parameter name="RSS_URL" locked="false">http://127.0.0.1/rss</parameter>-->
+	<!--    </listener>-->
+
+	<!--Registering Axis Storage Class if you comment this default one will -->
+	<!--does the job (org.apache.axis2.storage.impl.AxisMemoryStorage) , if you-->
+	<!--want to register new one write a class by extanding AbastractStorage-->
+	<!--and put that name here-->
+	<axisStorage
+		class="org.apache.axis2.storage.impl.AxisMemoryStorage">
+		<parameter name="StoreLocation" locked="false">N:S</parameter>
+	</axisStorage>
+
+
+
+	<!-- ================================================= -->
+	<!-- Message Receivers -->
+	<!-- ================================================= -->
+	<!-- This is the Deafult Message Receiver for the Request Response style Operations -->
+	<messageReceiver mep="INOUT"
+		class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
+
+	<!-- ================================================= -->
+	<!-- Transport Ins -->
+	<!-- ================================================= -->
+	<transportReceiver name="http"
+		class="org.apache.axis2.transport.http.SimpleHTTPServer">
+		<parameter name="port" locked="false">6060</parameter>
+	</transportReceiver>
+
+	<!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+		<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">
+		<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>
+		<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>
+		<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>
+		<parameter name="transport.mail.pop3.port" locked="false">110</parameter>
+		<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>
+		</transportReceiver> -->
+
+	<transportReceiver name="tcp"
+		class="org.apache.axis2.transport.tcp.TCPServer">
+		<parameter name="port" locked="false">6060</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="http"
+		class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+		<parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter>
+	</transportSender>
+	<transportSender name="https"
+		class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+		<parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+	</transportSender>
+
+	<!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+		<transportSender name="mail" class="org.apache.axis2.transport.mail.MailTransportSender">
+		<parameter name="transport.mail.smtp.host" locked="false">127.0.0.1</parameter>
+		<parameter name="transport.mail.smtp.user" locked="false">axis2</parameter>
+		<parameter name="transport.mail.smtp.password" locked="false">axis2</parameter>
+		<parameter name="transport.mail.smtp.port" locked="false">25</parameter>
+		</transportSender>
+	-->
+
+	<!-- ================================================= -->
+	<!-- Global Modules  -->
+	<!-- ================================================= -->
+	<!-- Comment this to disable Addressing -->
+	<!--  <module ref="addressing" /> -->
+	<module ref="addressing" /> 
+
+
+	<!--Configuring module , providing paramters for modules whether they refer or not-->
+	<!--<moduleConfig name="addressing">-->
+	<!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+	<!--</moduleConfig>-->
+
+	<dispatchOrder>
+		<dispatcher name="SyanpseDispatcher"
+			class="org.apache.synapse.axis2.SynapseDispatcher" />
+	</dispatchOrder>
+
+	<!-- ================================================= -->
+	<!-- Phases  -->
+	<!-- ================================================= -->
+	<phaseOrder type="inflow">
+		<!--  System pre defined phases       -->
+		<phase name="TransportIn" />
+		<phase name="PreDispatch" />
+		<phase name="Dispatch" />
+		<phase name="PostDispatch" />
+		<!--  System pre defined phases       -->
+		<!--   After Postdispatch phase module author or or service author can add any phase he want      -->
+		<phase name="userphase1" />
+	</phaseOrder>
+	<phaseOrder type="outflow">
+		<!--      user can add his own phases to this area  -->
+		<phase name="userphase1" />
+	</phaseOrder>
+	<phaseOrder type="INfaultflow">
+		<!--      user can add his own phases to this area  -->
+		<phase name="userphase1" />
+	</phaseOrder>
+	<phaseOrder type="Outfaultflow">
+		<!--      user can add his own phases to this area  -->
+		<phase name="userphase1" />
+	</phaseOrder>
+</axisconfig>
+

Added: incubator/synapse/trunk/scratch/prototype2/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/log4j.properties?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/log4j.properties (added)
+++ incubator/synapse/trunk/scratch/prototype2/log4j.properties Wed Nov 16 03:27:13 2005
@@ -0,0 +1,25 @@
+log4j.rootCategory=ERROR,stdout,logfile
+
+# Set the level to DEBUG if you want to log all SlideExceptions (some of them aren't errors)
+log4j.category.org.apache.axis2=FATAL
+log4j.category.org.apache.synapse=FATAL
+log4j.category.org.apache.synapse.mediators=INFO
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %-20c{2} - %m %n 
+
+####  appender writes to a file
+log4j.appender.logfile=org.apache.log4j.RollingFileAppender
+log4j.appender.logfile.File=synapse.log
+
+
+# Control the maximum log file size
+log4j.appender.logfile.MaxFileSize=1000KB
+# Archive log files (one backup file here)
+log4j.appender.logfile.MaxBackupIndex=10
+
+log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
+log4j.appender.logfile.layout.ConversionPattern=%6r %5p [%t] (%F:%L) - %m%n
+

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/Constants.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/Constants.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/Constants.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.synapse;
+
+import javax.xml.namespace.QName;
+
+public class Constants {
+	public static final String SPRINGMEDIATOR = "springmediator";
+
+	public static final String SYNAPSE_MEDIATOR_SPRING_BEAN_FACTORY = "synapse.mediator.spring.beanFactory";
+
+	public static final String SYNAPSE_SPRING_MEDIATOR_NAME = "synapse.spring.mediatorName";
+
+	public static final String CLASSMEDIATOR = "classmediator";
+
+	public static final String SYNAPSE_MEDIATOR_CLASS = "synapse.mediator.class";
+
+	public static final String MEDIATE_OPERATION_NAME = "mediate";
+
+
+
+	
+	public static final String SYNAPSE_MEDIATOR_XML_BYTES = "synapse.mediator.xml.bytes";
+
+	public static final String BPELMEDIATOR = "bpelmediator";
+
+	public static final String SYNAPSE_NAMESPACE = "http://ws.apache.org/ns/synapse";
+
+	public static final String SYNAPSE = "synapse";
+
+	public static final String MEDIATOR = "mediator";
+
+	public static final String STAGE = "stage";
+
+	public static final String TYPE = "type";
+
+	public static final QName STAGE_Q = new QName(SYNAPSE_NAMESPACE, STAGE);
+	public static final QName MEDIATOR_Q = new QName(SYNAPSE_NAMESPACE, MEDIATOR);
+
+	
+	public static final QName RULE_TYPE_ATT_Q = new QName("",
+			"rule-type");
+	public static final QName TYPE_ATT_Q = new QName("",
+			TYPE);
+	public static final QName STAGE_NAME_ATT_Q = new QName("",
+			"name");
+
+	public static final QName IN_ORDER_ATTR_Q = new QName("",
+			"order");
+	
+	public static final QName OUT_ORDER_ATTR_Q = new QName("",
+	"order");
+
+
+	public static final String IN = "inphase";
+
+	public static final String OUT = "outphase";
+
+	public static final String MEDIATOR_CONFIGURATION = "synapse.mediator.configuration";
+
+	public static final String MEDIATOR_RESPONSE_PROPERTY = "synapse.mediator.response";
+
+	public static final String ISRESPONSE_PROPERTY = "synapse.isresponse";
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngine.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngine.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngine.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngine.java Wed Nov 16 03:27:13 2005
@@ -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;
+
+
+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.spi.RuleEngine;
+
+
+
+
+public class SynapseEngine {
+	Log log = LogFactory.getLog(getClass());
+
+	private RuleEngine[] inphase = null, outphase = null;
+
+	private boolean inoutseparate = false;
+	
+	private SynapseEnvironment se = null;
+
+	public void process(SOAPMessageContext smc) {
+		log.debug("processing message");
+		SynapseEnvironment se = getSynapseEnvironment();
+		if (inoutseparate && smc.isResponse()) {
+				for (int i=0; i<outphase.length;i++) {
+					boolean ret = outphase[i].process(se, smc);
+					if (ret) break;
+				}
+			
+		}else {
+			for (int i=0; i<inphase.length;i++) {
+				boolean ret = inphase[i].process(se, smc);
+				if (!ret) break;
+			}
+		}
+	}
+	
+	public SynapseEnvironment getSynapseEnvironment() {
+		return se;
+	}
+	public void setSynapseEnvironment(SynapseEnvironment se) {
+		this.se =se;
+	}
+
+	public void setInphase(RuleEngine[] inphase) {
+		this.inphase = inphase;
+	}
+
+
+	public void setOutphase(RuleEngine[] outphase) {
+		this.outphase = outphase;
+	}
+
+
+	void setInoutseparate(boolean inoutseparate) {
+		this.inoutseparate = inoutseparate;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngineConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngineConfigurator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngineConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseEngineConfigurator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,149 @@
+/*
+ * 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;
+
+
+import java.util.HashMap;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+
+import org.apache.axis2.om.OMNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.ruleEngines.RuleEngineTypes;
+import org.apache.synapse.spi.RuleEngine;
+
+
+public class SynapseEngineConfigurator {
+
+	
+	public static void parse(SynapseEngine se, OMElement om) {
+		Log log = LogFactory.getLog(SynapseEngineConfigurator.class);
+		log.debug("parsing SynapseEngine "+om.toString());
+		List rulesets = new LinkedList();
+
+		RuleEngine[] inphase = null, outphase = null;
+
+		Map ruleSetNames = new HashMap();
+
+		boolean inoutseparate = false;
+		String inPhaseNames = null, outPhaseNames = null;
+		if (!om.getLocalName().equals(Constants.SYNAPSE)
+				|| !om.getNamespace().getName().equals(
+						Constants.SYNAPSE_NAMESPACE)) {
+			throw new SynapseException("OMElement is not of namespace "
+					+ Constants.SYNAPSE_NAMESPACE + "or not localname "
+					+ Constants.SYNAPSE);
+		}
+
+		OMNode node = om.getFirstOMChild();
+		while (node != null) {
+			if (node.getType() != OMNode.ELEMENT_NODE) {
+				node = node.getNextOMSibling();
+				continue;
+			} // loop thru Elements only
+
+			OMElement el = (OMElement) node;
+
+			if (!el.getNamespace().getName().toLowerCase().equals(
+					Constants.SYNAPSE_NAMESPACE)) {
+				node = node.getNextOMSibling();
+				continue;
+			} // ignore non-synapse elements
+
+			if (el.getLocalName().toLowerCase().equals(Constants.STAGE)) {
+				
+				OMAttribute attr = el
+						.getAttribute(Constants.RULE_TYPE_ATT_Q);
+				if (attr==null) throw new SynapseException("no "+Constants.RULE_TYPE_ATT_Q+" attribute on element "+el.toString());
+				String type = attr.getAttributeValue();
+				RuleEngine re = RuleEngineTypes.getRuleEngine(type);
+				if (re != null) {
+					re.init(el, se.getSynapseEnvironment().getClassLoader());
+				}
+				rulesets.add(re);
+				OMAttribute name = el
+						.getAttribute(Constants.STAGE_NAME_ATT_Q);
+				if (name != null) {
+					ruleSetNames.put(name.getAttributeValue(), re);
+				}
+			} else if (el.getLocalName().toLowerCase()
+					.equals(Constants.IN)) {
+				OMAttribute attr = el
+						.getAttribute(Constants.IN_ORDER_ATTR_Q);
+				if (attr != null) {
+					inPhaseNames = attr.getAttributeValue();
+				}
+			} else if (el.getLocalName().equals(Constants.OUT)) {
+				OMAttribute attr = el
+						.getAttribute(Constants.OUT_ORDER_ATTR_Q);
+				if (attr != null) {
+					outPhaseNames = attr.getAttributeValue();
+				}
+
+			}
+			node = node.getNextOMSibling();
+		}
+		if (inPhaseNames != null || outPhaseNames != null) {
+			inoutseparate = true;
+			String inOrder[] = parsePhaseOrder(inPhaseNames);
+			inphase = new RuleEngine[inOrder.length];
+			for (int i = 0; i < inOrder.length; i++) {
+				RuleEngine r = (RuleEngine) ruleSetNames.get(inOrder[i]);
+				if (r == null) {
+					throw new SynapseException(
+							"missing ruleset specified in inPhase order: "
+									+ inOrder[i]);
+				} else
+					inphase[i] = r;
+			}
+			String outOrder[] = parsePhaseOrder(outPhaseNames);
+			outphase = new RuleEngine[outOrder.length];
+			for (int i = 0; i < outOrder.length; i++) {
+				RuleEngine r = (RuleEngine) ruleSetNames.get(outOrder[i]);
+				if (r == null) {
+					throw new SynapseException(
+							"missing ruleset specified in outPhase order: "
+									+ outOrder[i]);
+				} else
+					outphase[i] = r;
+			}
+		} else {
+			inphase = new RuleEngine[rulesets.size()];
+			for (int i=0;i<inphase.length;i++) {
+				inphase[i] = (RuleEngine)rulesets.get(i);
+				
+			}
+			
+			
+		}
+		se.setInoutseparate(inoutseparate);
+		se.setInphase(inphase);
+		se.setOutphase(outphase);
+		
+		
+	}	
+
+	private static String[] parsePhaseOrder(String order) {
+		return order.trim().toLowerCase().split("[ \t\n\f\r]+");
+	}
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseException.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseException.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseException.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/SynapseException.java Wed Nov 16 03:27:13 2005
@@ -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;
+
+
+
+public class SynapseException extends RuntimeException {
+
+	private static final long serialVersionUID = -7244032125641596311L;
+	
+	
+	public SynapseException(String string) {
+		super(string);
+		
+	}
+
+	public SynapseException(String msg, Throwable e) {
+		super(msg, e);
+		
+	}
+
+	public SynapseException(Throwable t) {
+		super(t);
+		
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/ConfigurationAware.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/ConfigurationAware.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/ConfigurationAware.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/ConfigurationAware.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,7 @@
+package org.apache.synapse.api;
+
+
+public interface ConfigurationAware {
+	public void setMediationConfiguration(MediatorConfiguration mc);
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/EnvironmentAware.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/EnvironmentAware.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/EnvironmentAware.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/EnvironmentAware.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,7 @@
+package org.apache.synapse.api;
+
+
+public interface EnvironmentAware {
+	public void setSynapseEnvironment(SynapseEnvironment se);
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/Mediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/Mediator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/Mediator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/Mediator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,22 @@
+/*
+ * 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.api;
+
+
+
+public interface Mediator {
+    public boolean mediate(SOAPMessageContext smc);
+}
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/MediatorConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/MediatorConfiguration.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/MediatorConfiguration.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/MediatorConfiguration.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,9 @@
+package org.apache.synapse.api;
+
+import org.apache.axis2.om.OMElement;
+
+public interface MediatorConfiguration {
+	OMElement getMediatorElement();
+	String getMediatorName();
+	int getMediatorType();
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SOAPMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SOAPMessageContext.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SOAPMessageContext.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SOAPMessageContext.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.api;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.miheaders.RelatesTo;
+import org.apache.axis2.soap.SOAPEnvelope;
+
+
+public interface SOAPMessageContext {
+
+    public EndpointReference getFaultTo();
+    public void setFaultTo(EndpointReference reference);
+
+    public EndpointReference getFrom();
+    public void setFrom(EndpointReference reference);
+
+    public SOAPEnvelope getEnvelope();
+    public void setEnvelope(SOAPEnvelope envelope) throws AxisFault;
+
+    public String getMessageID();
+    public void setMessageID(String string);
+
+    public RelatesTo getRelatesTo();
+    public void setRelatesTo(RelatesTo reference);
+
+    public EndpointReference getReplyTo();
+    public void setReplyTo(EndpointReference reference);
+
+    public EndpointReference getTo();
+    public void setTo(EndpointReference reference);
+
+    public void setWSAAction(String actionURI);
+    public String getWSAAction();
+
+    public void setWSAMessageId(String messageID);
+    public String getWSAMessageId();
+
+    public Object getProperty(String key);
+    public void setProperty(String key, Object value);
+
+    public String getSoapAction();
+    public void setSoapAction(String string);
+
+    public boolean isDoingMTOM();
+    public void setDoingMTOM(boolean b);
+
+    public boolean isDoingREST();
+    public void setDoingREST(boolean b);
+
+    public boolean isSOAP11();
+    
+    public void setResponse(boolean b);
+    public boolean isResponse();
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SynapseEnvironment.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SynapseEnvironment.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SynapseEnvironment.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/api/SynapseEnvironment.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,27 @@
+/*
+ * 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.api;
+
+
+
+public interface SynapseEnvironment {
+	public void injectMessage(SOAPMessageContext smc);
+	public boolean executeMediator(MediatorConfiguration mc, SOAPMessageContext smc);
+	public ClassLoader getClassLoader();
+	public void sendOn(SOAPMessageContext smc);
+	public void sendBack(SOAPMessageContext smc);
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,126 @@
+package org.apache.synapse.axis2;
+
+
+
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.deployment.util.PhasesInfo;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.axis2.engine.AxisConfigurationImpl;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+
+
+
+
+import javax.xml.namespace.QName;
+
+public class Axis2FlexibleMEPClient {
+     
+	// wholesale cut and paste from axis2.clientapi.*
+	public static MessageContext send(MessageContext smc) {
+		try {
+		
+	     ConfigurationContext sysContext = null;
+         ConfigurationContextFactory efac =
+	                    new ConfigurationContextFactory();
+	            sysContext = efac.buildClientConfigurationContext(null);
+        QName assumedServiceName = new QName("AnonymousService");
+        AxisService axisService = new AxisService(assumedServiceName);
+        AxisOperation axisOperationTemplate = new   OutInAxisOperation(new QName("TemplateOperation"));
+        PhasesInfo info =((AxisConfigurationImpl)sysContext.getAxisConfiguration()).getPhasesinfo();
+        if(info != null){
+              info.setOperationPhases(axisOperationTemplate);
+        }
+        axisService.addOperation(axisOperationTemplate);
+        sysContext.getAxisConfiguration().addService(axisService);
+	    ServiceContext serviceContext = axisService.getParent().getServiceGroupContext(sysContext).getServiceContext(
+	                assumedServiceName.getLocalPart());
+	    
+	    MessageContext msgCtx = new MessageContext(serviceContext.getConfigurationContext());
+		
+	    if(smc.getSoapAction()!=null) msgCtx.setSoapAction(smc.getSoapAction());
+	    if(smc.getTo()!=null) msgCtx.setTo(smc.getTo());
+	    if(smc.getFrom()!=null) msgCtx.setFrom(smc.getFrom());
+	    if(smc.getMessageID()!=null) msgCtx.setMessageID(smc.getMessageID()); else msgCtx.setMessageID(String.valueOf("uuid:"+ UUIDGenerator.getUUID()));
+	    if(smc.getReplyTo()!=null) msgCtx.setReplyTo(smc.getReplyTo());
+	    if(smc.getRelatesTo()!=null) msgCtx.setRelatesTo(smc.getRelatesTo());
+
+	    msgCtx.setEnvelope(smc.getEnvelope());
+	    if (msgCtx.getEnvelope().getHeader()==null )
+	    msgCtx.getEnvelope().getBody().insertSiblingBefore(
+				OMAbstractFactory.getSOAP11Factory()
+						.getDefaultEnvelope().getHeader());
+
+        
+	    msgCtx.setServiceContext(serviceContext);
+        
+        EndpointReference epr = msgCtx.getTo();
+        String transport = null;
+        if (epr != null) {
+            String toURL = epr.getAddress();
+            int index = toURL.indexOf(':');
+            if (index > 0) {
+                transport = toURL.substring(0, index);
+            }
+        }
+
+        if (transport != null) {
+        
+				msgCtx.setTransportOut(serviceContext.getConfigurationContext().getAxisConfiguration().getTransportOut(
+				        new QName(transport)));
+		
+        } else {
+            throw new SynapseException("cannotInferTransport");
+        }
+        //initialize and set the Operation Context
+	    
+	    
+	    
+			msgCtx.setOperationContext(axisOperationTemplate.findOperationContext(msgCtx, serviceContext));
+			AxisEngine engine = new AxisEngine(sysContext);
+			engine.send(msgCtx);
+			
+			
+		
+		MessageContext response =
+            new MessageContext(msgCtx.getSystemContext(),
+                    msgCtx.getSessionContext(),
+                    msgCtx.getTransportIn(),
+                    msgCtx.getTransportOut());
+		response.setProperty(MessageContext.TRANSPORT_IN,
+                         msgCtx.getProperty(MessageContext.TRANSPORT_IN));
+		msgCtx.getAxisOperation().registerOperationContext(response,msgCtx.getOperationContext());
+		response.setServerSide(false);
+		response.setServiceContext(msgCtx.getServiceContext());
+		response.setServiceGroupContext(msgCtx.getServiceGroupContext());
+
+		//If request is REST we assume the response is REST, so set the variable
+		response.setDoingREST(msgCtx.isDoingREST());
+
+		SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(response, msgCtx.getEnvelope().getNamespace().getName());
+
+		response.setEnvelope(resenvelope);
+		engine = new AxisEngine(msgCtx.getSystemContext());
+		engine.receive(response);
+		response.setProperty(Constants.ISRESPONSE_PROPERTY, new Boolean(true));
+		return response;
+	    } catch (Exception e) {
+			e.printStackTrace();
+			throw new SynapseException(e);
+		}
+	      
+	}
+	
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,177 @@
+package org.apache.synapse.axis2;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.miheaders.RelatesTo;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.synapse.Constants;
+import org.apache.synapse.api.SOAPMessageContext;
+
+public class Axis2SOAPMessageContext implements SOAPMessageContext {
+
+	private MessageContext mc = null;
+
+	private Map props = new HashMap();
+	private boolean response = false;
+
+	public Axis2SOAPMessageContext(MessageContext mc) {
+		this.mc = mc;
+		Boolean resp = (Boolean)mc.getProperty(Constants.ISRESPONSE_PROPERTY);
+		if (resp!=null) response = resp.booleanValue();
+	}
+
+	public EndpointReference getFaultTo() {
+		return mc.getFaultTo();
+	}
+
+	public void setFaultTo(EndpointReference reference) {
+		mc.setFaultTo(reference);
+	}
+
+	public EndpointReference getFrom() {
+		return mc.getFrom();
+	}
+
+	public void setFrom(EndpointReference reference) {
+		mc.setFrom(reference);
+
+	}
+
+	public SOAPEnvelope getEnvelope() {
+
+		return mc.getEnvelope();
+	}
+
+	public void setEnvelope(SOAPEnvelope envelope) throws AxisFault {
+		mc.setEnvelope(envelope);
+
+	}
+
+	public String getMessageID() {
+		return mc.getMessageID();
+	}
+
+	public void setMessageID(String string) {
+		mc.setMessageID(string);
+
+	}
+
+	public RelatesTo getRelatesTo() {
+		return getRelatesTo();
+
+	}
+
+	public void setRelatesTo(RelatesTo reference) {
+		mc.setRelatesTo(reference);
+
+	}
+
+	public EndpointReference getReplyTo() {
+		return mc.getReplyTo();
+
+	}
+
+	public void setReplyTo(EndpointReference reference) {
+		mc.setReplyTo(reference);
+
+	}
+
+	public EndpointReference getTo() {
+		return mc.getTo();
+
+	}
+
+	public void setTo(EndpointReference reference) {
+		mc.setTo(reference);
+
+	}
+
+	public void setWSAAction(String actionURI) {
+		mc.setWSAAction(actionURI);
+
+	}
+
+	public String getWSAAction() {
+
+		return mc.getWSAAction();
+	}
+
+	public void setWSAMessageId(String messageID) {
+		mc.setWSAMessageId(messageID);
+
+	}
+
+	public String getWSAMessageId() {
+
+		return mc.getWSAMessageId();
+	}
+
+	public Object getProperty(String key) {
+		return props.get(key);
+
+	}
+
+	public void setProperty(String key, Object value) {
+		props.put(key, value);
+	}
+
+	public Iterator getPropertyNames() {
+		return props.keySet().iterator();
+	}
+
+	public String getSoapAction() {
+		return mc.getSoapAction();
+	}
+
+	public void setSoapAction(String string) {
+		mc.setSoapAction(string);
+
+	}
+
+	public boolean isDoingMTOM() {
+
+		return mc.isDoingMTOM();
+	}
+
+	public void setDoingMTOM(boolean b) {
+		mc.setDoingMTOM(b);
+
+	}
+
+	public boolean isDoingREST() {
+
+		return mc.isDoingREST();
+	}
+
+	public void setDoingREST(boolean b) {
+		mc.setDoingREST(b);
+
+	}
+
+	public boolean isSOAP11() {
+
+		return mc.isSOAP11();
+	}
+	public MessageContext getMessageContext() {
+		return mc;
+	}
+	public void setMessageContext(MessageContext mc) {
+		this.mc = mc;
+		Boolean resp = (Boolean)mc.getProperty(Constants.ISRESPONSE_PROPERTY);
+		if (resp!=null) response = resp.booleanValue();
+	}
+
+	public void setResponse(boolean b) {
+		response = b;
+		mc.setProperty(Constants.ISRESPONSE_PROPERTY, new Boolean(b));
+	}
+
+	public boolean isResponse() {
+		return response;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2Sender.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2Sender.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2Sender.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,101 @@
+package org.apache.synapse.axis2;
+
+
+
+import org.apache.axis2.AxisFault;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+
+import org.apache.axis2.context.OperationContextFactory;
+
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+
+
+import org.apache.synapse.api.SOAPMessageContext;
+
+
+public class Axis2Sender {
+	
+	public static void sendOn(SOAPMessageContext smc) {
+		
+		try {
+			
+			
+			MessageContext messageContext = ((Axis2SOAPMessageContext)smc).getMessageContext();
+			AxisEngine ae = new AxisEngine(messageContext.getSystemContext());
+			
+				
+				ConfigurationContext sc = messageContext.getSystemContext();
+				
+				MessageContext outMsgContext = Axis2FlexibleMEPClient.send(messageContext);
+				
+
+				// run all rules on response
+				
+				outMsgContext.setServerSide(true);
+
+				// deal with the fact that AddressingOutHandler has a bug if
+				// there
+				// is no header at all.
+				if (outMsgContext.getEnvelope().getHeader() == null)
+					outMsgContext.getEnvelope().getBody().insertSiblingBefore(
+							OMAbstractFactory.getSOAP11Factory()
+									.getDefaultEnvelope().getHeader());
+				Object os = messageContext
+						.getProperty(MessageContext.TRANSPORT_OUT);
+				outMsgContext.setProperty(MessageContext.TRANSPORT_OUT, os);
+				Object ti = messageContext
+						.getProperty(HTTPConstants.HTTPOutTransportInfo);
+				outMsgContext.setProperty(HTTPConstants.HTTPOutTransportInfo,
+						ti);
+				
+				SynapseDispatcher sd = new SynapseDispatcher();
+				sd.initDispatcher();
+				AxisService synapseService = sd.findService(messageContext);
+				AxisOperation synapseOperation = sd.findOperation(synapseService,
+						messageContext);
+				
+				outMsgContext.setConfigurationContext(sc);
+				outMsgContext.setAxisService(synapseService);
+				outMsgContext.setAxisOperation(synapseOperation);
+				outMsgContext.setOperationContext(OperationContextFactory.createOperationContext(OperationContextFactory.MEP_CONSTANT_OUT_ONLY, synapseOperation));
+			
+			
+				ae.receive(outMsgContext);
+
+				
+		} catch (Exception e) {
+			throw new SynapseException(e);
+		} 
+	}
+
+	public static void sendBack(SOAPMessageContext smc) {
+		MessageContext messageContext = ((Axis2SOAPMessageContext)smc).getMessageContext();
+		AxisEngine ae = new AxisEngine(messageContext.getSystemContext());
+		
+		if (messageContext.getEnvelope().getHeader() == null)
+			messageContext.getEnvelope().getBody().insertSiblingBefore(
+					OMAbstractFactory.getSOAP11Factory()
+							.getDefaultEnvelope().getHeader());
+		
+		messageContext.setProperty(Constants.ISRESPONSE_PROPERTY, new Boolean(true));
+		
+		try {
+			ae.send(messageContext);
+		} catch (AxisFault e) {
+			throw new SynapseException(e);
+			
+		}
+	
+
+	}
+	
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironment.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironment.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironment.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironment.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,139 @@
+package org.apache.synapse.axis2;
+
+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.om.OMElement;
+import org.apache.axis2.util.Utils;
+import org.apache.synapse.Constants;
+
+import org.apache.synapse.SynapseEngine;
+import org.apache.synapse.SynapseEngineConfigurator;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.MediatorConfiguration;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+import org.apache.synapse.mediators.MediatorTypes;
+
+
+
+public class Axis2SynapseEnvironment implements SynapseEnvironment {
+	private SynapseEngine se = new SynapseEngine();
+	private ClassLoader cl = null;
+	
+	public Axis2SynapseEnvironment(OMElement synapseConfiguration, ClassLoader cl) {
+		this.cl = cl;
+		se.setSynapseEnvironment(this);
+		SynapseEngineConfigurator.parse(se, synapseConfiguration);
+	}
+	
+	public void injectMessage(SOAPMessageContext smc) {
+		se.process(smc);
+	}
+
+	public ClassLoader getClassLoader() {
+		return cl;
+	}
+	
+	public void setClassLoader(ClassLoader cl) {
+		this.cl = cl;
+	}
+
+	public boolean executeMediator(MediatorConfiguration mc,
+			SOAPMessageContext smc) {
+		MessageContext messageContext = null;
+		try {
+			messageContext= ((Axis2SOAPMessageContext)smc).getMessageContext();
+		}
+		catch (ClassCastException cce) {
+			throw new SynapseException("A non-Axis2 MC SOAPMessageContext has been passed to the Axis2 MediationExecutor",cce);
+		}
+		
+		ConfigurationContext cc = messageContext.getSystemContext();
+		AxisConfiguration ac = cc.getAxisConfiguration();
+		AxisEngine ae = new AxisEngine(cc);
+
+		AxisService as = null;
+		AxisOperation ao = null;
+		messageContext.setProperty(
+				Constants.MEDIATOR_CONFIGURATION, mc);
+		
+		try {
+			switch (mc.getMediatorType()) { 
+				case  MediatorTypes.SPRING: {
+
+					as = ac.getService(Constants.SPRINGMEDIATOR);
+					if (as == null) throw new SynapseException("cannot locate service " +Constants.SPRINGMEDIATOR);
+					//((SpringMediatorConfiguration)mc).getApplicationContext().setClassLoader(as.getClassLoader());
+					//((SpringMediatorConfiguration)mc).getApplicationContext().refresh();
+					
+					break;
+					
+				}
+				case MediatorTypes.SERVICE: {
+					as = ac.getService(mc.getMediatorName());
+					if (as == null) throw new SynapseException("cannot locate service " +mc.getMediatorName());
+					break;
+				}
+				case MediatorTypes.CLASS: {
+					as = ac.getService(Constants.CLASSMEDIATOR);
+					if (as==null) throw new SynapseException("cannot locate service "+Constants.CLASSMEDIATOR);
+					break;
+					
+				}
+				case MediatorTypes.BUILTIN: {
+					as = ac.getService(Constants.CLASSMEDIATOR);
+					if (as==null) throw new SynapseException("cannot locate service "+Constants.CLASSMEDIATOR);
+					break;
+				}
+					
+			}
+			
+			
+
+			ao = as.getOperation(Constants.MEDIATE_OPERATION_NAME);
+			OperationContext oc = OperationContextFactory
+					.createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+			ao.registerOperationContext(messageContext, oc);
+
+			ServiceContext sc = Utils.fillContextInformation(ao, as, cc);
+			oc.setParent(sc);
+			messageContext.setOperationContext(oc);
+			messageContext.setServiceContext(sc);
+
+			messageContext.setAxisOperation(ao);
+			messageContext.setAxisService(as);
+			ae.receive(messageContext);
+
+		} catch (AxisFault e) {
+			throw new SynapseException(e);
+
+		}
+
+		return ((Boolean) messageContext
+				.getProperty(Constants.MEDIATOR_RESPONSE_PROPERTY))
+				.booleanValue();
+
+		
+	}
+
+	public void sendOn(SOAPMessageContext smc) {
+		Axis2Sender.sendOn(smc);
+		
+	}
+
+	public void sendBack(SOAPMessageContext smc) {
+		Axis2Sender.sendBack(smc);
+		
+	}
+
+	
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironmentFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironmentFinder.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironmentFinder.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/Axis2SynapseEnvironmentFinder.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,62 @@
+package org.apache.synapse.axis2;
+
+import java.io.InputStream;
+
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ParameterImpl;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.SynapseEnvironment;
+
+public class Axis2SynapseEnvironmentFinder {
+
+	private static final String SYNAPSECONFIGURATION = "SynapseConfiguration";
+
+	public static final String SYNAPSE_ENVIRONMENT = "synapse.environment";
+
+	public static synchronized SynapseEnvironment getSynapseEnvironment(MessageContext mc) {
+		AxisConfiguration ac = mc.getSystemContext().getAxisConfiguration();
+		Parameter synapseEnvParam = ac.getParameter(SYNAPSE_ENVIRONMENT);
+		if (synapseEnvParam == null) {
+
+			Parameter param = ac.getParameter(SYNAPSECONFIGURATION);
+			if (param == null) {
+				throw new SynapseException("no parameter '" + SYNAPSECONFIGURATION
+						+ "' in axis2.xml");
+			}
+			String synapseConfig = (String) param.getValue();
+			InputStream is = mc.getAxisService().getClassLoader().getResourceAsStream(synapseConfig);
+			
+			StAXOMBuilder builder;
+			try {
+				builder =  new StAXOMBuilder(is);
+
+			} catch (XMLStreamException e1) {
+				throw new SynapseException("Trouble parsing Synapse Configuration ",e1);
+				
+			}		
+			OMElement config = builder.getDocumentElement();
+			Axis2SynapseEnvironment se = new Axis2SynapseEnvironment(config, mc.getAxisService().getClassLoader());
+			
+		
+			synapseEnvParam = new ParameterImpl(SYNAPSE_ENVIRONMENT, null);
+			synapseEnvParam.setValue(se);
+			try {
+				ac.addParameter(synapseEnvParam);
+			} catch (AxisFault e) {
+				throw new SynapseException(e);
+			}
+		}
+		return (SynapseEnvironment) synapseEnvParam.getValue();
+		
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ClassMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ClassMessageReceiver.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ClassMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ClassMessageReceiver.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,45 @@
+package org.apache.synapse.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.ConfigurationAware;
+import org.apache.synapse.api.EnvironmentAware;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.mediators.ClassMediatorConfiguration;
+
+public class ClassMessageReceiver implements MessageReceiver {
+
+	  public void receive(MessageContext mc) throws AxisFault {
+	        Mediator mediator = (Mediator) makeNewServiceObject(mc);
+	        SOAPMessageContext smc = new Axis2SOAPMessageContext(mc);
+	        boolean resp = mediator.mediate(smc);
+	        mc.setProperty(Constants.MEDIATOR_RESPONSE_PROPERTY, Boolean.valueOf(resp));
+	    }
+
+	    
+	    protected Object makeNewServiceObject(MessageContext msgContext) {
+	        
+	        ClassMediatorConfiguration medConfig = (ClassMediatorConfiguration)msgContext.getProperty(Constants.MEDIATOR_CONFIGURATION);
+	        Class clazz = medConfig.getMediatorClass();
+	        
+	        Object o;
+			try {
+				o = clazz.newInstance();
+			} catch (Exception e) {
+				throw new SynapseException(e);
+			}
+	        if (EnvironmentAware.class.isAssignableFrom(o.getClass())) {
+	        	((EnvironmentAware)o).setSynapseEnvironment(Axis2SynapseEnvironmentFinder.getSynapseEnvironment(msgContext));
+	        }
+	        if (ConfigurationAware.class.isAssignableFrom(o.getClass())) {
+	        	((ConfigurationAware)o).setMediationConfiguration(medConfig);
+	        }
+	        return o;
+	    }
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/E4XMediatorMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/E4XMediatorMessageReceiver.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/E4XMediatorMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/E4XMediatorMessageReceiver.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,16 @@
+package org.apache.synapse.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.MessageReceiver;
+
+public class E4XMediatorMessageReceiver implements MessageReceiver {
+
+	public void receive(MessageContext arg0) throws AxisFault {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ServiceMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ServiceMessageReceiver.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ServiceMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/ServiceMessageReceiver.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,15 @@
+package org.apache.synapse.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.MessageReceiver;
+
+public class ServiceMessageReceiver implements MessageReceiver {
+
+	public void receive(MessageContext arg0) throws AxisFault {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SpringMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SpringMessageReceiver.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SpringMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SpringMessageReceiver.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,46 @@
+package org.apache.synapse.axis2;
+
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.synapse.Constants;
+import org.apache.synapse.api.ConfigurationAware;
+import org.apache.synapse.api.EnvironmentAware;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.mediators.SpringMediatorConfiguration;
+
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SpringMessageReceiver implements MessageReceiver {
+
+   
+	
+    public void receive(MessageContext mc) throws AxisFault {
+        Mediator mediator = (Mediator) makeNewServiceObject(mc);
+        SOAPMessageContext smc = new Axis2SOAPMessageContext(mc);
+        boolean resp = mediator.mediate(smc);
+        
+        mc.setProperty(Constants.MEDIATOR_RESPONSE_PROPERTY, Boolean.valueOf(resp));
+    }
+
+    
+    protected Object makeNewServiceObject(MessageContext msgContext) {
+        
+        SpringMediatorConfiguration medConfig = (SpringMediatorConfiguration)msgContext.getProperty(Constants.MEDIATOR_CONFIGURATION);
+        GenericApplicationContext ctx = medConfig.getApplicationContext();
+        
+        Object o = ctx.getBean(medConfig.getBeanName());
+        if (EnvironmentAware.class.isAssignableFrom(o.getClass())) {
+        	((EnvironmentAware)o).setSynapseEnvironment(Axis2SynapseEnvironmentFinder.getSynapseEnvironment(msgContext));
+        }
+        if (ConfigurationAware.class.isAssignableFrom(o.getClass())) {
+        	((ConfigurationAware)o).setMediationConfiguration(medConfig);
+        }
+        return o;
+    }
+	
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseDispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseDispatcher.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseDispatcher.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseDispatcher.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.axis2;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.engine.AbstractDispatcher;
+import org.apache.axis2.engine.AxisConfiguration;
+
+public class SynapseDispatcher extends AbstractDispatcher {
+	// FOR EVERY REQUEST - ALWAYS DISPATH TO THE SYNAPSE SERVICE
+
+	private static final long serialVersionUID = -6970206989111592645L;
+
+	private static final String SYNAPSE_SERVICE_NAME = "synapse";
+
+	private static final String MEDIATE_OPERATION_NAME = "mediate";
+
+	public void initDispatcher() {
+		QName qn = new QName("http://synapse.apache.org", "SynapseDispatcher");
+		HandlerDescription hd = new HandlerDescription(qn);
+		super.init(hd);
+
+	}
+
+	public AxisService findService(MessageContext mc) throws AxisFault {
+		AxisConfiguration ac = mc.getSystemContext().getAxisConfiguration();
+		AxisService as = ac.getService(SYNAPSE_SERVICE_NAME);
+		// TODO handle missing config
+		return as;
+	}
+
+	public AxisOperation findOperation(AxisService svc, MessageContext mc)
+			throws AxisFault {
+
+		AxisOperation ao = svc.getOperation(MEDIATE_OPERATION_NAME);
+		// code taken from InstanceDispatcher
+		OperationContext oc = new OperationContext(ao);
+
+		ao.registerOperationContext(mc, oc);
+
+		// fill the service group context and service context info
+		mc.getSystemContext().fillServiceContextAndServiceGroupContext(mc);
+		// TODO handle missing config
+		return ao;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseMessageReceiver.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/axis2/SynapseMessageReceiver.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,38 @@
+/*
+ * 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.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+
+public class SynapseMessageReceiver implements MessageReceiver {
+	
+	private Log log = LogFactory.getLog(getClass());
+	public void receive(MessageContext mc) throws AxisFault {
+		log.debug("receiving message");
+		SynapseEnvironment env = Axis2SynapseEnvironmentFinder.getSynapseEnvironment(mc);
+		SOAPMessageContext smc = new Axis2SOAPMessageContext(mc);
+		env.injectMessage(smc);
+	}
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfiguration.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfiguration.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfiguration.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,15 @@
+package org.apache.synapse.mediators;
+
+
+public class BuiltinMediatorConfiguration extends ClassMediatorConfiguration {
+
+	public BuiltinMediatorConfiguration() {
+		super();
+	}
+		
+	public int getMediatorType() {
+		
+		return MediatorTypes.BUILTIN;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfigurator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/BuiltinMediatorConfigurator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,27 @@
+package org.apache.synapse.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.MediatorConfiguration;
+import org.apache.synapse.spi.MediatorConfigurator;
+
+public class BuiltinMediatorConfigurator implements MediatorConfigurator {
+
+	public MediatorConfiguration parse(OMElement el, ClassLoader cl) {
+		BuiltinMediatorConfiguration bmc = new BuiltinMediatorConfiguration();
+		bmc.setMediatorElement(el);
+		OMAttribute attr = el.getAttribute(new QName("name"));
+		if (attr==null) throw new SynapseException("name attribute missing on element "+el.toString());
+		
+		String med = attr.getAttributeValue().trim().toLowerCase();
+		if (med.equals("log")) bmc.setMediatorClass(LogMediator.class);
+		else if (med.equals("sender")) bmc.setMediatorClass(SendMediator.class);
+		
+		return bmc;
+		
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfiguration.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfiguration.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfiguration.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,41 @@
+package org.apache.synapse.mediators;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.api.MediatorConfiguration;
+
+public class ClassMediatorConfiguration implements MediatorConfiguration {
+
+	private OMElement mediatorElement = null;
+	private String name = null;
+	
+	private Class clazz=null;
+	
+	public OMElement getMediatorElement() {
+		return  mediatorElement;
+
+	}
+
+	public String getMediatorName() {
+
+		return name;
+	}
+
+	public int getMediatorType() {
+		return MediatorTypes.CLASS;
+	}
+	public Class getMediatorClass() {
+		return clazz;
+	}
+
+	public void setMediatorName(String name) {
+		this.name=name;
+	}
+	public void setMediatorClass(Class clazz) {
+		this.clazz = clazz;
+	}
+	public void setMediatorElement(OMElement el) {
+		this.mediatorElement = el;
+	}
+	
+	
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfigurator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ClassMediatorConfigurator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,35 @@
+package org.apache.synapse.mediators;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.MediatorConfiguration;
+import org.apache.synapse.spi.MediatorConfigurator;
+
+public class ClassMediatorConfigurator implements MediatorConfigurator {
+
+	public MediatorConfiguration parse(OMElement el, ClassLoader cl) {
+		ClassMediatorConfiguration cmc = new ClassMediatorConfiguration();
+		
+		OMAttribute name = el.getAttribute(new QName("", "name"));
+		if (name==null) throw new SynapseException("missing name attribute on element"+el.toString());
+		cmc.setMediatorName(name.getAttributeValue());
+		
+		OMAttribute clsName = el.getAttribute(new QName("", "class"));
+		if (clsName==null) throw new SynapseException("missing class attribute on element"+el.toString());
+		try {
+		
+			// This is probably the wrong place to try to load the class because 
+			// we don't have access to the correct class loader
+			// maybe we need to pass classloaders into medconfigurators???
+			cmc.setMediatorClass(cl.loadClass(clsName.getAttributeValue()));
+		} catch (ClassNotFoundException e) {
+			throw new SynapseException("class loading error", e);
+		}
+		cmc.setMediatorElement(el);
+		return cmc;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/E4XMediatorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/E4XMediatorConfigurator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/E4XMediatorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/E4XMediatorConfigurator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,17 @@
+package org.apache.synapse.mediators;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.api.MediatorConfiguration;
+import org.apache.synapse.spi.MediatorConfigurator;
+
+public class E4XMediatorConfigurator implements MediatorConfigurator {
+
+
+
+	public MediatorConfiguration parse(OMElement el, ClassLoader cl) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/LogMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/LogMediator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/LogMediator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/LogMediator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,21 @@
+package org.apache.synapse.mediators;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.SOAPMessageContext;
+
+
+public class LogMediator implements Mediator {
+
+	Log log = LogFactory.getLog(getClass());
+	public boolean mediate(SOAPMessageContext smc) {
+		log.info(smc.getTo());
+		log.info(smc.getFrom());
+		log.info(smc.getReplyTo());
+		log.info(smc.getMessageID());
+		log.info(smc.getEnvelope());
+		return true;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/MediatorTypes.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/MediatorTypes.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/MediatorTypes.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/MediatorTypes.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,57 @@
+/*
+ * 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.spi.MediatorConfigurator;
+
+public class MediatorTypes {
+	
+	public static final int SERVICE=0, SPRING=1, E4X=2, CLASS=3, BUILTIN=4;
+	public static final String STRSERVICE = "service", STRCLASS = "class", STRSPRING = "spring", STRE4X = "e4x", STRBUILTIN="builtin";
+	
+
+	
+	public static MediatorConfigurator getMediatorConfigurator(String attributeValue) {
+		String type = attributeValue.toLowerCase().trim();
+		if (type.equals(STRSPRING))  
+			return new SpringMediatorConfigurator();
+		else if (type.equals(STRSERVICE)) 
+			return new ServiceMediatorConfigurator();
+		else if (type.equals(STRE4X))
+			return new E4XMediatorConfigurator();
+		else if (type.equals(STRCLASS)) 
+			return new ClassMediatorConfigurator();
+		else if (type.equals(STRBUILTIN)) 
+			return new BuiltinMediatorConfigurator();
+		else return null;
+	}
+
+	public static int getType(String attributeValue) {
+		String type = attributeValue.toLowerCase().trim();
+		if (type.equals(STRSPRING))  
+			return SPRING;
+		else if (type.equals(STRSERVICE)) 
+			return SERVICE;
+		else if (type.equals(STRE4X))
+			return E4X;
+		else if (type.equals(STRCLASS)) 
+			return CLASS;
+		else if (type.equals(STRBUILTIN)) 
+			return BUILTIN;
+		else return -1;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SendMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SendMediator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SendMediator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SendMediator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,29 @@
+package org.apache.synapse.mediators;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.EnvironmentAware;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.SOAPMessageContext;
+import org.apache.synapse.api.SynapseEnvironment;
+
+public class SendMediator implements Mediator, EnvironmentAware {
+	private SynapseEnvironment se = null;
+	
+	public boolean mediate(SOAPMessageContext smc) {
+		if (se==null) throw new SynapseException("engine has failed to do its duty... SynapseEnvironment not set");
+		if (smc.isResponse()) {
+			se.sendBack(smc);
+		}
+		else
+		{
+			se.sendOn(smc);
+		}
+		return false;
+	}
+
+	public void setSynapseEnvironment(SynapseEnvironment se) {
+		this.se = se;
+		
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ServiceMediatorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ServiceMediatorConfigurator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ServiceMediatorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/ServiceMediatorConfigurator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,14 @@
+package org.apache.synapse.mediators;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.api.MediatorConfiguration;
+import org.apache.synapse.spi.MediatorConfigurator;
+
+public class ServiceMediatorConfigurator implements MediatorConfigurator {
+
+	public MediatorConfiguration parse(OMElement el, ClassLoader cl) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfiguration.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfiguration.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfiguration.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,57 @@
+package org.apache.synapse.mediators;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.api.MediatorConfiguration;
+
+import org.springframework.context.support.GenericApplicationContext;
+
+
+public class SpringMediatorConfiguration implements MediatorConfiguration {
+
+	private OMElement mediatorElement = null;
+	private GenericApplicationContext ctx = null;
+	private String name = null;
+	private String beanName = null;
+	
+	public void setMediatorElement(OMElement me) {
+		this.mediatorElement = me;
+	}
+	
+	public OMElement getMediatorElement() {
+	
+		return mediatorElement;
+	}
+
+	public void setApplicationContext(GenericApplicationContext ctx) {
+		this.ctx = ctx;
+		
+	}
+	public GenericApplicationContext getApplicationContext() {
+		return ctx;
+	}
+
+	public String getMediatorName() {
+		
+		return name;
+		
+	}
+	public void setMediatorName(String name) {
+		this.name=name;
+	}
+
+	public int getMediatorType() {
+		
+		return MediatorTypes.SPRING;
+	}
+
+	public void setBeanName(String beanName) {
+		this.beanName = beanName;
+	}
+
+	public String getBeanName() {
+		return beanName;
+	}
+	
+
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfigurator.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/mediators/SpringMediatorConfigurator.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,71 @@
+package org.apache.synapse.mediators;
+
+import java.io.ByteArrayOutputStream;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.MediatorConfiguration;
+import org.apache.synapse.spi.MediatorConfigurator;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ByteArrayResource;
+
+public class SpringMediatorConfigurator implements MediatorConfigurator {
+	
+	
+	public MediatorConfiguration parse(OMElement el, ClassLoader cl) {
+		
+		SpringMediatorConfiguration mc = new SpringMediatorConfiguration();
+		OMAttribute name = el.getAttribute(new QName("", "name"));
+		if (name == null) throw new SynapseException("missing name attribute on "+el.toString());
+		mc.setMediatorName(name.getAttributeValue());
+		OMAttribute bean = el.getAttribute(new QName("", "bean"));
+		if (name == null) throw new SynapseException("missing bean attribute on "+el.toString());
+		mc.setBeanName(bean.getAttributeValue());
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		try {
+			baos.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">"
+							.getBytes());
+			XMLStreamWriter xsw = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
+			OMElement beans = null;
+			Iterator it = el.getChildElements();
+			while (it.hasNext()) {
+				OMElement ths = (OMElement)it.next();
+				if (ths.getLocalName().toLowerCase().equals("beans")) {
+					beans = ths;
+					break;
+				}
+			}
+			if (beans==null) throw new SynapseException("<beans> element not found in "+el.toString());
+			xsw.setDefaultNamespace(beans.getNamespace().getName());
+			beans.serialize(xsw);
+		} catch (Exception e) {
+			throw new SynapseException(e);
+		} 
+				
+		GenericApplicationContext ctx = new GenericApplicationContext();
+		XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(
+				ctx);
+		xbdr.setValidating(false);
+		xbdr.loadBeanDefinitions(new ByteArrayResource(baos.toByteArray()));
+		ctx.setClassLoader(cl);
+		ctx.refresh();
+		
+		
+		mc.setMediatorElement(el);
+		mc.setApplicationContext(ctx);
+		
+		return mc;
+	}
+
+
+
+}

Added: incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/AllRuleEngine.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/AllRuleEngine.java?rev=344984&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/AllRuleEngine.java (added)
+++ incubator/synapse/trunk/scratch/prototype2/src/org/apache/synapse/ruleEngines/AllRuleEngine.java Wed Nov 16 03:27:13 2005
@@ -0,0 +1,35 @@
+package org.apache.synapse.ruleEngines;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.Constants;
+import org.apache.synapse.api.SOAPMessageContext;
+
+
+public class AllRuleEngine extends OnceRuleEngine {
+	private static final QName ALL_RULE_Q = new QName(
+			Constants.SYNAPSE_NAMESPACE, "rule");
+
+	public static final RuleCondition always = new RuleCondition() {
+		public boolean matches(SOAPMessageContext smc) {
+			return true;
+		}
+		public String toString() { return "all: true";}
+	};
+
+	public RuleCondition getRuleCondition(OMElement om) {
+		return always;
+	}
+
+	public QName getRuleQName() {
+		return ALL_RULE_Q;
+	}
+
+	public String getRulesetType() {
+		return "all";
+		
+	}
+
+}



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