synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r321012 [1/3] - in /incubator/synapse/trunk/scratch/saminda: ./ server/ server/classes/ server/services/ src/ src/org/ src/org/apache/ src/org/apache/client/ src/org/apache/synapse/ src/org/apache/synapse/Utils/ src/org/apache/synapse/dispa...
Date Fri, 14 Oct 2005 05:24:53 GMT
Author: saminda
Date: Thu Oct 13 22:24:23 2005
New Revision: 321012

URL: http://svn.apache.org/viewcvs?rev=321012&view=rev
Log:
Prototype Synapse code added to scratch area 

Added:
    incubator/synapse/trunk/scratch/saminda/
    incubator/synapse/trunk/scratch/saminda/build.xml
    incubator/synapse/trunk/scratch/saminda/server/
    incubator/synapse/trunk/scratch/saminda/server/axis2.xml
    incubator/synapse/trunk/scratch/saminda/server/classes/
    incubator/synapse/trunk/scratch/saminda/server/classes/commons-logging.properties
    incubator/synapse/trunk/scratch/saminda/server/classes/log4j.properties
    incubator/synapse/trunk/scratch/saminda/server/services/
    incubator/synapse/trunk/scratch/saminda/server/services/mediation.aar   (with props)
    incubator/synapse/trunk/scratch/saminda/server/web.xml
    incubator/synapse/trunk/scratch/saminda/src/
    incubator/synapse/trunk/scratch/saminda/src/org/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/client/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SampleClient.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SimpleServer.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/SynapseConstants.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/Utils/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/Utils/SynapseTranportUtils.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/dispatchers/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/dispatchers/SynapseBaseDispatcher.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/engine/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/engine/SynapseEngine.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingHandler.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingModule.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/META-INF/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/META-INF/module.xml
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/services.xml
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/synapse.xml
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/Mediator.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleDummyMediator.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleLoggingMediator.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/DependencyManager.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseAbstractMessageReceiver.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseMessageReceiver.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/RuleBean.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleEngine.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleReader.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/transport/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/transport/http/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/transport/http/SynapseWorker.java
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/transport/server/
    incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/transport/server/SimpleSynapseServer.java
    incubator/synapse/trunk/scratch/saminda/synapse.iml
    incubator/synapse/trunk/scratch/saminda/synapse.ipr
    incubator/synapse/trunk/scratch/saminda/synapse.iws

Added: incubator/synapse/trunk/scratch/saminda/build.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/build.xml?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/build.xml (added)
+++ incubator/synapse/trunk/scratch/saminda/build.xml Thu Oct 13 22:24:23 2005
@@ -0,0 +1,76 @@
+<project name="synapse" default="compile" basedir=".">
+
+    <property name="src.dir" value="src"/>
+    <property name="build.dir" value="build"/>
+    <property name="lib.dir" value="./lib"/>
+    <property name="classes.dir" value="./classes"/>
+    <property name="jardrop.dir" value="${build.dir}/services"/>
+
+    <path id="classpath.library">
+        <fileset dir="${lib.dir}">
+            <include name="**/*.jar"/>
+        </fileset>
+    </path>
+
+    <target name="prepare">
+        <mkdir dir="${build.dir}"/>
+        <mkdir dir="${classes.dir}"/>
+        <mkdir dir="${jardrop.dir}"/>
+    </target>
+
+    <target name="clean">
+        <delete dir="${build.dir}"/>
+        <delete dir="${classes.dir}"/>
+        <delete dir="${jardrop.dir}"/>
+    </target>
+
+    <target name="compile" depends="prepare">
+        <javac srcdir="${src.dir}" destdir="${classes.dir}">
+            <classpath refid="classpath.library"/>
+        </javac>
+
+        <jar destfile="${jardrop.dir}/mediation.aar">
+            <fileset dir="${classes.dir}">
+                <include name="**/SimpleLoggingMediator.class"/>
+                <include name="**/DependencyManager.class"/>
+                <include name="**/SimpleDummyMediator.class"/>
+                <include name="**/SynapseAbstractMessageReceiver.class"/>
+                <include name="**/SynapseMessageReceiver.class"/>
+                <include name="**/RuleBean.class"/>
+            </fileset>
+            <fileset dir="${src.dir}/org/apache/synapse/mediators">
+                <include name="META-INF/services.xml"/>
+                <include name="META-INF/synapse.xml"/>
+            </fileset>
+        </jar>
+
+        <jar destfile="${jardrop.dir}/synapse_dispatch.jar">
+            <fileset dir="${classes.dir}">
+                <include name="**/SynapseBaseDispatcher.class"/>
+                <include name="**/SynapseRuleReader.class"/>
+                <include name="**/SynapseRuleEngine.class"/>
+                <include name="**/RuleBean.class"/>
+            </fileset>
+        </jar>
+
+
+        <jar destfile="${jardrop.dir}/LoggingModule.mar">
+            <fileset dir="${classes.dir}">
+                <include name="**/LoggingModule.class"/>
+                <include name="**/LoggingHandler.class"/>
+            </fileset>
+            <fileset dir="${src.dir}/org/apache/synapse/handlers">
+                <include name="META-INF/module.xml"/>
+            </fileset>
+        </jar>
+
+        <copy file="/home/saminda/myprojects/synapse/build/services/LoggingModule.mar"
+        todir="/home/saminda/myprojects/synapse/server/modules" overwrite="true"/>
+        <copy file="/home/saminda/myprojects/synapse/build/services/mediation.aar"
+        todir="/home/saminda/myprojects/synapse/server/services" overwrite="true"/>
+        <copy file="/home/saminda/myprojects/synapse/build/services/synapse_dispatch.jar"
+        todir="/home/saminda/myprojects/synapse/server/lib" overwrite="true"/>
+
+    </target>
+
+</project>

Added: incubator/synapse/trunk/scratch/saminda/server/axis2.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/server/axis2.xml?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/server/axis2.xml (added)
+++ incubator/synapse/trunk/scratch/saminda/server/axis2.xml Thu Oct 13 22:24:23 2005
@@ -0,0 +1,131 @@
+<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>
+
+
+
+    <!--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.1</parameter>
+        <!--<parameter name="PROXY" proxy_host="smecube" proxy_port="3128" locked="true">anonymous:anonymous:anonymous</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"/>
+
+
+    <!--Configuring module , providing paramters for modules whether they refer or not-->
+    <!--<moduleConfig name="addressing">-->
+         <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+    <!--</moduleConfig>-->
+    
+    <!-- ================================================= -->
+    <!-- Phases  -->
+    <!-- ================================================= -->
+    <dispatchOrder>
+        <dispatcher name="SynapseBaseDispatcher" class="org.apache.synapse.dispatchers.SynapseBaseDispatcher"/>
+    </dispatchOrder>
+
+    <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="log"/>
+    </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/saminda/server/classes/commons-logging.properties
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/server/classes/commons-logging.properties?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/server/classes/commons-logging.properties (added)
+++ incubator/synapse/trunk/scratch/saminda/server/classes/commons-logging.properties Thu Oct 13 22:24:23 2005
@@ -0,0 +1,11 @@
+# This is the logging properties that goes to the war, there are two logging conf kept at the 
+# svn, one for developement (one at src/test-resources) and other for producation
+ 
+# Uncomment the next line to disable all logging.
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
+
+# Uncomment the next line to enable the simple log based logging
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+
+# Uncomment the next line to enable log4j based logging
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

Added: incubator/synapse/trunk/scratch/saminda/server/classes/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/server/classes/log4j.properties?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/server/classes/log4j.properties (added)
+++ incubator/synapse/trunk/scratch/saminda/server/classes/log4j.properties Thu Oct 13 22:24:23 2005
@@ -0,0 +1,18 @@
+## Use two appenders, one to log to console, another to log to a file
+# This is the logging properties that goes to the war, there are two logging conf kept at the 
+# svn, one for developement (one at src/test-resources) and other for producation
+
+log4j.rootCategory=ERROR, LOGFILE
+
+####  appender writes to a file
+log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
+log4j.appender.LOGFILE.File=axis.log
+
+# Control the maximum log file size
+log4j.appender.LOGFILE.MaxFileSize=10000KB
+# Archive log files (one backup file here)
+log4j.appender.LOGFILE.MaxBackupIndex=100
+
+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/saminda/server/services/mediation.aar
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/server/services/mediation.aar?rev=321012&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/synapse/trunk/scratch/saminda/server/services/mediation.aar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/synapse/trunk/scratch/saminda/server/web.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/server/web.xml?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/server/web.xml (added)
+++ incubator/synapse/trunk/scratch/saminda/server/web.xml Thu Oct 13 22:24:23 2005
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+    <display-name>Apache-Axis2</display-name>
+    <servlet>
+        <servlet-name>AxisServlet</servlet-name>
+        <display-name>Apache-Axis Servlet</display-name>
+        <servlet-class>
+        org.apache.axis2.transport.http.AxisServlet
+        </servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/servlet/AxisServlet</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>*.jws</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listServices</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listService</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listModules</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/globalModules</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listPhases</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/engagingglobally</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/engageToService</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/adminlogin</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/viewGlobalHandlers</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/selectService</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/viewServiceHandlers</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listoperation</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listOperations</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/services/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/servicedit</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/removeService</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/editServicepara</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/selectServiceParaEdit</url-pattern>
+    </servlet-mapping>
+     <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listServciceGroups</url-pattern>
+    </servlet-mapping>
+     <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/engageToServiceGroup</url-pattern>
+    </servlet-mapping>
+     <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/listContexts</url-pattern>
+    </servlet-mapping>
+     <servlet-mapping>
+        <servlet-name>AxisServlet</servlet-name>
+        <url-pattern>/logout</url-pattern>
+    </servlet-mapping>
+    <error-page>
+        <exception-type>org.apache.axis2.transport.http.server.AdminAppException</exception-type>
+        <location>/Error/AuthError.html</location>
+    </error-page>
+
+    <!--error-page>
+        <exception-type>java.lang.Exception</exception-type>
+        <location>/Error/GenError.html</location>
+    </error-page-->
+</web-app>

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SampleClient.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SampleClient.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SampleClient.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SampleClient.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,66 @@
+package org.apache.client;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.clientapi.MessageSender;
+import org.apache.axis2.Constants;
+import org.apache.axis2.AxisFault;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 8:10:53 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SampleClient {
+    private static EndpointReference targetEPR = new EndpointReference(
+            "http://localhost:8080/");
+
+    public static void main(String[] args) {
+        try {
+
+
+            MessageSender msgSender = new MessageSender();
+            msgSender.setTo(targetEPR);
+            msgSender.setSenderTransport(Constants.TRANSPORT_HTTP);
+
+            msgSender.send("mediate", new ClientUtil().getPingOMElement());
+
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+        }
+
+
+    }
+
+    public static class ClientUtil {
+
+        public OMElement getEchoOMElement() {
+            OMFactory fac = OMAbstractFactory.getOMFactory();
+            OMNamespace omNs = fac.createOMNamespace(
+                    "http://example1.org/example1", "example1");
+            OMElement method = fac.createOMElement("echo", omNs);
+            OMElement value = fac.createOMElement("Text", omNs);
+            value.addChild(fac.createText(value, "Axis2 Echo String "));
+            method.addChild(value);
+
+            return method;
+        }
+
+        public OMElement getPingOMElement() {
+            OMFactory fac = OMAbstractFactory.getOMFactory();
+            OMNamespace omNs = fac.createOMNamespace(
+                    "http://example1.org/example1", "example1");
+            OMElement method = fac.createOMElement("ping", omNs);
+            OMElement value = fac.createOMElement("Text", omNs);
+            value.addChild(fac.createText(value, "Axis2 Ping String "));
+            method.addChild(value);
+
+            return method;
+        }
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SimpleServer.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SimpleServer.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SimpleServer.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/client/SimpleServer.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,22 @@
+package org.apache.client;
+
+import org.apache.axis2.AxisFault;
+import org.apache.synapse.transport.server.SimpleSynapseServer;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 8:10:44 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SimpleServer {
+    public static void main(String[] args ) {
+        try {
+            SimpleSynapseServer sss = new SimpleSynapseServer("/home/saminda/myprojects/synapse/server",8080);
+            sss.start();
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+        }
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/SynapseConstants.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/SynapseConstants.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/SynapseConstants.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,22 @@
+package org.apache.synapse;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 12, 2005
+ * Time: 2:27:49 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface SynapseConstants {
+
+    public static final String MEDEATOT_STATE = "mediatorState";
+    public static final String VALUE_TRUE="true";
+    public static final String VALUE_FALSE="false";
+    public static final String SYNAPSE_STATE="state";
+    public static final String RULE_STATE="ruleState";
+
+    public interface SynapseRuleReader {
+        public static final String CONDITION = "condition";
+        public static final String MEDIATOR = "mediator";
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/Utils/SynapseTranportUtils.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/Utils/SynapseTranportUtils.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/Utils/SynapseTranportUtils.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/Utils/SynapseTranportUtils.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,462 @@
+package org.apache.synapse.Utils;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.attachments.MIMEHelper;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.om.impl.llom.OMNamespaceImpl;
+import org.apache.axis2.om.impl.llom.mtom.MTOMStAXSOAPModelBuilder;
+import org.apache.axis2.om.impl.MTOMConstants;
+import org.apache.axis2.om.*;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.axis2.soap.SOAP11Constants;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
+import org.apache.axis2.soap.impl.llom.soap12.SOAP12Factory;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.engine.SynapseEngine;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.parsers.FactoryConfigurationError;
+import java.io.*;
+import java.util.Map;
+import java.util.Iterator;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 12, 2005
+ * Time: 1:40:58 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SynapseTranportUtils {
+
+    public static void processHTTPPostRequest(
+        MessageContext msgContext,
+        InputStream in,
+        OutputStream out,
+        String contentType,
+        String soapActionHeader,
+        String requestURI,
+        ConfigurationContext configurationContext)
+        throws AxisFault {
+        boolean soap11 = false;
+        try {
+
+            //remove the starting and trailing " from the SOAP Action
+            if (soapActionHeader != null
+                && soapActionHeader.startsWith("\"")
+                && soapActionHeader.endsWith("\"")) {
+
+                soapActionHeader =
+                    soapActionHeader.substring(
+                        1,
+                        soapActionHeader.length() - 1);
+            }
+            //fill up the Message Contexts
+            msgContext.setWSAAction(soapActionHeader);
+            msgContext.setSoapAction(soapActionHeader);
+            msgContext.setTo(new EndpointReference(requestURI));
+            msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
+            msgContext.setServerSide(true);
+
+            SOAPEnvelope envelope = null;
+            StAXBuilder builder = null;
+            if (contentType != null) {
+                if (contentType
+                    .indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
+                    > -1) {
+                    //It is MTOM
+                    builder = selectBuilderForMIME(msgContext, in, contentType);
+                    envelope = (SOAPEnvelope) builder.getDocumentElement();
+                } else {
+                    Reader reader = new InputStreamReader(in);
+
+                    XMLStreamReader xmlreader;
+                    //Figure out the char set encoding and create the reader
+
+                    //If charset is not specified
+                    if ( getCharSetEncoding(contentType) == null ) {
+                        xmlreader =
+                            XMLInputFactory
+                                .newInstance()
+                                .createXMLStreamReader(
+                                in,
+                                MessageContext.DEFAULT_CHAR_SET_ENCODING);
+                        //Set the encoding scheme in the message context
+                        msgContext.setProperty(
+                            MessageContext.CHARACTER_SET_ENCODING,
+                            MessageContext.DEFAULT_CHAR_SET_ENCODING);
+                    } else {
+                        //get the type of char encoding
+                        String charSetEnc = getCharSetEncoding(contentType);
+                        xmlreader =
+                            XMLInputFactory
+                                .newInstance()
+                                .createXMLStreamReader(
+                                in,
+                                charSetEnc);
+
+                        //Setting the value in msgCtx
+                        msgContext.setProperty(
+                            MessageContext.CHARACTER_SET_ENCODING,
+                            charSetEnc);
+
+                    }
+                    if (contentType
+                        .indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
+                        > -1) {
+                        soap11 = false;
+                        //it is SOAP 1.2
+                        builder =
+                            new StAXSOAPModelBuilder(
+                                xmlreader,
+                                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+                        envelope = (SOAPEnvelope) builder.getDocumentElement();
+                    } else if (
+                        contentType.indexOf(
+                            SOAP11Constants.SOAP_11_CONTENT_TYPE)
+                            > -1) {
+                        soap11 = true;
+                        //it is SOAP 1.1
+
+//                            msgContext.getProperty(
+//                                Constants.Configuration.ENABLE_REST);
+                        /**
+                         * Configuration via Deployment
+                         */
+
+                        Parameter enable  = msgContext.getParameter(Constants.Configuration.ENABLE_REST);
+
+                        if ((soapActionHeader == null
+                                || soapActionHeader.length() == 0)
+                                && enable != null) {
+                            if (Constants.VALUE_TRUE
+                                    .equals(enable.getValue())) {
+                                //If the content Type is text/xml (BTW which is the SOAP 1.1 Content type ) and
+                                //the SOAP Action is absent it is rest !!
+                                msgContext.setDoingREST(true);
+
+                                SOAPFactory soapFactory = new SOAP11Factory();
+                                builder = new StAXOMBuilder(xmlreader);
+                                builder.setOmbuilderFactory(soapFactory);
+                                envelope = soapFactory.getDefaultEnvelope();
+                                envelope.getBody().addChild(
+                                        builder.getDocumentElement());
+                            }
+                        } else {
+                            builder =
+                                new StAXSOAPModelBuilder(
+                                    xmlreader,
+                                    SOAP11Constants
+                                        .SOAP_ENVELOPE_NAMESPACE_URI);
+                            envelope =
+                                (SOAPEnvelope) builder.getDocumentElement();
+                        }
+                    }
+
+                }
+
+            }
+
+            String charsetEncoding = builder.getDocument().getCharsetEncoding();
+            if(charsetEncoding != null && !"".equals(charsetEncoding) &&
+                    !((String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING))
+                            .equalsIgnoreCase(charsetEncoding)){
+                String faultCode;
+                if(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelope.getNamespace().getName())){
+                   faultCode = SOAP12Constants.FAULT_CODE_SENDER;
+                }else {
+                    faultCode = SOAP11Constants.FAULT_CODE_SENDER;
+                }
+                throw new AxisFault("Character Set Encoding from " +
+                        "transport information do not match with " +
+                        "character set encoding in the received SOAP message", faultCode);
+            }
+
+            /**
+             * setting the postinterface...
+             */
+            msgContext.setEnvelope(envelope);
+            AxisEngine axisEngine = new AxisEngine(configurationContext);
+            SynapseEngine synapseEngine = new SynapseEngine();
+            /**
+             * inversion of control
+             */
+            synapseEngine.setAxisEngine(axisEngine);
+            /**
+             * call for the SynapseEngine, which is the wrapper of AxisEngine
+             * Thus, making Synapse to wrap the Axis2
+             */
+
+            synapseEngine.excecuite(msgContext);
+
+        } catch (SOAPProcessingException e) {
+            throw new AxisFault(e);
+
+        } catch (AxisFault e) {
+            //rethrow
+            throw e;
+        } catch (OMException e) {
+            throw new AxisFault(e);
+        } catch (XMLStreamException e) {
+            throw new AxisFault(e);
+        } catch (FactoryConfigurationError e) {
+            throw new AxisFault(e);
+        } catch (UnsupportedEncodingException e) {
+            throw new AxisFault(e);
+        } finally {
+            if (msgContext.getEnvelope() == null && !soap11) {
+                msgContext.setEnvelope(
+                    new SOAP12Factory().createSOAPEnvelope());
+            }
+
+        }
+    }
+
+    /**
+     * Extracts and returns the character set encoding from the
+     * Content-type header
+     * Example:
+     * Content-Type: text/xml; charset=utf-8
+     * @param contentType
+     */
+    private static String getCharSetEncoding(String contentType) {
+        int index = contentType.indexOf(HTTPConstants.CHAR_SET_ENCODING);
+        if(index == -1) { //Charset encoding not found in the contect-type header
+            //Using the default UTF-8
+            return MessageContext.DEFAULT_CHAR_SET_ENCODING;
+        }
+
+        //If there are spaces around the '=' sign
+        int indexOfEq = contentType.indexOf("=", index);
+        //There can be situations where "charset" is not the last parameter of the Content-Type header
+        int indexOfSemiColon = contentType.indexOf(";", indexOfEq);
+        String value;
+        if (indexOfSemiColon > 0) {
+            value = (contentType.substring(indexOfEq + 1, indexOfSemiColon));
+        } else {
+            value = (contentType.substring(indexOfEq + 1, contentType.length()))
+                    .trim();
+        }
+
+        //There might be "" around the value - if so remove them
+        value = value.replaceAll("\"", "");
+
+        if("null".equalsIgnoreCase(value)){
+            return null;
+        }
+
+        return value.trim();
+
+    }
+
+
+    public static SOAPEnvelope createEnvelopeFromGetRequest(
+        String requestUrl,
+        Map map) {
+        String[] values =
+            Utils.parseRequestURLForServiceAndOperation(requestUrl);
+
+        if (values[1] != null && values[0] != null) {
+            String operation = values[1];
+            SOAPFactory soapFactory = new SOAP11Factory();
+            SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
+
+            OMNamespace omNs =
+                soapFactory.createOMNamespace(values[0], "services");
+            OMNamespace defualtNs = new OMNamespaceImpl("", null);
+
+            OMElement opElement = soapFactory.createOMElement(operation, omNs);
+
+            Iterator it = map.keySet().iterator();
+            while (it.hasNext()) {
+                String name = (String) it.next();
+                String value = (String) map.get(name);
+                OMElement omEle = soapFactory.createOMElement(name, defualtNs);
+                omEle.setText(value);
+                opElement.addChild(omEle);
+            }
+
+            envelope.getBody().addChild(opElement);
+            return envelope;
+        } else {
+            return null;
+        }
+    }
+
+    public static StAXBuilder selectBuilderForMIME(
+        MessageContext msgContext,
+        InputStream inStream,
+        String contentTypeString)
+        throws OMException,
+            XMLStreamException, FactoryConfigurationError,
+            UnsupportedEncodingException {
+        StAXBuilder builder = null;
+
+
+        Parameter parameter_cache_attachment = msgContext.getParameter(
+                Constants.Configuration.CACHE_ATTACHMENTS);
+         boolean fileCacheForAttachments ;
+        if(parameter_cache_attachment == null){
+            fileCacheForAttachments = false;
+        }  else {
+           fileCacheForAttachments =
+            (Constants
+                .VALUE_TRUE
+                .equals(
+                    parameter_cache_attachment.getValue()));
+        }
+        String attachmentRepoDir = null;
+        String attachmentSizeThreshold = null;
+        Parameter parameter;
+        if (fileCacheForAttachments) {
+            parameter = msgContext.getParameter(Constants.Configuration.ATTACHMENT_TEMP_DIR);
+            attachmentRepoDir = parameter==null?"":parameter.getValue().toString();
+
+            parameter = msgContext
+                    .getParameter(Constants.Configuration.FILE_SIZE_THRESHOLD);
+            attachmentSizeThreshold = parameter==null?"":parameter.getValue().toString();
+        }
+
+        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString,
+                fileCacheForAttachments, attachmentRepoDir,attachmentSizeThreshold);
+
+        String charSetEncoding = getCharSetEncoding(mimeHelper.getSOAPPartContentType());
+        XMLStreamReader reader;
+        if(charSetEncoding == null || "null".equalsIgnoreCase(charSetEncoding)){
+             reader = XMLInputFactory.newInstance()
+                .createXMLStreamReader(
+                        new BufferedReader(new InputStreamReader(mimeHelper
+                                .getSOAPPartInputStream(),
+                                charSetEncoding)));
+            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, charSetEncoding);
+
+        }else {
+            reader = XMLInputFactory.newInstance()
+                .createXMLStreamReader(
+                        new BufferedReader(new InputStreamReader(mimeHelper
+                                .getSOAPPartInputStream())));
+            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, MessageContext.UTF_8);
+
+        }
+
+
+        /*
+		 * put a reference to Attachments in to the message context
+		 */
+        msgContext.setProperty(MTOMConstants.ATTACHMENTS, mimeHelper);
+        if (mimeHelper.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
+            /*
+             * Creates the MTOM specific MTOMStAXSOAPModelBuilder
+             */
+            builder =
+                new MTOMStAXSOAPModelBuilder(
+                    reader,
+                    mimeHelper,
+                    null);
+        } else if (
+            mimeHelper.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
+            builder =
+                new StAXSOAPModelBuilder(
+                    reader,
+                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        }
+        return builder;
+    }
+
+    public static boolean checkEnvelopeForOptimise(SOAPEnvelope envelope) {
+        return isOptimised(envelope);
+    }
+
+    private static boolean isOptimised(OMElement element) {
+        Iterator childrenIter = element.getChildren();
+        boolean isOptimized = false;
+        while (childrenIter.hasNext() && !isOptimized) {
+            OMNode node = (OMNode) childrenIter.next();
+            if (OMNode.TEXT_NODE == node.getType()
+                && ((OMText) node).isOptimized()) {
+                isOptimized = true;
+            } else if (OMNode.ELEMENT_NODE == node.getType()) {
+                isOptimized = isOptimised((OMElement) node);
+            }
+        }
+        return isOptimized;
+    }
+
+    public static boolean doWriteMTOM(MessageContext msgContext) {
+        boolean enableMTOM = false;
+        if (msgContext.getParameter(Constants.Configuration.ENABLE_MTOM)
+            != null) {
+            enableMTOM =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getParameter(
+                        Constants.Configuration.ENABLE_MTOM).getValue());
+        } else if(msgContext.getProperty(Constants.Configuration.ENABLE_MTOM) != null) {
+            enableMTOM =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getProperty(
+                        Constants.Configuration.ENABLE_MTOM));
+        }
+        boolean envelopeContainsOptimise =
+            HTTPTransportUtils.checkEnvelopeForOptimise(
+                msgContext.getEnvelope());
+        boolean doMTOM = enableMTOM && envelopeContainsOptimise;
+        msgContext.setDoingMTOM(doMTOM);
+        return doMTOM;
+    }
+
+    public static boolean isDoingREST(MessageContext msgContext) {
+        boolean enableREST = false;
+        if (msgContext.getParameter(Constants.Configuration.ENABLE_REST)
+            != null) {
+            enableREST =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getParameter(
+                        Constants.Configuration.ENABLE_REST).getValue());
+        } else if(msgContext.getProperty(Constants.Configuration.ENABLE_REST) != null) {
+            enableREST =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getProperty(
+                        Constants.Configuration.ENABLE_REST));
+        }
+        msgContext.setDoingREST(enableREST);
+        return enableREST;
+
+    }
+
+    public static boolean isDoingRESTThoughPost(MessageContext msgContext) {
+        boolean restThroughPost = true;
+
+        if (msgContext.getParameter(Constants.Configuration.ENABLE_REST_THROUGH_GET)
+            != null) {
+            restThroughPost =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getParameter(
+                        Constants.Configuration.ENABLE_REST_THROUGH_GET).getValue());
+            restThroughPost = false;
+        } else if(msgContext.getProperty(Constants.Configuration.ENABLE_REST_THROUGH_GET) != null) {
+            restThroughPost =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getProperty(
+                        Constants.Configuration.ENABLE_REST_THROUGH_GET));
+            restThroughPost =false;
+        }
+        msgContext.setRestThroughPOST(!restThroughPost);
+        return restThroughPost;
+
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/dispatchers/SynapseBaseDispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/dispatchers/SynapseBaseDispatcher.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/dispatchers/SynapseBaseDispatcher.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/dispatchers/SynapseBaseDispatcher.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,127 @@
+package org.apache.synapse.dispatchers;
+
+import org.apache.axis2.engine.AbstractDispatcher;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.description.OperationDescription;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.rules.SynapseRuleEngine;
+import org.apache.synapse.rules.RuleBean;
+import org.apache.synapse.SynapseConstants;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+
+/**
+ * This is place where all the dispatching will take place, all the ruling will be done
+ */
+public class SynapseBaseDispatcher extends AbstractDispatcher {
+
+    public static final QName NAME = new QName("http://synapse.ws.apache.org",
+            "SynapseBaseDispatcher");
+
+    protected String serviceName;
+    protected QName operationName;
+
+
+    /**
+     * Rules which is going to be populated via services.xml
+     */
+    protected SynapseRuleEngine ruleEngine;
+
+    /**
+     * to keep the state
+     */
+    private int synapseState = 0;
+
+    public SynapseBaseDispatcher() {
+        ruleEngine = new SynapseRuleEngine();
+    }
+
+    public void initDispatcher() {
+        init(new HandlerDescription(NAME));
+    }
+
+    public ServiceDescription findService(MessageContext messageContext)
+            throws AxisFault {
+
+        /**
+         * testing the rule searching.
+         *
+         */
+        Object ruleObj = messageContext
+                .getProperty(SynapseConstants.RULE_STATE);
+        if (ruleObj == null) {
+            ruleEngine.ruleConfiguration(messageContext);
+            messageContext.setProperty(SynapseConstants.RULE_STATE, ruleEngine);
+        }
+
+        /**
+         * here "*" all will be handled.
+         */
+        operationName = new QName(this.ruleEngine.getOperationName());
+
+        /**
+         * mediator selection
+         */
+
+        Integer state = (Integer) messageContext
+                .getProperty(SynapseConstants.SYNAPSE_STATE);
+        if (state != null) {
+            synapseState = state.intValue();
+        } else {
+            synapseState = 1;
+        }
+
+        String key = null;
+        if (synapseState == 1) {
+            key = mediatorType(messageContext, ruleEngine, synapseState);
+        } else {
+            key = mediatorType(messageContext, ruleEngine, synapseState);
+        }
+        serviceName = key;
+
+        AxisConfiguration registry =
+                messageContext.getSystemContext()
+                        .getAxisConfiguration();
+        return registry.getService(serviceName);
+
+
+    }
+
+    public OperationDescription findOperation(
+            ServiceDescription serviceDescription,
+            MessageContext messageContext) throws AxisFault {
+        OperationDescription operationDis;
+        if (operationName != null) {
+            operationDis = serviceDescription.getOperation(operationName);
+            return operationDis;
+        }
+        return null;
+    }
+
+    private String mediatorType(MessageContext messageContext,
+                                SynapseRuleEngine ruleEngine,
+                                int synapseState) {
+        ArrayList ruleArrayList = ruleEngine.getArrayList();
+        String key = null;
+        Integer state = null;
+        if (synapseState <= ruleArrayList.size()) {
+            String rule = (String) ruleArrayList.get(synapseState - 1);
+            if (synapseState == ruleArrayList.size()) {
+                messageContext.setProperty(SynapseConstants.VALUE_FALSE,
+                        new Boolean(false));
+            } else {
+                state = new Integer(++synapseState);
+                messageContext
+                        .setProperty(SynapseConstants.SYNAPSE_STATE, state);
+            }
+
+            key = rule;
+        }
+        return key;
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/engine/SynapseEngine.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/engine/SynapseEngine.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/engine/SynapseEngine.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/engine/SynapseEngine.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,85 @@
+package org.apache.synapse.engine;
+
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.AxisFault;
+import org.apache.synapse.SynapseConstants;
+
+import java.util.LinkedList;
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 12, 2005
+ * Time: 12:31:35 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SynapseEngine {
+    private AxisEngine axisEngine;
+
+    public AxisEngine getAxisEngine() {
+        return axisEngine;
+    }
+
+    public void setAxisEngine(AxisEngine axisEngine) {
+        this.axisEngine = axisEngine;
+    }
+
+    public void excecuite(MessageContext messageContext) throws AxisFault {
+
+        if (axisEngine != null) {
+            if (messageContext.getEnvelope().getBody().hasFault()) {
+                axisEngine.receiveFault(messageContext);
+            } else {
+                axisEngine.receive(messageContext);
+            }
+            /**
+             * Once the control return we would decide how to do the rule maching next
+             */
+
+            /**
+             * recursivly check for more rules.
+             */
+
+            moreRules(messageContext);
+
+        }
+
+
+    }
+
+    private void moreRules(MessageContext returnMsgCtx)
+            throws AxisFault {
+
+        Boolean returnValue = (Boolean) returnMsgCtx
+                .getProperty(SynapseConstants.MEDEATOT_STATE);
+        if (!returnValue.booleanValue()) {
+            return ;
+        } else {
+            MessageContext newContext = new MessageContext(
+                    returnMsgCtx.getSystemContext());
+            newContext.setProperty(SynapseConstants.MEDEATOT_STATE,
+                    returnMsgCtx.getProperty(SynapseConstants.MEDEATOT_STATE));
+
+            newContext.setProperty(SynapseConstants.SYNAPSE_STATE,
+                    returnMsgCtx.getProperty(SynapseConstants.SYNAPSE_STATE));
+            newContext.setProperty(SynapseConstants.VALUE_FALSE,
+                    returnMsgCtx.getProperty(SynapseConstants.VALUE_FALSE));
+            newContext.setProperty(SynapseConstants.RULE_STATE,
+                    returnMsgCtx.getProperty(SynapseConstants.RULE_STATE));
+            newContext.setServerSide(true);
+            newContext.setEnvelope(returnMsgCtx.getEnvelope());
+            newContext.setServiceContextID(returnMsgCtx.getServiceContextID());
+            newContext.setWSAAction(returnMsgCtx.getWSAAction());
+            newContext.setSoapAction(returnMsgCtx.getSoapAction());
+            axisEngine.receive(newContext);
+            moreRules(newContext);
+            return ;
+        }
+    }
+
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingHandler.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingHandler.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingHandler.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingHandler.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,20 @@
+package org.apache.synapse.handlers;
+
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 6:21:19 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class LoggingHandler extends AbstractHandler implements Handler {
+    public void invoke(MessageContext messageContext) throws AxisFault {
+        //todo dosmoething..
+        System.out.println("I'm in the logging handler....\n");
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingModule.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingModule.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingModule.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/LoggingModule.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,22 @@
+package org.apache.synapse.handlers;
+
+import org.apache.axis2.modules.Module;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.AxisFault;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 6:19:41 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class LoggingModule implements Module {
+    public void init(AxisConfiguration axisConfiguration) throws AxisFault {
+        System.out.println("I'm in the Logging Module");
+    }
+
+    public void shutdown(AxisConfiguration axisConfiguration) throws AxisFault {
+        
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/META-INF/module.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/META-INF/module.xml?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/META-INF/module.xml (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/handlers/META-INF/module.xml Thu Oct 13 22:24:23 2005
@@ -0,0 +1,7 @@
+<module name="log" class="org.apache.synapse.handlers.LoggingModule">
+    <inflow>
+        <handler name="IFLog" class="org.apache.synapse.handlers.LoggingHandler">
+            <order phase="log"/>
+        </handler>
+    </inflow>
+</module>
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/services.xml?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/services.xml (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/services.xml Thu Oct 13 22:24:23 2005
@@ -0,0 +1,39 @@
+<serviceGroup>
+
+    <description>
+        services.xml taken as the "xml formatted" rule provider.
+    </description>
+
+    <service name="Log_1">
+        <!-- selecting the mediator; so ServiceClass is the Mediator -->
+        <parameter name="ServiceClass" locked="false">
+            org.apache.synapse.mediators.SimpleDummyMediator</parameter>
+
+        <!-- this is the mock service, which is going to be called-->
+        <!-- because service level message receivers are not allowed to add -->
+
+        <operation name="receiver">
+            <messageReceiver
+                    class="org.apache.synapse.receivers.SynapseMessageReceiver"/>
+        </operation>
+    </service>
+
+
+    <service name="Log">
+        <!-- selecting the mediator; so ServiceClass is the Mediator -->
+        <parameter name="ServiceClass" locked="false">
+            org.apache.synapse.mediators.SimpleLoggingMediator</parameter>
+
+        <!-- this is the mock service, which is going to be called-->
+        <!-- because service level message receivers are not allowed to add -->
+
+        <operation name="receiver">
+            <messageReceiver
+                    class="org.apache.synapse.receivers.SynapseMessageReceiver"/>
+        </operation>
+    </service>
+
+
+
+
+</serviceGroup>
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/synapse.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/synapse.xml?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/synapse.xml (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/META-INF/synapse.xml Thu Oct 13 22:24:23 2005
@@ -0,0 +1,22 @@
+<rules>
+    <rule>
+        <condition>*</condition>
+        <mediator>Log_1</mediator>
+    </rule>
+    <rule>
+        <condition>*</condition>
+        <mediator>Log</mediator>
+    </rule>
+    <rule>
+        <condition>*</condition>
+        <mediator>Log</mediator>
+    </rule>
+    <rule>
+        <condition>*</condition>
+        <mediator>Log_1</mediator>
+    </rule>
+    <rule>
+        <condition>*</condition>
+        <mediator>Log_1</mediator>
+    </rule>
+</rules>
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/Mediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/Mediator.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/Mediator.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/Mediator.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,15 @@
+package org.apache.synapse.mediators;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 12, 2005
+ * Time: 10:30:41 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface Mediator {
+    public boolean mediate(MessageContext messageContext) throws AxisFault;
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleDummyMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleDummyMediator.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleDummyMediator.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleDummyMediator.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,32 @@
+package org.apache.synapse.mediators;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.rules.SynapseRuleEngine;
+import org.apache.synapse.rules.RuleBean;
+
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 12, 2005
+ * Time: 11:40:48 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SimpleDummyMediator implements Mediator {
+
+    public boolean mediate(MessageContext messageContext) throws AxisFault {
+
+        System.out.println(
+                "you are in the dummy mediator..logging facility ... now\n");
+        Boolean retbool = (Boolean) messageContext
+                .getProperty(SynapseConstants.VALUE_FALSE);
+        if (retbool != null) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleLoggingMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleLoggingMediator.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleLoggingMediator.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/mediators/SimpleLoggingMediator.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,33 @@
+package org.apache.synapse.mediators;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.synapse.SynapseConstants;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 5:34:01 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SimpleLoggingMediator implements Mediator{
+    /**
+     * Do Some mediation and return true/false
+     * false means, mediator consumes the message
+     * ture means, medator return for that message, to deal with another Rule
+     * @param msgContext
+     * @return Boolean
+     */
+    public boolean mediate(MessageContext msgContext) throws AxisFault {
+        System.out.println("i'm doing the logging mediation...now");
+        Boolean retbool = (Boolean) msgContext
+                .getProperty(SynapseConstants.VALUE_FALSE);
+        if (retbool != null) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/DependencyManager.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/DependencyManager.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/DependencyManager.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/DependencyManager.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,50 @@
+package org.apache.synapse.receivers;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 5:44:52 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class DependencyManager {
+     private final static String MESSAGE_CONTEXT_MEDIATE_INJECTION_METHOD = "mediate";
+
+    public static Boolean mediatorBusinessLogicProvider(Object obj,
+                                                      MessageContext msgctx)
+            throws AxisFault {
+        Boolean returnValue = null;
+        try {
+            Class classToLoad = obj.getClass();
+            Method[] methods = classToLoad.getMethods();
+
+            for (int i = 0; i < methods.length; i++) {
+                if (MESSAGE_CONTEXT_MEDIATE_INJECTION_METHOD.equals(
+                        methods[i].getName()) &&
+                        methods[i].getParameterTypes().length == 1 &&
+                        methods[i].getParameterTypes()[0] ==
+                                MessageContext.class) {
+                    returnValue = (Boolean)methods[i].invoke(obj, new Object[]{msgctx});
+                }
+            }
+            /**
+             * return the mediator state
+             */
+            return returnValue;
+        } catch (SecurityException e) {
+            throw new AxisFault(e);
+        } catch (IllegalArgumentException e) {
+            throw new AxisFault(e);
+        } catch (IllegalAccessException e) {
+            throw new AxisFault(e);
+        } catch (InvocationTargetException e) {
+            throw new AxisFault(e);
+        }
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseAbstractMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseAbstractMessageReceiver.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseAbstractMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseAbstractMessageReceiver.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,24 @@
+package org.apache.synapse.receivers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.receivers.AbstractMessageReceiver;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 5:54:59 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public abstract class SynapseAbstractMessageReceiver extends AbstractMessageReceiver {
+    protected Log log = LogFactory.getLog(getClass());
+
+    public abstract void invokeBusinessLogic(MessageContext inMessage) throws AxisFault;
+
+    public final void receive(final MessageContext messgeCtx) throws AxisFault {
+        invokeBusinessLogic(messgeCtx);
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseMessageReceiver.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/receivers/SynapseMessageReceiver.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,74 @@
+package org.apache.synapse.receivers;
+
+import org.apache.axis2.engine.*;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.description.OperationDescription;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.wsdl.WSDLService;
+import org.apache.synapse.SynapseConstants;
+
+import java.lang.reflect.Method;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 5:54:04 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SynapseMessageReceiver extends SynapseAbstractMessageReceiver implements MessageReceiver {
+
+   /**
+     * Field log
+     */
+    protected Log log = LogFactory.getLog(getClass());
+
+    /**
+     * Field scope
+     */
+    private String scope;
+
+    /**
+     * Field method
+     */
+    private Method method;
+
+    /**
+     * Field classLoader
+     */
+    private ClassLoader classLoader;
+
+    /**
+     * Constructor RawXMLProvider
+     */
+    public SynapseMessageReceiver() {
+        scope = Constants.APPLICATION_SCOPE;
+    }
+
+    public void invokeBusinessLogic(MessageContext msgContext)
+            throws AxisFault {
+        try {
+
+            // get the implementation class for the Web Service
+            Object obj = getTheImplementationObject(msgContext);
+
+            
+            /**
+             * Injecting messageContext for medaite method
+             * Will not be on use in the M1
+             */
+            Boolean mediatorState = DependencyManager.mediatorBusinessLogicProvider(obj, msgContext);
+            msgContext.setProperty(SynapseConstants.MEDEATOT_STATE,mediatorState);
+
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/RuleBean.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/RuleBean.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/RuleBean.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/RuleBean.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,28 @@
+package org.apache.synapse.rules;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 11, 2005
+ * Time: 4:42:11 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class RuleBean {
+    private String condition;
+    private String mediatation;
+
+    public void setCondition(String condition) {
+        this.condition = condition;
+    }
+    public void setMediate(String mediatation) {
+        this.mediatation = mediatation;
+    }
+
+    public String getCondition(){
+        return condition;
+    }
+    public String getMediatation() {
+        return mediatation;   
+    }
+
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleEngine.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleEngine.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleEngine.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleEngine.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,74 @@
+package org.apache.synapse.rules;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.AxisFault;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 10, 2005
+ * Time: 4:54:13 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SynapseRuleEngine {
+
+    private String operationName = "receiver";
+
+    private SynapseRuleReader ruleReader;
+
+    private ArrayList ruleList;
+
+    public SynapseRuleEngine() {
+        ruleReader = new SynapseRuleReader();
+        ruleList = new ArrayList();
+    }
+
+    public void ruleConfiguration(MessageContext msgCtx) throws AxisFault {
+        AxisConfiguration registry = msgCtx.getSystemContext()
+                .getAxisConfiguration();
+
+        HashMap serviceMap = registry.getServices();
+
+        ruleReader.populateRules(registry);
+
+        Iterator ite = serviceMap.entrySet().iterator();
+        Map.Entry entry = null;
+        String key = null;
+        while (ite.hasNext()) {
+            entry = (Map.Entry) ite.next();
+            key = (String) entry.getKey();
+
+            Iterator iterator = ruleReader.getRulesIterator();
+
+            while (iterator.hasNext()) {
+                RuleBean bean = (RuleBean) iterator.next();
+                /**
+                 * Rulling logic goes here
+                 */
+
+                if (bean.getMediatation().equalsIgnoreCase(key)) {
+                    this.ruleList.add(key);
+                }
+            }
+
+        }
+    }
+
+    public void setOperationName(String operationName) {
+        this.operationName = operationName;
+    }
+
+    public String getOperationName() {
+        return operationName;
+    }    
+
+    public ArrayList getArrayList() {
+        return ruleList;
+    }
+}

Added: incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleReader.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleReader.java?rev=321012&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleReader.java (added)
+++ incubator/synapse/trunk/scratch/saminda/src/org/apache/synapse/rules/SynapseRuleReader.java Thu Oct 13 22:24:23 2005
@@ -0,0 +1,121 @@
+package org.apache.synapse.rules;
+
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ParameterImpl;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.synapse.SynapseConstants;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.io.*;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipEntry;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: saminda
+ * Date: Oct 11, 2005
+ * Time: 3:31:07 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SynapseRuleReader {
+    public static final String RULE_XML = "META-INF/synapse.xml";
+    private ArrayList ruleList;
+
+    public SynapseRuleReader() {
+        ruleList = new ArrayList();
+    }
+
+    private OMElement readRules(ServiceDescription serviceDescription)
+            throws AxisFault {
+
+        try {
+            InputStream in = serviceDescription.getClassLoader()
+                    .getResourceAsStream(RULE_XML);
+            if (in == null) {
+                return null;
+            } else {
+                XMLStreamReader parser = XMLInputFactory.newInstance()
+                        .createXMLStreamReader(in);
+                OMFactory fac = OMAbstractFactory.getOMFactory();
+                StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac, parser);
+                OMElement element = staxOMBuilder.getDocumentElement();
+                element.build();
+                return element;
+            }
+//
+
+        } catch (XMLStreamException e) {
+            throw new AxisFault(e);
+        }
+    }
+
+    public void populateRules(AxisConfiguration registry) throws
+            AxisFault {
+        boolean beanReader = false;
+        HashMap serviceMap = registry.getServices();
+        try {
+            Iterator ite = serviceMap.entrySet().iterator();
+            Map.Entry entry = null;
+            String service = null;
+            while (ite.hasNext()) {
+                entry = (Map.Entry) ite.next();
+                service = (String) entry.getKey();
+                if (!beanReader) {
+                    ServiceDescription serviceDes = registry
+                            .getService(service);
+                    OMElement rules = readRules(serviceDes);
+                    if (rules != null) {
+                        beanReader = this.fillBean(rules);
+                    }
+                }
+            }
+        } catch (AxisFault axisFault) {
+            throw new AxisFault(axisFault);
+        }
+    }
+
+    private boolean fillBean(OMElement ele) {
+        Iterator children = ele.getChildElements();
+        while (children.hasNext()) {
+            OMElement rule = (OMElement) children.next();
+            OMElement condition = null;
+            OMElement mediation = null;
+            Iterator childite = rule.getChildElements();
+            while (childite.hasNext()) {
+                OMElement childele = (OMElement) childite.next();
+                if (childele.getLocalName().equalsIgnoreCase(
+                        SynapseConstants.SynapseRuleReader.CONDITION)) {
+                    condition = childele;
+                }
+                if (childele.getLocalName().equalsIgnoreCase(
+                        SynapseConstants.SynapseRuleReader.MEDIATOR)) {
+                    mediation = childele;
+                }
+            }
+            RuleBean ruleBean = new RuleBean();
+            if (condition != null && mediation != null) {
+                ruleBean.setCondition(condition.getText());
+                ruleBean.setMediate(mediation.getText());
+                ruleList.add(ruleBean);
+            }
+        }
+        return true;
+    }
+
+    public Iterator getRulesIterator() {
+        return ruleList.iterator();
+    }
+
+}



Mime
View raw message