You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2006/02/15 08:11:37 UTC

svn commit: r377953 [7/9] - in /incubator/synapse/trunk/scratch/synase-multimodules: ./ bin/ etc/ modules/ modules/core/ modules/core/conf/ modules/core/src/ modules/core/src/org/ modules/core/src/org/apache/ modules/core/src/org/apache/synapse/ module...

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/project.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/project.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/project.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/project.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+    <name>Apache Synapse - Extensions</name>
+    <id>synapse-extensions</id>
+    <groupId>synapse</groupId>
+
+    <dependencies>
+        <dependency>
+            <groupId>synapse</groupId>
+            <artifactId>synapse-core</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>synapse</groupId>
+            <artifactId>synapse-mediators</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>synapse</groupId>
+            <artifactId>synapse-sample</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <!-- external JARs -->
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-core</artifactId>
+            <version>${axis2.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons.logging.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>${commons.httpclient.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-discovery</groupId>
+            <artifactId>commons-discovery</artifactId>
+            <version>${commons.discovery.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>${commons.codec.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>${log4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>${stax.impl.groupid}</groupId>
+            <artifactId>${stax.impl.artifactid}</artifactId>
+            <version>${stax.impl.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>${stax.api.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>axis</groupId>
+            <artifactId>axis-wsdl4j</artifactId>
+            <version>${axis.wsdl4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-javamail</artifactId>
+            <version>${geronimo.spec.javamail.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-activation</artifactId>
+            <version>${geronimo.spec.activation.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-jms</artifactId>
+            <version>${geronimo.spec.jms.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <properties>
+                <classloader>root</classloader>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jaxen</groupId>
+            <artifactId>jaxen</artifactId>
+            <version>${jaxen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>xalan</groupId>
+            <artifactId>xalan</artifactId>
+            <version>2.6.0</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>policy</artifactId>
+            <version>${policy.version}</version>
+            <properties>
+                <module>false</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>axiom</artifactId>
+            <version>${axiom.version}</version>
+            <properties>
+                <module>false</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring</artifactId>
+            <version>${spring.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+    </dependencies>
+</project>
+

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator Tue Feb 14 23:11:24 2006
@@ -0,0 +1 @@
+org.apache.synapse.processors.mediatortypes.spring.SpringMediatorProcessorConfigurator
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,56 @@
+package org.apache.synapse.processors.mediatortypes.spring;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.api.EnvironmentAware;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.processors.AbstractProcessor;
+import org.springframework.context.support.GenericApplicationContext;
+
+/**
+ *
+ * @see org.apache.synapse.processors.builtin.xslt.XSLTProcessorConfigurator
+ * <p> This class is the class that "plugs" Spring-based mediators into Synapse. 
+ * <p> A spring based mediator is any object that implements mediator and can be instantiated by
+ * Spring (see www.springframework.org). The mediator definition is set up using the 
+ *  SpringMediatorProcessorConfigurator class.
+ *  
+ * This class simply has a Context property which is set with a Spring GenericApplicationContext and 
+ * a BeanName property, which is set with the name of the bean  
+ *
+ */
+public class SpringMediatorProcessor extends AbstractProcessor {
+	
+	private GenericApplicationContext ctx = null;
+
+	private String beanName = null;
+
+	public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+		Mediator m = (Mediator) getContext().getBean(getBeanName());
+		if (EnvironmentAware.class.isAssignableFrom(m.getClass())) {
+			((EnvironmentAware) m).setSynapseEnvironment(se);
+		}
+		return m.mediate(smc);
+
+	}
+
+	
+
+	public void setContext(GenericApplicationContext ctx) {
+		this.ctx = ctx;
+	}
+
+	public GenericApplicationContext getContext() {
+		return ctx;
+	}
+
+	public void setBeanName(String beanName) {
+		this.beanName = beanName;
+	}
+
+	public String getBeanName() {
+		return beanName;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,92 @@
+package org.apache.synapse.processors.mediatortypes.spring;
+
+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.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+
+
+
+import org.apache.synapse.xml.AbstractProcessorConfigurator;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ByteArrayResource;
+
+
+
+/**
+ *
+ * @see org.apache.synapse.processors.builtin.xslt.XSLTProcessor
+ * <p> This class configures the Spring mediator type. 
+ * <p> The tag looks like this
+ * <xmp>
+ * <spring:springmediator name="x" bean="beanname">
+ * 		<beans> 
+ * 			spring config here
+ *  	</beans>
+ * </xmp>
+ * The spring config is inlined (future work to let it be pointed to with an attribute). The bean attribute identifies
+ * the bean inside the spring assembly to be used. 
+ */
+public class SpringMediatorProcessorConfigurator extends AbstractProcessorConfigurator {
+	private static final QName tagName = new QName(Constants.SYNAPSE_NAMESPACE+"/spring", "springmediator");
+	public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+		SpringMediatorProcessor smp = new SpringMediatorProcessor();
+		super.setNameOnProcessor(se,el,smp);
+		
+		OMAttribute bean = el.getAttribute(new QName("bean"));
+		if (bean == null) throw new SynapseException("missing bean attribute on "+el.toString());
+		
+		smp.setBeanName(bean.getAttributeValue().trim());
+		
+		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(se.getClassLoader());
+		ctx.refresh();
+		smp.setContext(ctx);
+		return smp;
+		
+		
+		
+	}
+
+	public QName getTagQName() {
+		
+		return tagName;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/maven.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/maven.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/maven.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="jar"
+         xmlns:j="jelly:core"
+         xmlns:u="jelly:util"
+         xmlns:deploy="deploy"
+         xmlns:ant="jelly:ant"
+         xmlns:maven="jelly:maven"
+         xmlns:define="jelly:define">
+
+    <j:set var="dist.name" value="${pom.artifactId}-${pom.currentVersion}"/>
+    <!--<j:set var="dist.dir" value="target/dist"/>-->
+    <j:set var="mediators.dir" value="target/mediators"/>
+
+    <postGoal name="test:test">
+        <j:if test="${context.getVariable('maven.test.skip') != 'true'}">
+            <attainGoal name="toDistBin"/>
+        </j:if>
+    </postGoal>
+
+
+    <goal name="mediators">
+        <mkdir dir="target/mediators"/>
+        <echo message="----------------Creating DeprecationMediator aar----------------"/>
+        <mkdir dir="target/deprecation/META-INF"/>
+        <copy file="src/org/apache/synapse/mediators/deprecation/META-INF/services.xml"
+              tofile="target/deprecation/META-INF/services.xml"/>
+        <copy file="src/org/apache/synapse/mediators/deprecation/META-INF/deprecation.xml"
+              tofile="target/deprecation/META-INF/deprecation.xml"/>
+
+        <ant:copy todir="target/deprecation">
+            <ant:fileset dir="target/classes">
+                <ant:include name="**/deprecation/**"/>
+                <ant:exclude name="**/deprecation/**/*.xml"/>
+            </ant:fileset>
+        </ant:copy>
+
+        <echo message="----------------Creating SLAMediator aar----------------"/>
+        <mkdir dir="target/sla/META-INF"/>
+        <copy file="src/org/apache/synapse/mediators/sla/META-INF/services.xml"
+              tofile="target/sla/META-INF/services.xml"/>
+        <copy file="src/org/apache/synapse/mediators/sla/META-INF/sla.xml"
+              tofile="target/sla/META-INF/sla.xml"/>
+
+        <ant:copy todir="target/sla">
+            <ant:fileset dir="target/classes">
+                <ant:include name="**/sla/**"/>
+                <ant:exclude name="**/sla/**/*.xml"/>
+            </ant:fileset>
+        </ant:copy>
+
+        <mkdir dir="${mediators.dir}/deprecation"/>
+        <jar jarfile="target/mediators/deprecation/DeprecationMediator.aar"
+             basedir="target/deprecation">
+            <include name="**"/>
+        </jar>
+
+        <mkdir dir="${mediators.dir}/sla"/>
+        <jar jarfile="target/mediators/sla/SLAMediator.aar"
+             basedir="target/sla">
+            <include name="**"/>
+        </jar>
+
+        <mkdir dir="${mediators.dir}/deprecation/src"/>
+        <ant:copy todir="${mediators.dir}/deprecation/src">
+            <ant:fileset dir="src">
+                <ant:include name="org/apache/synapse/**/deprecation/**"/>
+            </ant:fileset>
+            <!-- To run the sample we include StockQuoteClient in the source path-->
+            <ant:fileset dir="../samples/src">
+                <ant:include name="samples/userguide/StockQuoteClient.java"/>
+            </ant:fileset>
+        </ant:copy>
+
+        <mkdir dir="${mediators.dir}/sla/src"/>
+        <ant:copy todir="${mediators.dir}/sla/src">
+            <ant:fileset dir="src">
+                <ant:include name="org/apache/synapse/**/sla/**"/>
+            </ant:fileset>
+            <!-- To run the sample we include StockQuoteClient in the source path-->
+            <ant:fileset dir="../samples/src">
+                <ant:include name="samples/userguide/StockQuoteClient.java"/>
+            </ant:fileset>
+        </ant:copy>
+
+    </goal>
+
+    <goal name="toDistBin" prereqs="mediators">
+        <property name="bin.dist.dir"
+                  value="target/dist-bin"/>
+        <ant:mkdir dir="${bin.dist.dir}"/>
+        <ant:mkdir dir="${bin.dist.dir}/mediators"/>
+
+        <ant:copy file="scripts/deprecation_mediator/synapse.xml"
+                  tofile="${bin.dist.dir}/mediators/deprecation/synapse.xml"/>
+        <ant:copy file="scripts/deprecation_mediator/README.txt"
+                  tofile="${bin.dist.dir}/mediators/deprecation/README.txt"/>
+        <ant:copy file="scripts/deprecation_mediator/build.xml"
+                  tofile="${bin.dist.dir}/mediators/deprecation/build.xml"/>
+
+        <ant:copy file="scripts/sla_mediator/synapse.xml"
+                  tofile="${bin.dist.dir}/mediators/sla/synapse.xml"/>
+        <ant:copy file="scripts/sla_mediator/README.txt"
+                  tofile="${bin.dist.dir}/mediators/sla/README.txt"/>
+        <ant:copy file="scripts/sla_mediator/build.xml"
+                  tofile="${bin.dist.dir}/mediators/sla/build.xml"/>
+
+        <ant:copy todir="${bin.dist.dir}/mediators">
+            <ant:fileset dir="target/mediators/">
+                <include name="**"/>
+            </ant:fileset>
+        </ant:copy>
+
+        <ant:delete dir="target/mediators"/>
+        <ant:delete dir="target/deprecation"/>
+        <ant:delete dir="target/sla"/>
+    </goal>
+</project>

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.properties
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.properties?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.properties (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.properties Tue Feb 14 23:11:24 2006
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2004 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.
+# -------------------------------------------------------------------
+
+maven.multiproject.type=jar

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/project.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+
+    <name>Apache Synapse - Mediators</name>
+    <id>synapse-mediators</id>
+    <groupId>synapse</groupId>
+
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+
+    <dependencies>
+
+        <dependency>
+            <groupId>synapse</groupId>
+            <artifactId>synapse-core</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+
+
+
+        <!-- external JARs -->
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-core</artifactId>
+            <version>${axis2.version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons.logging.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>${commons.httpclient.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-discovery</groupId>
+            <artifactId>commons-discovery</artifactId>
+            <version>${commons.discovery.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>${commons.codec.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>${log4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>${stax.impl.groupid}</groupId>
+            <artifactId>${stax.impl.artifactid}</artifactId>
+            <version>${stax.impl.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>${stax.api.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>axis</groupId>
+            <artifactId>axis-wsdl4j</artifactId>
+            <version>${axis.wsdl4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-javamail</artifactId>
+            <version>${geronimo.spec.javamail.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-activation</artifactId>
+            <version>${geronimo.spec.activation.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-jms</artifactId>
+            <version>${geronimo.spec.jms.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <properties>
+                <classloader>root</classloader>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jaxen</groupId>
+            <artifactId>jaxen</artifactId>
+            <version>${jaxen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>xalan</groupId>
+            <artifactId>xalan</artifactId>
+            <version>2.6.0</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>policy</artifactId>
+            <version>${policy.version}</version>
+            <properties>
+                <module>false</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>axiom</artifactId>
+            <version>${axiom.version}</version>
+            <properties>
+                <module>false</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <nagEmailAddress>synapse-dev@ws.apache.org</nagEmailAddress>
+        <sourceDirectory>src</sourceDirectory>
+        <unitTestSourceDirectory>test</unitTestSourceDirectory>
+        <unitTest>
+            <includes>
+                <include>**/*Test.java</include>
+            </includes>
+            <!--<excludes>-->
+                <!--<exclude>**/*Test.java</exclude>-->
+            <!--</excludes>-->
+        </unitTest>
+        <!--b-->
+
+    </build>
+</project>
+

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/README.txt
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/README.txt?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/README.txt (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/README.txt Tue Feb 14 23:11:24 2006
@@ -0,0 +1,15 @@
+Running Deprecation Mediator Sample
+===================================
+
+1. Copy synapse.xml in this repository to synapse_repository in the binary distribution.
+2. Place the DeprecationMediator.aar in the synape_repository/services.
+3. Using the Ant command "ant synapse", start the stand-alone synapse server. This will be start at port 8080. 
+4. Use Ant command "ant" StockQuoteClient to run the sample. 
+ 
+You will get an answer if the system date is not between 06/09/2005:00:00 and 07/02/2006:00:00 [DD/MM/yyyy:HH:mm]
+
+The prior configuration is available at deprecation.xml, where it will located at DeprecationMediator.aar's META-INF folder. 
+
+Note : 
+The service is deprecated between these dates, i.e. it is not available or is not to be used.
+

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/build.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/build.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/build.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/build.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,74 @@
+<project name="samples" default="help">
+    <target name="help">
+        <echo>
+            This script requires Ant 1.5 or higher
+
+            usage:
+            ant -help display ant help screen
+            ant help display this message
+            ant clean delete the built directory
+
+            ant compile build the deprecation_mediator sample
+
+            ant StockQuote [Symbol] [webserviceurl] [synapseurl] {optional[repository]}
+            Use the smart client - Synapse in WS-Addressing router mode
+
+        </echo>
+    </target>
+
+    <property name="symbol" value="IBM"/>
+    <property name="url" value="http://www.webservicex.net/stockquote.asmx"/>
+    <property name="synapseurl" value="http://localhost:8080"/>
+    <property name="repository" value="../../synapse_repository"/>
+
+    <property name="class.dir" value="target/classes"/>
+
+    <path id="axis.classpath">
+        <fileset dir="../../lib">
+            <include name="*.jar"/>
+        </fileset>
+    </path>
+
+    <target name="clean">
+        <delete dir="target" quiet="true"/>
+        <delete dir="${class.dir}" quiet="true"/>
+    </target>
+
+
+    <target name="StockQuote" depends="compile">
+        <java classname="samples.userguide.StockQuoteClient"
+              classpathref="javac.classpath" fork="true">
+            <arg value="${symbol}"/>
+            <arg value="${url}"/>
+            <arg value="${synapseurl}"/>
+            <arg value="${repository}"/>
+        </java>
+    </target>
+
+    <target name="init">
+        <mkdir dir="${class.dir}"/>
+        <mkdir dir="src/ddl"/>
+
+        <path id="javac.classpath">
+            <pathelement path="${class.dir}"/>
+            <fileset dir="../../lib">
+                <include name="**/*.jar"/>
+            </fileset>
+        </path>
+    </target>
+
+    <target name="compile" depends="init" description="Compile all Java">
+        <javac srcdir="src" destdir="${class.dir}">
+            <classpath refid="javac.classpath"/>
+        </javac>
+    </target>
+
+    <target name="synapse">
+        <java classname="org.apache.axis2.transport.http.SimpleHTTPServer"
+              classpathref="axis.classpath" fork="true">
+            <arg value="../../synapse_repository"/>
+            <arg value="8080"/>
+        </java>
+    </target>
+
+</project>

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/synapse.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/synapse.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/synapse.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/deprecation_mediator/synapse.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,36 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+    <engage-addressing-in/>
+    <log/>
+
+    <!-- this matches the gateway case -->
+    <regex message-address="to" pattern="/StockQuote.*">
+        <ref ref="stockquote"/>
+    </regex>
+    <!-- this matches the virtual url case for either the proxy or ws-add case -->
+    <regex message-address="to" pattern="http://stockquote.*">
+        <ref ref="stockquote"/>
+    </regex>
+
+
+    <regex message-address="to"
+           pattern="http://www.webservicex.net/stockquote.asmx">
+        <servicemediator name="Deprecation" service="DeprecationMediator"/>
+    </regex>
+
+    <send/>
+
+    <never>
+        <stage name="stockquote">
+            <!-- set the To address to the real endpoint -->
+            <header type="to" value="http://www.webservicex.net/stockquote.asmx"/>
+            <!-- check if the symbol is MSFT -->
+            <xpath expr="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/">
+                <!-- if it is throw a fault -->
+                <fault/>
+            </xpath>
+        </stage>
+
+    </never>
+</synapse>
+

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/README.txt
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/README.txt?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/README.txt (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/README.txt Tue Feb 14 23:11:24 2006
@@ -0,0 +1,39 @@
+Hi everybody,
+
+Note
+-----
+
+A SLA or Service Level Aggrement, is between a consumer and a provider, enforced through a 
+contract or a policy.
+In this case its enforced through the SLAMediator and the configuration is stored in the sla.xml.
+Every known consumer, identified by the IP address of his system is alloted a priority for every 
+service for which SLA is to be enforced.
+In case more than 1 request for a given service, land on the server at the same time,
+the SLA mediator if provisioned is able to arrange these requests based on the priority alloted to
+the consumer for the given request. 
+
+Priority
+---------
+
+0  has the highest priority.
+-1 is returned in case there is no priority configured for this 
+   particular (consumer, service) combination.
+
+Return Value
+-------------
+
+true  - SLA successfully executed.
+false - Error while procesing.
+
+
+Running SLA Mediator Sample
+===================================
+
+1. Copy synapse.xml in this repository to synapse_repository in the binary distribution.
+2. Place the SLAMediator.aar in the synape_repository/services.
+3. Using the Ant command "ant synapse", start the stand-alone synapse server. 
+   This will be start at port 8080. 
+4. Use Ant command "ant" StockQuoteClient available in this folder to run the sample. 
+ 
+The configuration is available in sla.xml, which is located in SLAMediator.aar's META-INF folder. 
+

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/build.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/build.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/build.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/build.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,80 @@
+<project name="samples" default="help">
+    <target name="help">
+        <echo>
+            This script requires Ant 1.5 or higher
+
+            usage:
+            ant -help display ant help screen
+            ant help display this message
+            ant clean delete the built directory
+
+            ant compile build the deprecation_mediator sample
+
+            ant StockQuote [Symbol] [webserviceurl] [synapseurl] {optional[repository]}
+            Use the smart client - Synapse in WS-Addressing router mode
+
+            ant synapse
+                -Dport  
+                    The port on which Synapse should listen, as provided in the synapseurl.
+                    Default is 8080.
+
+        </echo>
+    </target>
+
+    <property name="symbol" value="IBM"/>
+    <property name="url" value="http://www.webservicex.net/stockquote.asmx"/>
+    <property name="synapseurl" value="http://localhost:8080"/>
+    <property name="repository" value="../../synapse_repository"/>
+
+    <property name="class.dir" value="target/classes"/>
+
+    <path id="axis.classpath">
+        <fileset dir="../../lib">
+            <include name="*.jar"/>
+        </fileset>
+    </path>
+
+    <target name="clean">
+        <delete dir="target" quiet="true"/>
+        <delete dir="${class.dir}" quiet="true"/>
+    </target>
+
+
+    <target name="StockQuote" depends="compile">
+        <java classname="samples.userguide.StockQuoteClient"
+              classpathref="javac.classpath" fork="true">
+            <arg value="${symbol}"/>
+            <arg value="${url}"/>
+            <arg value="${synapseurl}"/>
+            <arg value="${repository}"/>
+        </java>
+    </target>
+
+    <target name="init">
+        <mkdir dir="${class.dir}"/>
+        <mkdir dir="src/ddl"/>
+
+        <path id="javac.classpath">
+            <pathelement path="${class.dir}"/>
+            <fileset dir="../../lib">
+                <include name="**/*.jar"/>
+            </fileset>
+        </path>
+    </target>
+
+    <target name="compile" depends="init" description="Compile all Java">
+        <javac srcdir="src" destdir="${class.dir}">
+            <classpath refid="javac.classpath"/>
+        </javac>
+    </target>
+
+    <target name="synapse">
+        <property name="port" value="8080"/>
+        <java classname="org.apache.axis2.transport.http.SimpleHTTPServer"
+              classpathref="javac.classpath" fork="true">
+            <arg value="../../synapse_repository"/>
+            <arg value="-p${port}"/>
+        </java>
+    </target>
+
+</project>

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/synapse.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/synapse.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/synapse.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/scripts/sla_mediator/synapse.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,40 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+    <stage name="logall">
+        <engage-addressing-in/>
+        <log/>
+    </stage>
+
+    <stage name="service-specific">
+        <!-- this matches the gateway case -->
+        <regex message-address="to" pattern="/StockQuote.*">
+            <ref ref="stockquote"/>
+        </regex>
+        <!-- this matches the virtual url case for either the proxy or ws-add case -->
+        <regex message-address="to" pattern="http://stockquote.*">
+            <ref ref="stockquote"/>
+        </regex>
+    </stage>
+
+    <stage name="check-sla" >
+        <regex message-address="to" pattern="http://www.webservicex.net/stockquote.asmx">
+            <servicemediator name="SLA" service="SLAMediator"/>
+        </regex>
+    </stage>
+
+    <stage name="sender">
+        <send/>
+    </stage>
+
+    <!-- these are only called if referenced above-->
+    <never>
+        <stage name="stockquote">
+            <header type="to" value="http://www.webservicex.net/stockquote.asmx" />
+            <xpath expr="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/">
+                <fault/>
+            </xpath>
+        </stage>
+    </never>
+</synapse>
+
+

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfiguration.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfiguration.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfiguration.java Tue Feb 14 23:11:24 2006
@@ -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.mediators.deprecation;
+
+public class DeprecationConfiguration {
+
+    private DeprecationRule rules[] = new DeprecationRule[0];
+    private String enabled;
+
+    public DeprecationConfiguration() {
+    }
+
+    public void addRule(DeprecationRule rule) {
+        DeprecationRule tmp[] = new DeprecationRule[rules.length + 1];
+        for (int i = 0; i < rules.length; i++) {
+            tmp[i] = rules[i];
+        }
+        tmp[rules.length] = rule;
+        this.rules = tmp;
+    }
+
+    public void removeRule() {
+        if (rules.length == 0)
+            return;
+        DeprecationRule tmp[] = new DeprecationRule[rules.length - 1];
+        for (int i = 0; i < rules.length - 1; i++) {
+            tmp[i] = rules[i];
+        }
+        this.rules = tmp;
+    }
+
+    public boolean hasRule(String service) {
+        for (int i = 0; i < rules.length; i++) {
+            if (rules[i].getService().equals(service)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public DeprecationRule[] getRules() {
+        return rules;
+    }
+
+    public void setEnabled(String enabled) {
+        this.enabled = enabled;
+    }
+
+    public String getEnabled() {
+        return this.enabled;
+    }
+
+}
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,137 @@
+/*
+ * 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.deprecation;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+
+import javax.xml.namespace.QName;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class DeprecationConfigurator {
+
+    /*
+    *** MAP STRUCTURE ***
+    The config map contains the parameter-sets for all the services and also a default
+    parameter set. The key to this map is the endPoint reference of the service and the
+    value associated with it is the parameter map corresponding to it.
+
+    <deprecationConfig>
+        <service Id = "the serviceEPR">
+                <parameterSet>
+                    <fromDate>value</fromDate>
+                    <toDate>value</toDate>
+                </parameterSet>
+                <parameterSet>
+                    <fromDate>value</fromDate>
+                    <toDate>value</toDate>
+                </parameterSet>*
+        </service>*
+    </deprecationConfig>
+
+    This should map to
+    key is ("serviceEPR")
+    value is (map of parameterSet) i.e.
+        map with key (parameter name), value (parameter value).
+    */
+
+    public Map deprecationConfig;
+    private Map configMap;
+
+    public DeprecationConfigurator(InputStream inStream) {
+
+        //Read from some source, probably a file and set the config map here.
+        //If the source is service specific, we can use getConfig() and only access
+        //service based parameters else make a general config and filter out the needed parameters
+        //and create a Map in the getConfig(EndpointReference to)
+        try {
+            configMap = generateMap(inStream);
+            setConfig(configMap);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private Map generateMap(InputStream inStream) throws Exception {
+
+
+        StAXOMBuilder staxOMBuilder;
+
+        staxOMBuilder = new StAXOMBuilder(inStream);
+
+        //Read the source and generate a map of the
+        Map generatedMap = new HashMap();
+
+        OMElement config = staxOMBuilder.getDocumentElement();
+        config.build();
+        Iterator serviceItr = config.getChildrenWithName(new QName(DeprecationConstants.CFG_DEPRECATION_SERVICE));
+
+        while (serviceItr.hasNext()) {
+            OMElement serviceEle = (OMElement) serviceItr.next();
+            String serviceKey = serviceEle.getAttributeValue(new QName("Id"));
+            Iterator paramItr = serviceEle.getChildElements();
+            int counter = 0;
+            Map dataMap = new HashMap();
+
+            while (paramItr.hasNext()) {
+                OMElement paramEle = (OMElement) paramItr.next();
+                Iterator dataItr = paramEle.getChildElements();
+
+                while (dataItr.hasNext()) {
+                    OMElement dataEle = (OMElement) dataItr.next();
+                    String dataName = dataEle.getLocalName() + "[" + counter + "]";
+                    String dataValue = dataEle.getText();
+                    dataMap.put(dataName, dataValue);
+                }
+
+                //Will be of use if multiple services are facaded by a single serviceEPR
+                dataMap.put(DeprecationConstants.CFG_DEPRECATION_SERVICE + "[" + counter + "]", serviceKey);
+                counter++;
+
+            }
+            generatedMap.put(serviceKey, dataMap);
+        }
+        return generatedMap;
+    }
+
+    public Map getConfig(EndpointReference to) {
+
+        //Filter out the required parameters and generate the ConfigMap for this service
+        //This is done by using the EndPointReference as a key into the configMap.
+        //The value object corresponding to it is the required deprecationMap.
+
+        deprecationConfig = (Map) configMap.get(to.getAddress());
+
+        return deprecationConfig;
+    }
+
+    public void setConfig(Map configMap) {
+
+        //In case we go for service-specific impl then the configMap will contain details
+        // for the single service alone, hence this line.
+        //If an aggregate approach is taken [i.e. all service data in a single source file]
+        // then this method should not assign configMap to deprecationConfig.
+
+        this.deprecationConfig = configMap;
+
+    }
+
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConstants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConstants.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConstants.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationConstants.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,28 @@
+/*
+ * 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.deprecation;
+
+public interface DeprecationConstants {
+
+    public static final String CFG_DEPRECATION_SERVICE = "deprecationService";
+    public static final String CFG_DEPRECATION_FROM_DATE = "deprecationFromdate";
+    public static final String CFG_DEPRECATION_TO_DATE = "deprecationTodate";
+    public static final String CFG_DEPRECATION_ENABLED = "deprecationEnabled";
+    public static final String CFG_DEPRECATION_RESULT = "synapse.deprecation.result";
+    public static final String CFG_DEPRECATION_XML = "deprecation.xml";
+    public static final String CFG_XML_FOLDER = "META-INF";
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationMediator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationMediator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationMediator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,106 @@
+/*
+ * 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.deprecation;
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.EnvironmentAware;
+
+import java.util.Map;
+import java.io.InputStream;
+
+public class DeprecationMediator implements Mediator, EnvironmentAware {
+
+    DeprecationConfiguration configuration;
+    private ClassLoader classLoader;
+
+    public DeprecationMediator() {
+    }
+
+    public boolean mediate(SynapseMessage synapseMessageContext) {
+
+        try {
+
+            String resource = DeprecationConstants.CFG_XML_FOLDER+"/"+DeprecationConstants.CFG_DEPRECATION_XML;
+            InputStream inStream = classLoader.getResourceAsStream(resource);
+            final DeprecationConfigurator deprecationConfigurator =
+                    new DeprecationConfigurator(inStream);
+            Map mediatorConfig = deprecationConfigurator
+                    .getConfig(synapseMessageContext.getTo());
+            loadConfiguration(mediatorConfig);
+            DeprecationRule rules[] = configuration.getRules();
+            boolean deprecated = false;
+
+            for (int i = 0, len = rules.length; i < len; i++) {
+
+                if (rules[i].isDeprecated()) {
+
+                    deprecated = true;
+                }
+
+            }
+
+            synapseMessageContext.setProperty(
+                    DeprecationConstants.CFG_DEPRECATION_RESULT,
+                    Boolean.valueOf(deprecated));
+
+            return !(deprecated);
+
+        } catch (Exception e) {
+
+            return false;
+        }
+    }
+
+    private void loadConfiguration(Map mediatorConfig) {
+        configuration = new DeprecationConfiguration();
+
+        for (int i = 0; true; i++) {
+
+            String serviceKey = DeprecationConstants.CFG_DEPRECATION_SERVICE +
+                    "[" + i + "]";
+            String fromDateKey = DeprecationConstants
+                    .CFG_DEPRECATION_FROM_DATE + "[" + i + "]";
+            String toDateKey = DeprecationConstants.CFG_DEPRECATION_TO_DATE +
+                    "[" + i + "]";
+            String enabledKey = DeprecationConstants.CFG_DEPRECATION_ENABLED +
+                    "[" + i + "]";
+
+            if (mediatorConfig.get(serviceKey) == null) {
+                break;
+            }
+
+
+            DeprecationRule rule = new DeprecationRule();
+            rule.setService((String) mediatorConfig.get(serviceKey));
+            rule.setFromDate((String) mediatorConfig.get(fromDateKey));
+            rule.setToDate((String) mediatorConfig.get(toDateKey));
+            rule.setEnabled((String) mediatorConfig.get(enabledKey));
+            configuration.addRule(rule);
+        }
+
+    }
+
+    public void setSynapseEnvironment(SynapseEnvironment se) {
+        //not used for now
+    }
+
+    public void setClassLoader(ClassLoader cl) {
+        this.classLoader = cl;
+    }
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationRule.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationRule.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationRule.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/DeprecationRule.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,118 @@
+/*
+ * 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.deprecation;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+public class DeprecationRule {
+
+    private String service;
+    private String fromDate;
+    private String toDate;
+    private String enabled;
+
+    public DeprecationRule() {
+
+    }
+
+    public DeprecationRule(String service) {
+        this.service = service;
+    }
+
+    public String getService() {
+        return this.service;
+    }
+
+    public void setService(String service) {
+        this.service = service;
+    }
+
+    public String getFromDate() {
+        return this.fromDate;
+    }
+
+    public void setFromDate(String fromDate) {
+        this.fromDate = fromDate;
+    }
+
+    public String getToDate() {
+        return this.toDate;
+    }
+
+    public void setToDate(String toDate) {
+        this.toDate = toDate;
+    }
+
+    public String getEnabled() {
+        return this.enabled;
+    }
+
+    public void setEnabled(String enabled) {
+        this.enabled = enabled;
+    }
+
+    public boolean isDeprecated() {
+        try {
+            if (Boolean.TRUE == Boolean.valueOf(enabled)) {
+                Calendar current = Calendar.getInstance();
+                TimeZone tz = current.getTimeZone();
+                int offset = tz.getRawOffset();
+                Calendar calendar = new GregorianCalendar(tz);
+
+                DateFormat df = new SimpleDateFormat("d/M/y:H:m");
+                df.setTimeZone(tz);
+
+                Date d1 = df.parse(fromDate);
+                Calendar fromCalendar = new GregorianCalendar(tz);
+                d1.setTime(d1.getTime() + offset);
+                fromCalendar.setTime(d1);
+
+                if (toDate == null || (toDate.length() == 0)) {
+                    return calendar.before(fromCalendar);
+                }
+
+                Date d2 = df.parse(toDate);
+                Calendar toCalendar = new GregorianCalendar(tz);
+                d2.setTime(d2.getTime() + offset);
+                toCalendar.setTime(d2);
+
+                return (calendar.after(fromCalendar) && calendar.before(toCalendar));
+            }
+        } catch (ParseException e) {
+            return false;
+        }
+
+        return false;
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer(1024);
+        buf.append("Service : ").append(getService()).append("\n");
+        buf.append("FromDate: ").append(getFromDate()).append("\n");
+        buf.append("ToDate: ").append(getToDate()).append("\n");
+        buf.append("Enabled: ").append(getEnabled()).append("\n");
+
+        return buf.toString();
+    }
+
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/deprecation.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/deprecation.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/deprecation.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/deprecation.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,11 @@
+<!-- The time format is dd/mm/yyyy:H:m and its with respect to UTC.
+TimeZone is that of the system, offset from UTC is calculated internally -->
+<deprecationConfig>
+    <deprecationService Id="http://www.webservicex.net/stockquote.asmx">
+        <parameterSet>
+            <deprecationFromdate>06/09/2005:00:00</deprecationFromdate>
+            <deprecationTodate>07/02/2006:00:00</deprecationTodate>
+            <deprecationEnabled>true</deprecationEnabled>
+        </parameterSet>
+    </deprecationService>
+</deprecationConfig>
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/services.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/services.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/META-INF/services.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,10 @@
+<!-- Can be used if the mediator is to be provided as an axis2 service-->
+<service name="DeprecationMediator">
+    <parameter name="ServiceClass" locked="false">
+       org.apache.synapse.mediators.deprecation.DeprecationMediator</parameter>
+    <operation name="mediate">
+        <messageReceiver
+                class="org.apache.synapse.axis2.ServiceMediatorMessageReceiver"/>
+    </operation>
+</service>
+  
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/README.txt
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/README.txt?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/README.txt (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/deprecation/README.txt Tue Feb 14 23:11:24 2006
@@ -0,0 +1,35 @@
+Hi everybody,
+
+Note
+-----
+
+This is the first shot towards a Deprecation mediator.
+A trivial explanation would be - A service configured as deprecated between certain dates/time will not
+be accessible for requests coming in between those dates.
+You are free to declare more than one set of dates/time and enable or disable the set when required.
+
+The mediator depends on the UTC - Date/time settings and these are converted and offset to local time,
+during processing, internally.
+
+It implements the Mediator interface and hence has the "boolean mediate(SynapseMessage)" method.
+The configuration data about the deprecation for a particular service is provided in a 
+"deprecation.xml" file.
+
+When a SynapseContext is sent to the DeprecationMediator it checks wether the service to which the request is
+addressed is deprecatd or not. It sets the value in the "synapse.deprecation.result" property in the synapseContext.
+
+Return Values
+--------------
+True - Service is not deprecated, the request can go on.
+False - The service is deprecated, need not send the request to the service.
+
+To try out the mediator
+------------------------
+
+ - Modify the deprecation.xml present in the 
+      * aar (in case you are using the binary)
+      * src/org/apache/synapse/mediators/deprecation/META-INF (in case you are working with the source)
+   to suit the configuration you want.
+ - Send in a request to Synapse and see it work/get rejected depending on the settings.
+
+~ Lots of scope for enhancement and improvement. Will keep adding up!
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/services.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/services.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/services.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,10 @@
+<!-- Can be used if the mediator is to be provided as an axis2 service-->
+<service name="SLAMediator">
+    <parameter name="ServiceClass" locked="false">
+        org.apache.synapse.mediators.sla.SLAMediator</parameter>
+    <operation name="mediate">
+        <messageReceiver
+                class="org.apache.synapse.axis2.ServiceMediatorMessageReceiver"/>
+    </operation>
+</service>
+  
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/sla.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/sla.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/sla.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/META-INF/sla.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,17 @@
+<slaConfig>
+    <slaRequest ip="192.168.6.71" enabled="true">
+        <serviceURL url="http://www.webservicex.net/stockquote.asmx" enabled="true" >
+            <priority>0</priority>
+        </serviceURL>    
+    </slaRequest>
+    <slaRequest ip="192.168.6.81" enabled="true">
+        <serviceURL url="http://www.webservicex.net/stockquote.asmx" enabled="true" >
+            <priority>0</priority>
+        </serviceURL>    
+    </slaRequest>    
+    <slaRequest ip="192.168.6.127" enabled="true">
+        <serviceURL url="http://www.webservicex.net/stockquote.asmx" enabled="true" >
+            <priority>1</priority>
+        </serviceURL>    
+    </slaRequest>
+</slaConfig>
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/README.txt
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/README.txt?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/README.txt (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/README.txt Tue Feb 14 23:11:24 2006
@@ -0,0 +1,37 @@
+Note
+-----
+
+A SLA or Service Level Aggrement, is between a consumer and a provider, enforced through a 
+contract or a policy.
+In this case its enforced through the SLAMediator and the configuration is stored in the sla.xml.
+Every known consumer, identified by the IP address of his system is alloted a priority for every 
+service for which SLA is to be enforced.
+In case more than 1 request for a given service, lands on the server at the same time,
+the SLA mediator if provisioned will be able to arrange these requests based on the priority assigned to
+the them for the given request. 
+
+Priority
+---------
+
+0  has the highest priority.(it's an int value)
+-1 is returned in case there is no priority configured for a 
+   particular (consumer, service) combination.
+
+Return Value
+-------------
+
+true  - SLA successfully executed.
+false - Error while procesing.
+
+
+Running SLA Mediator Sample
+===================================
+
+1. Copy synapse.xml in this repository to synapse_repository in the binary distribution.
+2. Place the SLAMediator.aar in the synape_repository/services.
+3. Using the Ant command "ant synapse", start the stand-alone synapse server. 
+   This will be start at port 8080. 
+4. Use Ant command "ant" StockQuoteClient available in this folder to run the sample. 
+
+The configuration details are available in sla.xml, which is located in SLAMediator's META-INF folder. 
+

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,86 @@
+package org.apache.synapse.mediators.sla;
+
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.io.InputStream;
+
+
+public class SLAConfigurator {
+    private static Map SLAConfig;
+    private Log log = LogFactory.getLog(getClass());
+
+
+       public SLAConfigurator(InputStream inStream) {
+
+           try {
+               Map configMap = generateMap(inStream);
+               setConfig(configMap);
+           } catch (Exception e) {
+               log.info(e);
+           }
+       }
+
+       private Map generateMap(InputStream inStream) throws Exception {
+
+
+           StAXOMBuilder staxOMBuilder;
+           staxOMBuilder = new StAXOMBuilder(inStream);
+           Map generatedMap = new HashMap();
+           OMElement config = staxOMBuilder.getDocumentElement();
+           config.build();
+           Iterator clientItr = config.getChildrenWithName(new QName("slaRequest"));
+           while (clientItr.hasNext()) {
+               OMElement clientEle = (OMElement) clientItr.next();
+               String enabled = clientEle.getAttributeValue(new QName("enabled"));
+               boolean isClientEnabled = enabled.equalsIgnoreCase("true");
+               if(isClientEnabled){
+
+                   String clientKey = clientEle.getAttributeValue(new QName("ip"));
+                   Iterator serviceItr = clientEle.getChildrenWithName(new QName("serviceURL"));
+
+                   Map dataMap = new HashMap();
+
+                   while (serviceItr.hasNext()) {
+                       OMElement serviceEle = (OMElement) serviceItr.next();
+                       OMElement priorityEle = serviceEle.getFirstChildWithName(new QName("priority"));
+                       String serviceEnabled = serviceEle.getAttributeValue(new QName("enabled"));
+                       boolean isServiceEnabled = serviceEnabled.equalsIgnoreCase("true");
+                       if(isServiceEnabled) {
+                           String serviceKey = serviceEle.getAttributeValue(new QName("url"));
+                           String priority = priorityEle.getText();
+                           dataMap.put(serviceKey,priority);
+                       }
+                   }
+                   generatedMap.put(clientKey, dataMap);
+               }
+           }
+           return generatedMap;
+       }
+
+       public int getPriority(String ip, EndpointReference to) {
+
+           int priority=-1;
+           Map clientMap = (Map) SLAConfig.get(ip);
+           if(clientMap!=null){
+               log.info("address" + to.getAddress());
+               String priorityValue = (String)clientMap.get(to.getAddress());
+                if(priorityValue!=null){
+                    priority = Integer.parseInt(priorityValue);
+                }
+           }
+           return priority;
+       }
+
+       public void setConfig(Map configMap) {
+
+           SLAConfig = configMap;
+
+       }
+}
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConstants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConstants.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConstants.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAConstants.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,10 @@
+
+package org.apache.synapse.mediators.sla;
+
+public interface SLAConstants {
+
+    public static final String CFG_SLA_ENABLED = "slaEnabled";
+    public static final String CFG_SLA_RESULT = "synapse.sla.result";
+    public static final String CFG_SLA_XML = "sla.xml";
+    public static final String CFG_XML_FOLDER = "META-INF";
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAMediator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAMediator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAMediator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,87 @@
+package org.apache.synapse.mediators.sla;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.EnvironmentAware;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.InputStream;
+
+public class SLAMediator implements Mediator, EnvironmentAware {
+
+    private ClassLoader classLoader;
+    private SynapseEnvironment se;
+    private Log log = LogFactory.getLog(getClass());
+    public SLAMediator() {
+    }
+
+    public boolean mediate(SynapseMessage synapseMessageContext) {
+
+        try {
+            log.info("SLA Mediator!");
+            MessageContext mc = ((Axis2SynapseMessage)synapseMessageContext).getMessageContext();
+            String resource = SLAConstants.CFG_XML_FOLDER+"/"+SLAConstants.CFG_SLA_XML;
+            InputStream inStream = classLoader.getResourceAsStream(resource);
+            final SLAConfigurator slaConfigurator = new SLAConfigurator(inStream);
+            SLAStack slaStack = null;
+            try{
+                if(se.getProperty("PRIORITY_STACK")!=null){
+                    slaStack = (SLAStack)se.getProperty("PRIORITY_STACK");
+                }
+                else{
+                    slaStack = new SLAStack();
+                    se.setProperty("PRIORITY_STACK",slaStack);
+                }
+            }catch(Exception ex){
+                log.info(ex);
+
+            }
+            String fromAddress = (String)synapseMessageContext.getFrom().getAddress();
+            int priority = slaConfigurator.getPriority(fromAddress,synapseMessageContext.getTo());
+            SLAObject slaObject = new SLAObject(priority,System.currentTimeMillis(),fromAddress);
+            try{
+            slaStack.addRequest(slaObject);
+            }catch(Exception ex){
+              log.info(ex);
+            }
+
+            while(true)
+            {
+              if(!slaStack.isEmpty()){
+                SLAObject slaObjectStack = (SLAObject)slaStack.get(0);
+                if(slaObjectStack.equals(slaObject))
+                {
+                  slaStack.remove(0);
+                  break;
+                }
+              }else
+              {
+                break;
+              }
+            }
+            
+            return true;
+
+        } catch (Exception e) {
+            log.info(e);
+            return false;
+        }
+    }
+
+    public void setSynapseEnvironment(SynapseEnvironment se) {
+
+        this.se = se;
+        if(se!=null){
+            log.info("ENVIRONMENT NOT NULL IN SLA");
+        }
+    }
+
+    public void setClassLoader(ClassLoader cl) {
+        this.classLoader = cl;
+    }
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAObject.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAObject.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAObject.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAObject.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,63 @@
+package org.apache.synapse.mediators.sla;
+
+public class SLAObject implements Comparable {
+
+    int priority;
+    long time;
+    Object object;
+
+    public SLAObject() {
+    }
+
+    public SLAObject(int priority, long time, Object object) {
+        this.priority = priority;
+        this.time = time;
+        this.object = object;
+    }
+
+    public int getPriority() {
+        return priority;
+    }
+
+    public void setPriority(int index) {
+        this.priority = index;
+    }
+
+    public long getTime() {
+        return time;
+    }
+
+    public void setTime(long time) {
+        this.time = time;
+    }
+
+    public Object getObject() {
+        return object;
+    }
+
+    public void setObject(Object object) {
+        this.object = object;
+    }
+
+    public int compareTo(Object o2) {
+        SLAObject obj1 = this;
+        SLAObject obj2 = (SLAObject) o2;
+        if (obj1.getTime() == obj2.getTime()) {
+            if (obj1.getPriority() == obj2.getPriority()) {
+                if (obj1.hashCode() == obj2.hashCode()) {
+                    return 0;
+                } else if (obj1.hashCode() < obj2.hashCode()) {
+                    return -1;
+                } else return 1;
+            } else if (obj1.getPriority() < obj2.getPriority()) {
+                return -1;
+            } else {
+                return 1;
+            }
+        } else if (obj1.getTime() < obj2.getTime()) {
+            return -1;
+        } else {
+            return 1;
+        }
+    }
+}

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAStack.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAStack.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAStack.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/mediators/src/org/apache/synapse/mediators/sla/SLAStack.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,17 @@
+package org.apache.synapse.mediators.sla;
+import java.util.Collections;
+import java.util.ArrayList;
+
+public class SLAStack extends ArrayList
+{
+  public SLAStack()
+  {
+  }
+  public void addRequest(SLAObject slaObject)
+  {
+      this.add(slaObject);
+      if(this.size() > 1){
+          Collections.sort(this);
+      }
+  }
+}
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/maven.xml?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/maven.xml (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/maven.xml Tue Feb 14 23:11:24 2006
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="jar"
+         xmlns:j="jelly:core"
+         xmlns:u="jelly:util"
+         xmlns:deploy="deploy"
+         xmlns:ant="jelly:ant"
+         xmlns:maven="jelly:maven"
+         xmlns:define="jelly:define">
+
+    <j:set var="dist.name" value="${pom.artifactId}-${pom.currentVersion}"/>
+    <!--<j:set var="dist.dir" value="target/dist"/>-->
+    <j:set var="samples.dir" value="target/samples"/>
+
+    <postGoal name="test:test">
+        <j:if test="${context.getVariable('maven.test.skip') != 'true'}">
+            <attainGoal name="toDistBin"/>
+        </j:if>
+    </postGoal>
+
+
+    <goal name="samples_userguide">
+
+        <mkdir dir="target/samples"/>
+        <mkdir dir="${samples.dir}/src"/>
+        <ant:copy todir="${samples.dir}/src">
+            <ant:fileset dir="src">
+                <ant:include name="samples/**"/>
+            </ant:fileset>
+        </ant:copy>
+
+    </goal>
+
+    <goal name="toDistBin" prereqs="samples_userguide">
+        <property name="bin.dist.dir"
+                  value="target/dist-bin"/>
+        <ant:mkdir dir="${bin.dist.dir}"/>
+        <ant:mkdir dir="${bin.dist.dir}/samples"/>
+
+        <ant:copy file="scripts/userguide/build.xml"
+                  tofile="${bin.dist.dir}/samples/build.xml"/>
+        <ant:copy file="scripts/userguide/README.txt"
+                  tofile="${bin.dist.dir}/samples/README.txt"/>
+
+        <ant:copy todir="${bin.dist.dir}/samples">
+            <ant:fileset dir="target/samples/">
+                <include name="**"/>
+            </ant:fileset>
+        </ant:copy>
+        <ant:delete dir="target/samples"/><ant:delete dir="target/samples"/>
+    </goal>
+</project>

Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/project.properties
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/project.properties?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/project.properties (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/samples/project.properties Tue Feb 14 23:11:24 2006
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2004 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.
+# -------------------------------------------------------------------
+
+maven.multiproject.type=jar



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