synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r397884 [3/8] - in /incubator/synapse/trunk/scratch/synapse2: ./ bin/ modules/ modules/core/ modules/core/conf/ modules/core/src/ modules/core/src/org/ modules/core/src/org/apache/ modules/core/src/org/apache/synapse/ modules/core/src/org/a...
Date Fri, 28 Apr 2006 12:49:34 GMT
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.synapse.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+/**
+ * <p/>
+ * <p/>
+ * This is used to "catch" messages in Axis2 and pass them to Synapse for processing.
+ */
+public class SynapseMessageReceiver implements MessageReceiver {
+
+    private Log log = LogFactory.getLog(getClass());
+
+    public void receive(MessageContext mc) throws AxisFault {
+        log.debug("receiving message");
+        SynapseEnvironment env = Axis2SynapseEnvironmentFinder
+                .getSynapseEnvironment(mc);
+        ////////////////////////////////////////////////////////////////////////
+        // SynapseEnvironment is set as a property in MessageContext. This is due
+        // use we can expect in ServiceMediatorProcessor and many extensions yet to come
+        // So it a mediator uses EnvironmentAware, that mediator will be injected with the correct environment
+        
+        ////////////////////////////////////////////////////////////////////////
+        SynapseMessage smc = new Axis2SynapseMessage(mc,env);
+        smc.setSynapseEnvironment(env);
+        env.injectMessage(smc);
+
+        ///////////////////////////////////////////////////////////////////////
+        // Response handling mechanism for 200/202 and 5XX
+        // smc.isResponse =true then the response will be handle with 200 OK
+        // else, response will be 202 OK without no http body
+        // smc.isFaultRespose = true then the response is a fault with 500 Internal Server Error
+        if (smc.isResponse()) {
+            mc.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
+                    Constants.VALUE_TRUE);
+        }
+        if (smc.isFaultResponse()) {
+            // todo: a good way to inject faultSoapEnv to the Axis2 Transport 
+            throw new AxisFault(
+                    "Synapse Encounters an Error - Please See Log for More Details");
+        }
+        ///////////////////////////////////////////////////////////////////////
+    }
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/AbstractListMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/AbstractListMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/AbstractListMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/AbstractListMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+import java.util.Iterator;
+
+import java.util.List;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.api.ListMediator;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseMessage;
+
+
+/**
+ *
+ *         stages, mediations that it has as subelements It is a way of grouping
+ *         stuff.
+ * 
+ */
+public abstract class AbstractListMediator implements ListMediator {
+	
+	private Log log = LogFactory.getLog(getClass());
+
+	protected List mediators = null;
+	
+	public boolean mediate(SynapseMessage smc) {
+		log.debug("mediate()");
+		if (mediators == null) {
+			log.info("mediate called on empty mediator list");
+			return true;
+		}
+		Iterator it = mediators.iterator();
+		while (it.hasNext()) {
+			Mediator m = (Mediator) it.next();
+			log.debug(m.getClass());
+			if (!m.mediate(smc))
+				return false;
+		}
+		return true;
+	}
+
+	public void setList(List m) {
+		log.debug("setting list");
+		Iterator it = m.iterator();
+		while (it.hasNext()) {
+			Mediator x = (Mediator)it.next();
+			log.debug(x.getClass());
+		}
+		mediators = m;
+	}
+	public List getList() {
+		return mediators;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/DefineMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/DefineMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/DefineMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/DefineMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.synapse.mediators.base;
+
+import org.apache.synapse.SynapseMessage;
+
+/**
+ *
+ */
+public class DefineMediator extends AbstractListMediator {
+
+    public boolean mediate(SynapseMessage sm) {
+        return true;
+    }
+
+    /*
+    The Processor.process() is common to every one. Define Processor is a unique
+    mediator that is not run in-line. It should always reference by some entity. This
+    Entity is "<refdefine/>. <refdefine/> has the @ref which will reference to the
+    <define/>.
+
+    The Following method processRef(SynapseEnvironment se, SynapseMessage sm) will
+    allow to reference the <define/> process and, will not allow the <define/> to be a inline
+    process either.
+    */
+
+    public boolean mediateRef(SynapseMessage sm) {
+        return super.mediate(sm);
+    }
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/InMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/InMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/InMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/InMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+
+import org.apache.synapse.SynapseMessage;
+
+/**
+ *
+ * 
+ * Only processes if this is not a response
+ *
+ */
+public class InMediator extends AbstractListMediator {
+
+	public boolean mediate(SynapseMessage sm) {
+		if (!sm.isResponse()) return super.mediate(sm);
+		return true;
+		
+	}
+	
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/NeverMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/NeverMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/NeverMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/NeverMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+
+import org.apache.synapse.SynapseMessage;
+
+/**
+ *
+ * This never executes its children. Used as a holder (for references)
+ *
+ */
+public class NeverMediator extends AbstractListMediator {
+
+	public boolean mediate(SynapseMessage sm) {
+		return true;
+	}
+	
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/OutMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/OutMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/OutMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/OutMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+import org.apache.synapse.SynapseMessage;
+
+/**
+ * <p>
+ * This only executes on response messages
+ *
+ */
+public class OutMediator extends AbstractListMediator{
+
+	public boolean mediate(SynapseMessage sm) {
+		if (sm.isResponse()) return super.mediate(sm);
+			return true;
+	}
+	
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefDefineMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefDefineMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefDefineMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefDefineMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.Mediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Processor that reference to <refdefine/>
+ */
+public class RefDefineMediator implements Mediator {
+    private Log log = LogFactory.getLog(getClass());
+	private String refDefine = null;
+
+    public boolean mediate(SynapseMessage sm) {
+        log.debug("RefDfineProcessor-Process");
+        Mediator m = sm.getSynapseEnvironment().lookupMediator(getRefDefine());
+		if (m==null) log.debug("mediator with name "+this.getRefDefine()+" not found");
+		else if (m instanceof DefineMediator) {
+            DefineMediator defm = (DefineMediator)m;
+            return defm.mediateRef(sm);
+        }
+		return true;
+    }
+
+    public void setRefDefine(String refDefine) {
+        this.refDefine = refDefine;
+    }
+
+    public String getRefDefine() {
+        return this.refDefine;
+    }
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/RefMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.Mediator;
+
+/**
+ *
+ * 
+ * Calls another processor which is referred to by the Ref property.
+ *
+ */
+public class RefMediator implements Mediator {
+	private Log log = LogFactory.getLog(getClass());
+	private String ref = null;
+	
+	public boolean mediate(SynapseMessage sm) {
+		log.debug("mediate");
+		Mediator m = sm.getSynapseEnvironment().lookupMediator(getRef());
+		if (m==null) log.debug("mediator with name "+this.getRef()+" not found");
+		else return m.mediate(sm);
+		return true;
+	}
+
+	public void setRef(String ref) {
+		this.ref = ref;
+	}
+
+	public String getRef() {
+		return ref;
+	}
+
+		
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/StageMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/StageMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/StageMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/StageMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+
+/**
+ *
+ * 
+ * 
+ */
+public class StageMediator extends AbstractListMediator {
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SynapseMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.base;
+
+/**
+ *
+ * 
+ * This implements the main processor. Delegates to ListProcessor
+ * Here in case we need the main <synapse> to do anything special
+ *
+ */
+public class SynapseMediator extends AbstractListMediator {
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.builtin;
+
+import org.apache.synapse.api.Mediator;
+
+import org.apache.synapse.SynapseMessage;
+
+/**
+ * Implementaion of <drop/>
+ */
+public class DropMediator implements Mediator  {
+    
+    public boolean mediate(SynapseMessage sm) {
+        if (sm.getTo() == null) {
+            return false;
+        }else{
+            sm.setTo(null);
+            return false;
+        }
+    }
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.synapse.mediators.builtin;
+
+import org.apache.synapse.HeaderType;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.api.Mediator;
+
+
+/**
+ *
+ *      @see org.apache.synapse.HeaderType  
+ * <p> Sets aspects of the header to new values.
+ *   Uses HeaderType to set header values     
+ * 
+ */
+public class HeaderMediator implements Mediator{
+	
+	private HeaderType headerType = new HeaderType();
+
+	private String value = null;
+
+	public void setHeaderType(String ht) {
+		headerType.setHeaderType(ht);
+	}
+	
+	public String getHeaderType() {
+		return headerType.getHeaderType();
+	}
+	
+	public boolean mediate(SynapseMessage sm) {
+
+		headerType.setHeader(sm, getValue());
+		return true;
+	}
+
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+	public String getValue() {
+		return value;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.builtin;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.api.Mediator;
+
+
+/**
+ *
+ * <p>
+ * Logs the message using commons logging
+ * 
+ * <p>
+ * TODO make configurable - short or detailed logs
+ *
+ */
+public class LogMediator implements Mediator {
+	
+	private Log log = LogFactory.getLog(getClass());
+
+	public boolean mediate(SynapseMessage smc) {
+		log.info("---------------------------------------");
+		if (smc.getTo() != null)
+			log.info("To: " + smc.getTo().getAddress());
+		if (smc.getFrom() != null)
+			log.info("From: " + smc.getFrom().getAddress());
+		if (smc.getReplyTo() != null)
+			log.info("ReplyTo: " + smc.getReplyTo().getAddress());
+		if (smc.getEnvelope() != null)
+			log.info("Envelope: " + smc.getEnvelope().toString());
+		log.info("---------------------------------------");
+		return true;
+	}
+
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.builtin;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseMessage;
+
+/**
+ *
+ * <p>
+ * 
+ * This sends the message on (or back)
+ *
+ */
+public class SendMediator implements Mediator {
+	
+
+	private Log log = LogFactory.getLog(getClass());
+
+	
+	public boolean mediate(SynapseMessage smc) {
+		log.debug("mediate");
+		smc.getSynapseEnvironment().send(smc);
+		return false;
+
+	}
+
+	
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendNowMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendNowMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendNowMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendNowMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.builtin;
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.axis2.Axis2FlexibleMEPClient;
+import org.apache.synapse.axis2.DynamicAxisOperation;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.deployment.util.PhasesInfo;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.wsdl.WSDLConstants;
+import org.apache.axiom.soap.SOAPEnvelope;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Implementaion of <sendnow/>
+ */
+public class SendNowMediator implements Mediator {
+    public boolean mediate( SynapseMessage sm) {
+        MessageContext mc = ((Axis2SynapseMessage)sm).getMessageContext();
+
+        try {
+            MessageContext response = send(mc);
+            if (response.getProperty(MessageContext.TRANSPORT_IN) !=null) {
+                SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(
+                response, mc.getEnvelope().getNamespace()
+                .getName());
+
+                response.setEnvelope(resenvelope);
+                outMessageSerialization(response,mc,sm);
+            }
+
+
+        } catch (AxisFault axisFault) {
+            throw new SynapseException(axisFault);
+        }
+        // this will stop processing message and what User
+        return false;
+    }
+
+    public MessageContext send(MessageContext smc) throws AxisFault {
+        ConfigurationContext cc = smc.getConfigurationContext();
+        AxisConfiguration ac = cc.getAxisConfiguration();
+        PhasesInfo phasesInfo = ac.getPhasesInfo();
+
+        // setting operation default chains
+        if (ac.getService("__ANONYMOUS_SERVICE__") == null) {
+            DynamicAxisOperation operation = new DynamicAxisOperation(new QName(
+                            "__DYNAMIC_OPERATION__"));
+            AxisService axisAnonymousService =
+                    new AxisService("__ANONYMOUS_SERVICE__");
+            axisAnonymousService.addOperation(operation);
+            ac.addService(axisAnonymousService);
+            phasesInfo.setOperationPhases(operation);
+        }
+        ServiceGroupContext sgc = new ServiceGroupContext(cc,
+                (AxisServiceGroup)ac.getService("__ANONYMOUS_SERVICE__").getParent());
+        ServiceContext sc =
+                sgc.getServiceContext(new AxisService("__ANONYMOUS_SERVICE__"));
+
+        MessageContext mc = new MessageContext();
+        mc.setConfigurationContext(sc.getConfigurationContext());
+        ///////////////////////////////////////////////////////////////////////
+        // filtering properties
+        if (smc.getSoapAction() != null)
+            mc.setSoapAction(smc.getSoapAction());
+        if (smc.getWSAAction() != null)
+            mc.setWSAAction(smc.getWSAAction());
+        if (smc.getFrom() != null)
+            mc.setFrom(smc.getFrom());
+        if (smc.getMessageID() != null)
+            mc.setMessageID(smc.getMessageID());
+        else
+            mc.setMessageID(String.valueOf("uuid:"
+                    + UUIDGenerator.getUUID()));
+        if (smc.getReplyTo() != null)
+            mc.setReplyTo(smc.getReplyTo());
+        if (smc.getRelatesTo() != null)
+            mc.setRelatesTo(smc.getRelatesTo());
+        if (smc.getTo() != null) {
+            mc.setTo(smc.getTo());
+        } else {
+            throw new AxisFault(
+                    "To canno't be null, if null Synapse can't infer the transport");
+        }
+        if (smc.isDoingREST()) {
+            mc.setDoingREST(true);
+        }
+        mc.setEnvelope(Axis2FlexibleMEPClient.outEnvelopeConfiguration(smc));
+
+        AxisOperation axisAnonymousOperation =
+                ac.getService("__ANONYMOUS_SERVICE__")
+                        .getOperation(new QName("__DYNAMIC_OPERATION__"));
+
+        Options options = new Options();
+        OperationClient mepClient =
+                axisAnonymousOperation.createClient(sc,options);
+
+        mepClient.addMessageContext(mc);
+        mepClient.execute(true);
+        MessageContext response = mepClient
+                .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+
+
+        response.setProperty(MessageContext.TRANSPORT_OUT,
+                smc.getProperty(MessageContext.TRANSPORT_OUT));
+        response.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
+                smc.getProperty(
+                        org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
+
+        // If request is REST we assume the response is REST, so set the
+        // variable
+        response.setDoingREST(smc.isDoingREST());
+
+        return response;
+    }
+
+    private void outMessageSerialization(MessageContext mcn,MessageContext mco,SynapseMessage sm) throws AxisFault {
+
+        // copying important configuration stuff
+        sm.setResponse(true);
+        // as agreed upone
+        mcn.setTo(null);
+        Object os = mco
+                .getProperty(MessageContext.TRANSPORT_OUT);
+        mcn.setProperty(MessageContext.TRANSPORT_OUT, os);
+        TransportInDescription ti = mco.getTransportIn();
+        mcn.setTransportIn(ti);
+        mcn.setServerSide(true);
+
+        AxisEngine ae = new AxisEngine(mco.getConfigurationContext());
+        ae.send(mcn);
+
+
+    }
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingInMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingInMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingInMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingInMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.builtin.axis2;
+
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.OperationContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisModule;
+
+
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+
+
+
+
+
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * <p/>
+ * This class turns on the addressing module and then calls an empty
+ * service There's probably a better way but this should work!
+ */
+public class AddressingInMediator implements Mediator{
+    private Log log = LogFactory.getLog(getClass());
+
+
+    public boolean mediate(SynapseMessage smc) {
+        log.debug("Processing __AddressingInHandler__");
+        try {
+            MessageContext mc = ((Axis2SynapseMessage)smc).getMessageContext();
+
+            // for this execution chain set Addressing as processed
+            smc.setProperty(Constants.ENGAGE_ADDRESSING_IN_MESSAGE,Boolean.TRUE);
+
+            // default configuration_contex and axis_configuration
+            ConfigurationContext cc = mc.getConfigurationContext();
+            AxisConfiguration ac = cc.getAxisConfiguration();
+            AxisService as = ac.getService(Constants.EMPTYMEDIATOR);
+            if (as == null)
+                throw new SynapseException("cannot locate service "
+                        + Constants.EMPTYMEDIATOR);
+            // Engagin addressing
+
+
+            AxisModule module = ac.getModule(new QName("addressing"));
+            if (module == null)
+                throw new SynapseException("cannot locate addressing module in the repository ");
+
+            if (!as.isEngaged(module.getName())) {
+                as.engageModule(module, ac);
+            }
+
+//            ac.engageModule(new QName("addressing"));
+
+            AxisEngine ae = new AxisEngine(cc);
+            AxisOperation ao = as
+                    .getOperation(Constants.MEDIATE_OPERATION_NAME);
+            OperationContext oc = OperationContextFactory
+                    .createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+            ao.registerOperationContext(mc,oc);
+            ServiceContext sc = Utils.fillContextInformation(as, cc);
+            oc.setParent(sc);
+            mc.setAxisOperation(ao);
+            mc.setAxisService(as);
+            ae.receive(mc);
+            // purpose of addressing is over now disengage addressing
+//            ac.disEngageModule(addressingModule);
+            if (as.isEngaged(module.getName())) {
+                ac.disEngageModule(ac.getModule(module.getName()));
+            }
+
+
+        } catch (AxisFault axisFault) {
+            throw new SynapseException(
+                    "__AddresingInHandler__ caught an Exception" +
+                            axisFault.getMessage());
+        }
+        return true;
+    }
+
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingOutMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingOutMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingOutMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/AddressingOutMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,30 @@
+package org.apache.synapse.mediators.builtin.axis2;
+
+import org.apache.synapse.api.Mediator;
+
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Constants;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class AddressingOutMediator implements Mediator {
+    public boolean mediate(SynapseMessage sm) {
+        // engage addressing outhandler in the out bound message. 
+        sm.setProperty(Constants.ENGAGE_ADDRESSING_OUT_BOUND_MESSAGE, Boolean.TRUE);
+        return true;
+    }
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/FaultMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/FaultMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/FaultMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/FaultMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.builtin.axis2;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.Mediator;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDocument;
+
+import javax.xml.namespace.QName;
+
+/**
+ * <p/> This returns a fault in response to this message
+ */
+public class FaultMediator implements Mediator{
+
+    private Log log = LogFactory.getLog(getClass());
+
+    private QName faultCode;
+    private String reason;
+
+    public boolean mediate(SynapseMessage smc) {
+        log.debug("process");
+
+        SOAPEnvelope envelop = smc.getEnvelope();
+        SOAPFactory factory;
+        if (envelop != null) {
+            if (envelop.getNamespace().getName().equals(
+                    SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+                factory = OMAbstractFactory.getSOAP12Factory();
+            } else {
+                factory = OMAbstractFactory.getSOAP11Factory();
+            }
+
+        } else {
+            factory = OMAbstractFactory.getSOAP11Factory();
+        }
+        try {
+            // TODO : Figure out how to easily gen the correct fault
+
+            // Replace this
+            OMDocument soapFaultDocument = factory.createOMDocument();
+            SOAPEnvelope faultEnvelope = factory.getDefaultFaultEnvelope();
+            soapFaultDocument.addChild(faultEnvelope);
+
+            smc.setEnvelope(faultEnvelope);
+        } catch (Exception e) {
+            throw new SynapseException(e);
+        }
+        smc.setResponse(true);
+
+        // Flipping the headers
+        EndpointReference tempEPR = smc.getTo();
+        smc.setTo(smc.getReplyTo());
+        smc.setReplyTo(tempEPR);
+
+        smc.getSynapseEnvironment().injectMessage(smc);
+
+        return false;
+    }
+
+    public QName getFaultCode() {
+        return faultCode;
+    }
+
+    public void setFaultCode(QName faultCode) {
+        this.faultCode = faultCode;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/SecurityMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/SecurityMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/SecurityMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/axis2/SecurityMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,79 @@
+package org.apache.synapse.mediators.builtin.axis2;
+
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.OperationContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+public class SecurityMediator implements Mediator {
+    private Log log = LogFactory.getLog(getClass());
+
+    public boolean mediate(SynapseMessage sm) {
+        log.debug("process");
+		try {
+			MessageContext mc = ((Axis2SynapseMessage) sm)
+					.getMessageContext();
+			ConfigurationContext cc = mc.getConfigurationContext();
+			AxisConfiguration ac = cc.getAxisConfiguration();
+			AxisEngine ae = new AxisEngine(cc);
+			AxisService as = ac.getService(Constants.SECURITY_QOS);
+			if (as == null)
+				throw new SynapseException("cannot locate service "
+                        + Constants.SECURITY_QOS);
+			ac.engageModule(new QName("security"));
+			AxisOperation ao = as
+					.getOperation(Constants.MEDIATE_OPERATION_NAME);
+			OperationContext oc = OperationContextFactory
+					.createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+			ao.registerOperationContext(mc, oc);
+
+			ServiceContext sc = Utils.fillContextInformation(as, cc);
+			oc.setParent(sc);
+
+			mc.setOperationContext(oc);
+			mc.setServiceContext(sc);
+
+			mc.setAxisOperation(ao);
+			mc.setAxisService(as);
+
+			ae.receive(mc);
+
+		} catch (AxisFault e) {
+			throw new SynapseException(e);
+		}
+		return true;
+    }
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,91 @@
+package org.apache.synapse.mediators.builtin.xslt;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+
+/**
+ *
+ * @see org.apache.synapse.mediators.base.builtin.xslt.XSLTProcessorConfigurator
+ * <p> This class is the class that transforms messages using XSLT. 
+ *   
+
+ *
+ */
+public class XSLTMediator implements Mediator {
+
+    private Transformer tran = null;
+
+    private boolean isBody = false;
+
+    public boolean mediate(SynapseMessage smc) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        XMLStreamWriter xsw;
+        try {
+            xsw = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
+
+        if (isBody) smc.getEnvelope().getBody().serialize(xsw);
+        else smc.getEnvelope().serialize(xsw);
+
+        Source src = new StreamSource(new ByteArrayInputStream(baos.toByteArray()));
+        ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
+        StreamResult result = new StreamResult(baos2);
+        tran.transform(src, result);
+        StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(baos2.toByteArray()));
+        OMElement nw = builder.getDocumentElement();
+        if (isBody) smc.getEnvelope().setFirstChild(nw);
+        //TODO don't assume SOAP 1.1
+        else smc.setEnvelope(OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope(builder));
+
+        } catch (Exception e) {
+            throw new SynapseException(e);
+        }
+        return true;
+    }
+
+    /**
+     * @param b
+     * <p> If isBody is true then the XSLT is applied to the Body of the SOAP message, otherwise to the whole env
+     */
+    public void setIsBody(boolean b) {
+        isBody  = b;
+    }
+
+
+    /**
+     * @param is
+     * <p>
+     * This sets the correct XSL transform
+     */
+    public void setXSLInputStream(InputStream is) {
+        try {
+            Source src = new StreamSource(is);
+            tran = TransformerFactory.newInstance().newTransformer(src);
+        } catch (Exception e) {
+            throw new SynapseException(e);
+
+        }
+    }
+
+}
+
+	

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/xslt/XSLTMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,56 @@
+package org.apache.synapse.mediators.builtin.xslt;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.xml.AbstractMediatorFactory;
+import org.apache.synapse.xml.Constants;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+
+
+
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+
+/**
+ *
+ * @see org.apache.synapse.mediators.base.builtin.xslt.XSLTProcessor
+ * <p> This class configures the XSLT transformer 
+ * <p> The tag looks like this
+ * <xmp><xslt name="x" xsl="file.xsl" type="body|envelope"/></xmp>
+ *  Perform the given XSLT on the SOAP-Envelope or Body 
+ *  <p>If type is not present, assumed to be body
+ */
+public class XSLTMediatorFactory extends AbstractMediatorFactory {
+    private static final QName tagName = new QName(Constants.SYNAPSE_NAMESPACE, "xslt");
+
+    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+        XSLTMediator xm = new XSLTMediator();
+        super.setNameOnMediator(se,el,xm);
+
+        OMAttribute type = el.getAttribute(new QName("type"));
+        if (type != null && type.getAttributeValue().trim().toLowerCase().equals("envelope")) xm.setIsBody(false);
+        else xm.setIsBody(true);
+
+        OMAttribute xsl = el.getAttribute(new QName("xsl"));
+        if (xsl == null) throw new SynapseException("no xsl attribute on: "+el.toString());
+
+        InputStream xslStream =  se.getClassLoader().getResourceAsStream(xsl.getAttributeValue());
+        xm.setXSLInputStream(xslStream);
+
+        return xm;
+
+    }
+
+    public QName getTagQName() {
+
+        return tagName;
+    }
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/AbstractFilterMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/AbstractFilterMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/AbstractFilterMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/AbstractFilterMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.filters;
+
+
+
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseMessageConstants;
+import org.apache.synapse.mediators.base.AbstractListMediator;
+
+
+/**
+ *	This is a base type for "conditional" mediators. Any mediator that is used in "only once"
+ *  processing should be an extension of this. This makes sure that the matched property gets set properly
+ *  
+ *        
+ */
+public abstract class AbstractFilterMediator extends AbstractListMediator {
+
+	//private Log log = LogFactory.getLog(getClass());
+
+	public boolean mediate(SynapseMessage smc) {
+		if (this.test(smc)) {
+		    smc.setProperty(SynapseMessageConstants.MATCHED,Boolean.TRUE);
+		    return super.mediate(smc);
+		}
+		else
+		{
+			 smc.setProperty(SynapseMessageConstants.MATCHED,Boolean.FALSE);
+			 return true;
+		}
+	}
+	
+	public abstract boolean test(SynapseMessage sm);
+	
+
+	
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/DefaultMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/DefaultMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/DefaultMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/DefaultMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,26 @@
+package org.apache.synapse.mediators.filters;
+
+import org.apache.synapse.SynapseMessage;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class DefaultMediator extends AbstractFilterMediator {
+   
+	public boolean test(SynapseMessage sm) {
+		return true;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/ExactlyOneMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/ExactlyOneMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/ExactlyOneMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/ExactlyOneMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,53 @@
+package org.apache.synapse.mediators.filters;
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseMessageConstants;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.AbstractListMediator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Corresponding to <exactly/> This conatins conditional mediators such as
+ * <regex/> and <xpath/> It will look for the first match, if the first match is
+ * true then all the other mediators listed thereafter will be ingnored
+ */
+public class ExactlyOneMediator extends AbstractListMediator {
+
+	private Log log = LogFactory.getLog(getClass());
+
+public boolean mediate( SynapseMessage smc) {
+        log.debug("ExactlyOneMediator");
+        List mediators = getList(); // from parent
+        if (mediators == null || mediators.size()==0) {
+            log.info("no mediators called -  empty list");
+            return true;
+        }
+        Iterator it = mediators.iterator();
+                
+        while (it.hasNext()) {
+            Mediator m = (Mediator) it.next();
+            log.debug(m.getClass());
+            
+            boolean cont = m.mediate(smc);
+            if (!cont) return false; // if any mediator says finish then
+										// finish
+            
+            if (smc.getProperty(SynapseMessageConstants.MATCHED) == null) {
+            	// should never get here --- famous last words.
+            	log.error("Condition mediator "+m.getClass()+" did not properly signal matching");
+            	return true;  
+            }
+            	
+            boolean matched = ((Boolean) smc.getProperty(
+                         SynapseMessageConstants.MATCHED))
+                         .booleanValue();
+            if (matched) return true;      
+        }
+        return true;
+    }
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/RegexMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/RegexMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/RegexMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/RegexMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.filters;
+
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.synapse.HeaderType;
+import org.apache.synapse.SynapseMessage;
+
+
+
+/**
+ *
+ * <p>
+ * This checks the pattern against a property and if true processes the message with its child or children
+ * <p>
+ * TODO add to the set of properties you can search
+ * 
+ * 
+ */
+public class RegexMediator extends AbstractFilterMediator {
+	private Pattern pattern = null;
+
+	private Log log = LogFactory.getLog(getClass());
+
+	private HeaderType headerType = new HeaderType();
+
+	private String property = null;
+
+	public void setHeaderType(String header) {
+		headerType.setHeaderType(header);
+	}
+
+	public String getHeaderType() {
+		return headerType.getHeaderType();
+	}
+
+	public void setPattern(String p) {
+		pattern = Pattern.compile(p);
+	}
+
+	public String getPattern() {
+		return pattern.toString();
+	}
+
+	public void setPropertyName(String p) {
+		this.property = p;
+	}
+
+	public String getPropertyName() {
+		return property;
+	}
+
+	public boolean test(SynapseMessage smc) {
+
+		if (pattern == null) {
+			log.debug("trying to process with empty pattern");
+			return true;
+		}
+
+        String toMatch;
+		if (property != null) {
+			toMatch = smc.getProperty(property).toString();
+		} else {
+			toMatch = headerType.getHeader(smc);
+		}
+
+		if (toMatch==null) return false;  
+
+		if (pattern.matcher(toMatch).matches()) {
+            if (log.isDebugEnabled()) {
+                log.debug("Regex pattern " + pattern.pattern() + " matched "
+                        + toMatch);
+            }
+            return true;
+		}
+
+        if (log.isDebugEnabled()) {
+            log.debug("Regex pattern '" + pattern.pattern() +
+                    "' failed to match '" + toMatch);
+        }
+        return false;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/XPathMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/XPathMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/XPathMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/XPathMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.filters;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseMessageConstants;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.jaxen.JaxenException;
+
+/**
+ *
+ * 
+ * <p>
+ * This class executes an XPath test against the message envelope and then processes all subsequent rules/mediations
+ * if the test is true
+ * <p>
+ * TODO add the context into the XPath matching space
+ * 
+ */
+public class XPathMediator extends AbstractFilterMediator {
+
+	private Log log = LogFactory.getLog(getClass());
+
+	private AXIOMXPath xp = null;
+
+
+	public boolean test(SynapseMessage smc) {
+		if (xp == null) {
+			log.debug("trying to process xpath without being set");
+			return true;
+		}
+		try {
+			if (xp.booleanValueOf(smc.getEnvelope())) {
+				log.debug("matched xpath: " + xp.toString());
+				// now do "all"
+                smc.setProperty(SynapseMessageConstants.MATCHED,Boolean.TRUE);
+                return true;
+			}
+
+		} catch (JaxenException je) {
+			throw new SynapseException("Problem evaluating " + xp.toString(),
+					je);
+		}
+		return false;
+	}
+
+	public void setXPathExpr(String expr) {
+		try {
+			xp = new AXIOMXPath(expr);
+		} catch (JaxenException je) {
+			throw new SynapseException(je);
+		}
+	}
+
+	public String getXPathExpr() {
+		return xp.toString();
+	}
+
+	public void addXPathNamespace(String prefix, String uri) {
+		try {
+			xp.addNamespace(prefix, uri);
+		} catch (JaxenException je) {
+			throw new SynapseException(je);
+		}
+
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/ClassMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/ClassMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/ClassMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/ClassMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,64 @@
+/*
+ * 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.types;
+
+
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.Mediator;
+
+
+/**
+ *
+ * 
+ * This executes the "mediate" operation on a new instance of the specified class
+ * 
+ * TODO add support for simple properties to be set
+ *
+ */
+public class ClassMediator implements Mediator{
+
+	private Class clazz = null;
+
+	
+
+	public boolean mediate(SynapseMessage smc) {
+		Mediator m = null;
+
+		try {
+			m = (Mediator) getClazz().newInstance();
+		} catch (Exception e) {
+			throw new SynapseException(e);
+		}
+		/*if (EnvironmentAware.class.isAssignableFrom(m.getClass())) {
+			((EnvironmentAware) m).setSynapseEnvironment(se);
+		}*/
+		return m.mediate(smc);
+
+	}
+
+	
+	public void setClazz(Class clazz) {
+		this.clazz = clazz;
+	}
+
+	public Class getClazz() {
+		return clazz;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/axis2/ServiceMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/axis2/ServiceMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/axis2/ServiceMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/types/axis2/ServiceMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.mediators.types.axis2;
+
+
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.OperationContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.Utils;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+
+
+/**
+ *
+ * <p>
+ * This class executes a service in the "owning" axis2 engine.
+ * The service operation will be "mediate" and the service name is set as the ServiceName property
+ * 
+ *
+ */
+public class ServiceMediator implements Mediator {
+	
+
+	private String serviceName = null;
+
+	public boolean mediate(SynapseMessage smc) {
+		MessageContext messageContext = null;
+		try {
+			messageContext = ((Axis2SynapseMessage) smc)
+					.getMessageContext();
+		} catch (ClassCastException cce) {
+			throw new SynapseException(
+					"A non-Axis2 MC SOAPMessageContext has been passed to the Axis2 MediationExecutor",
+					cce);
+		}
+
+		
+
+		try {
+			ConfigurationContext cc = messageContext.getConfigurationContext();
+			AxisConfiguration ac = cc.getAxisConfiguration();
+			AxisEngine ae = new AxisEngine(cc);
+
+			AxisService as = null;
+			AxisOperation ao = null;
+			
+			as = ac.getService(getServiceName());
+			if (as == null)
+				throw new SynapseException("cannot locate service "
+						+ getServiceName());
+			
+			ao = as.getOperation(Constants.MEDIATE_OPERATION_NAME);
+			OperationContext oc = OperationContextFactory
+					.createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+			ao.registerOperationContext(messageContext, oc);
+
+			ServiceContext sc = Utils.fillContextInformation(as, cc);
+			oc.setParent(sc);
+
+			messageContext.setOperationContext(oc);
+			messageContext.setServiceContext(sc);
+
+			messageContext.setAxisOperation(ao);
+			messageContext.setAxisService(as);
+
+			ae.receive(messageContext);
+
+		} catch (AxisFault e) {
+			throw new SynapseException(e);
+
+		}
+
+		return ((Boolean) messageContext
+				.getProperty(Constants.MEDIATOR_RESPONSE_PROPERTY))
+				.booleanValue();
+
+	}
+
+	public void setServiceName(String serviceName) {
+		this.serviceName = serviceName;
+	}
+
+	public String getServiceName() {
+		return serviceName;
+	}
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/registry/Registry.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/registry/Registry.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/registry/Registry.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/registry/Registry.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,22 @@
+package org.apache.synapse.registry;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReference;
+//import org.apache.ws.commons.schema.XmlSchema;
+//import org.apache.ws.policy.Policy;
+//import org.apache.wsdl.WSDLDescription;
+
+public interface Registry {
+	public OMElement getXML(String identifier);
+	public String getString(String identifier);
+	public String getURI(String identifier); // guaranteed a URI
+	public EndpointReference getEPR(String identifier);
+	public List getURIList(String identifier); // could be a list of links to other entries
+//	public Policy getPolicy(String identifier);
+//	public XmlSchema getSchema(String identifier);
+//	public WSDLDescription getWSDL(String identifier);
+	public Properties getProperties(String identifier); 
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHandler.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHandler.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHandler.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHandler.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,30 @@
+package org.apache.synapse.resources;
+
+import org.apache.axiom.om.OMElement;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public interface ResourceHandler {
+    OMElement get(String uri);
+
+    void setProperty(String name, String value);
+    String getProperty(String name);
+    String[] getPropertyNames();
+
+    boolean isUpdated(String uriRoot); // used to poll if resource has changed (Pull model)
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelper.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelper.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelper.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelper.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,33 @@
+/*
+ * 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.resources;
+
+import org.apache.synapse.api.ResourceUpdateAware;
+import org.apache.axiom.om.OMElement;
+
+/**
+ *
+ */
+public interface ResourceHelper {
+
+    OMElement get(String uri); // get a resource
+    OMElement get(String uri, ResourceUpdateAware mediator); // get a resource and be notified of changes
+    void registerResourceHandler(ResourceHandler rh, String urlRoot);
+         // register a handler for a given set of URLs (which share the same root)
+    void notifyUpdate(String uriRoot);
+         // a resource handler uses this to notify that all resources with that root have changed (Resource Push model)
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,139 @@
+package org.apache.synapse.resources;
+
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.resources.xml.ResourceMediator;
+import org.apache.synapse.resources.xml.PropertyMediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ResourceHelperFactory {
+    private Log log = LogFactory.getLog(getClass());
+
+    private static ResourceHelperFactory fac;
+
+    private static boolean created = false;
+
+    private HashMap resourcesProcessorsMap = new HashMap();
+
+    private ResourceHelperFactory() {
+    }
+
+    public static ResourceHelperFactory newInstance() {
+        if (created) {
+            return fac;
+        } else {
+            fac = new ResourceHelperFactory();
+        }
+        return fac;
+    }
+
+    public ResourceHelper createResourceHelper() {
+        log.debug("Creating resources helper");
+        ResourceHelperImpl helper = new ResourceHelperImpl();
+        if (resourcesProcessorsMap==null) {throw new SynapseException("null resources map");}
+        log.debug("size of resources list "+resourcesProcessorsMap.size());
+        for (Iterator ite = resourcesProcessorsMap.keySet().iterator();
+             ite.hasNext();) {
+
+            String key = (String) ite.next();
+
+            Object obj = resourcesProcessorsMap.get(key);
+
+            if (obj instanceof ResourceMediator) {
+                ResourceMediator rp = (ResourceMediator) obj;
+                // getting the resource handler
+                ResourceHandler rh = getResourceHandler(rp.getType());
+                //filling the propertybags of ResourceHanlder
+                fillResourceHandler(rp,rh);
+                helper.registerResourceHandler(rh,rp.getURIRoot());
+                log.debug(">created helper for "+rp.getURIRoot());
+            } else {
+                throw new SynapseException(
+                        "Should be found only ResourceHandler implementations");
+            }
+
+        }
+        return helper;
+    }
+
+    private void fillResourceHandler(ResourceMediator rm, ResourceHandler rh) {
+        //filling the ResourcesHandlers properties
+        List rms = rm.getList();
+
+        for (Iterator ite = rms.iterator();ite.hasNext();) {
+            Object obj = ite.next();
+            if (obj instanceof PropertyMediator) {
+                PropertyMediator pp = (PropertyMediator)obj;
+                rh.setProperty(pp.getName(),pp.getValue());
+            } else {
+                throw new SynapseException("Support only PropertyMediator, found :" + obj.getClass().getName());
+            }
+        }
+
+
+
+    }
+
+    public void addResourceMediator(String uri, ResourceMediator rm) {
+    	resourcesProcessorsMap.put(uri, rm);
+    }
+    public ResourceMediator getResourceMediator(String uri) {
+    	return (ResourceMediator)resourcesProcessorsMap.get(uri);
+    }
+    public void setResourceProcessorsMap(HashMap resourceProcessorsMap) {
+        this.resourcesProcessorsMap = resourceProcessorsMap;
+    }
+
+    private ResourceHandler getResourceHandler(String clazzName) {
+        ResourceHandler handler;
+        try {
+            Class clazz = Class.forName(clazzName);
+            Constructor ct = clazz.getConstructor(new Class[]{});
+            Object obj = ct.newInstance(new Object[]{});
+
+            if (obj instanceof ResourceHandler) {
+                handler = (ResourceHandler) obj;
+            } else {
+                throw new SynapseException(
+                        "Only Objects implements ResourceHandler should be available");
+            }
+            return handler;
+        } catch (ClassNotFoundException e) {
+            throw new SynapseException(e);
+        } catch (IllegalAccessException e) {
+            throw new SynapseException(e);
+        } catch (NoSuchMethodException e) {
+            throw new SynapseException(e);
+        } catch (InvocationTargetException e) {
+            throw new SynapseException(e);
+        } catch (InstantiationException e) {
+            throw new SynapseException(e);
+        }
+
+    }
+
+
+
+}



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


Mime
View raw message