synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r399252 [1/2] - in /incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse: ./ api/ axis2/ config/ mediators/ mediators/base/ mediators/builtin/ mediators/ext/ mediators/filters/ mediators/transform/
Date Wed, 03 May 2006 10:58:26 GMT
Author: saminda
Date: Wed May  3 03:58:21 2006
New Revision: 399252

URL: http://svn.apache.org/viewcvs?rev=399252&view=rev
Log:
Rename SynapseEnvironment as SynapseContext and perform more cleanup/refactpring.. is still WIP and is not yet ready..

Added:
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseContext.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContext.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContextFinder.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SequenceMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java
Removed:
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseEnvironment.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseEnvironment.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseEnvironmentFinder.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfigurationFactory.java
Modified:
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Constants.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseMessage.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/ListMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseMessage.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractListMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ClassMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/Constants.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/DropMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/LogMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SendMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ServiceMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseMediatorFactory.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ServiceMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
    incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/transform/XSLTMediator.java

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Constants.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Constants.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/Constants.java Wed May  3 03:58:21 2006
@@ -29,16 +29,16 @@
     QName MEDIATE_OPERATION_NAME = new QName("mediate");
 
     String MEDIATOR_RESPONSE_PROPERTY = "synapse.mediator.response";
-    String MEDIATOR_SYNAPSE_ENV_PROPERTY = "synapse.mediator.environment";
+    String MEDIATOR_SYNAPSE_CTX_PROPERTY = "synapse.mediator.environment";
 
     String ISRESPONSE_PROPERTY = "synapse.isresponse";
 
     String EMPTYMEDIATOR = "emptymediator";
 
     //this is for the synapse.config config
-    String SYNAPSECONFIGURATION = "SynapseConfiguration";
+    String SYNAPSE_CONFIGURATION = "SynapseConfiguration";
 
-    String SYNAPSE_ENVIRONMENT = "synapse.environment";
+    String SYNAPSE_CONTEXT = "synapse.context";
 
     String ADD_ADDRESSING = "synapse.send.useaddressing";
 

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseContext.java?rev=399252&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseContext.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseContext.java Wed May  3 03:58:21 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;
+
+
+import org.apache.synapse.config.SynapseConfiguration;
+
+
+/**
+ * The Synapse Environment is available to mediators through the SynapseMessage. It
+ * allows one to call to the underlying SOAP engine (such as Axis2) where required.
+ * e.g. send message, get classloader etc. It also holds a reference to the current
+ * SynapseConfiguration.
+ */
+public interface SynapseContext {
+
+    /*
+    * This method injects a new message into the Synapse engine
+    * It is used in a couple of ways. Firstly, this is how, for example,
+    * Axis2 kicks messages into Synapse to start with.
+    * <p>
+    * Also mediators can use this to send messages that they want to be mediated by Synapse
+    * <p>For example if you want to send a copy of a message somewhere, you can clone it and then
+    * injectMessage()
+    */
+    public void injectMessage(SynapseMessage smc);
+
+    /*
+     * Mediators that wish to load classes should use the ClassLoader given here
+     */
+    public ClassLoader getClassLoader();
+
+    /**
+     * This method allows you send messages on. As opposed to injectMessage send message does not
+     * process these through Synapse.
+     * <p/>
+     * This will send request messages on, and send response messages back to the client
+     */
+    public void send(SynapseMessage smc);
+
+    /**
+     * Get a reference to the current SynapseConfiguration
+     *
+     * @return the current synapse configuration
+     */
+    public SynapseConfiguration getConfiguration();
+
+    /**
+     * Set or replace the Synapse Configuration instance to be used
+     *
+     * @param cfg The new synapse configuration instance
+     */
+    public void setConfiguration(SynapseConfiguration cfg);
+
+}

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseMessage.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseMessage.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseMessage.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/SynapseMessage.java Wed May  3 03:58:21 2006
@@ -91,7 +91,7 @@
 
     public boolean isFaultResponse();
 
-    public SynapseEnvironment getSynapseEnvironment();
+    public SynapseContext getSynapseContext();
 
-    public void setSynapseEnvironment(SynapseEnvironment env);
+    public void setSynapseContext(SynapseContext env);
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/ListMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/ListMediator.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/ListMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/ListMediator.java Wed May  3 03:58:21 2006
@@ -1,3 +1,18 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 package org.apache.synapse.api;
 
 import java.util.List;
@@ -16,6 +31,4 @@
     public Mediator removeChild(int pos);
 
     public List getList();
-
-    public void setList(List l); //TODO do we need this?
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/api/Mediator.java Wed May  3 03:58:21 2006
@@ -24,5 +24,5 @@
 public interface Mediator {
     public boolean mediate(SynapseMessage smc);
 
-    public String getName();
+    public String getType();
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java Wed May  3 03:58:21 2006
@@ -26,7 +26,7 @@
 
 
 /**
- * This class helps the Axis2SynapseEnvironment implement the send method
+ * This class helps the Axis2SynapseContext implement the send method
  */
 public class Axis2Sender {
 
@@ -72,11 +72,11 @@
 
             outMsgContext.setTransportIn(ti);
 
-            if (smc.getSynapseEnvironment() == null) {
+            if (smc.getSynapseContext() == null) {
                 throw new SynapseException("no Synapse Env set on message");
             }
-            smc.getSynapseEnvironment().injectMessage(new Axis2SynapseMessage(
-                outMsgContext, smc.getSynapseEnvironment()));
+            smc.getSynapseContext().injectMessage(new Axis2SynapseMessage(
+                outMsgContext, smc.getSynapseContext()));
         } catch (Exception e) {
             e.printStackTrace();
             throw new SynapseException(e);

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContext.java?rev=399252&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContext.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContext.java Wed May  3 03:58:21 2006
@@ -0,0 +1,71 @@
+/*
+ * 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.config.SynapseConfigurationBuilder;
+
+import java.io.InputStream;
+
+/**
+ * <p> This is the Axis2 implementation of the SynapseContext
+ */
+public class Axis2SynapseContext implements SynapseContext {
+
+    private ClassLoader cl = null;
+    private SynapseConfiguration config = null;
+    private Log log = LogFactory.getLog(getClass());
+
+    public Axis2SynapseContext(InputStream is, ClassLoader cl) {
+        super();
+        this.cl = cl;
+        new SynapseConfigurationBuilder().setConfiguration(this, is);
+    }
+
+    public void injectMessage(SynapseMessage smc) {
+        smc.setSynapseContext(this);
+        getConfiguration().getMainMediator().mediate(smc);
+    }
+
+    public void send(SynapseMessage sm) {
+        if (sm.isResponse())
+            Axis2Sender.sendBack(sm);
+        else
+            Axis2Sender.sendOn(sm);
+    }
+
+    public ClassLoader getClassLoader() {
+        return cl;
+    }
+
+    public void setClassLoader(ClassLoader cl) {
+        this.cl = cl;
+    }
+
+    public SynapseConfiguration getConfiguration() {
+        return config;
+    }
+
+    public void setConfiguration(SynapseConfiguration cfg) {
+        this.config = cfg;
+    }
+
+}

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContextFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContextFinder.java?rev=399252&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContextFinder.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseContextFinder.java Wed May  3 03:58:21 2006
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.synapse.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseException;
+
+import java.io.InputStream;
+
+/**
+ * <p/>
+ * The SynapseContext needs to be set up and then is used by the SynapseMessageReceiver to inject messages.
+ * This class is used by the SynapseMessageReceiver to find the environment. The env is stored in a Parameter to the Axis2 config
+ */
+public class Axis2SynapseContextFinder implements Constants {
+
+    private static Log log = LogFactory.getLog(Axis2SynapseContextFinder.class);
+
+    public static synchronized SynapseContext getSynapseContext(MessageContext mc) {
+
+        AxisConfiguration ac = mc.getConfigurationContext().getAxisConfiguration();
+        Parameter synapseCtxParam = ac.getParameter(SYNAPSE_CONTEXT);
+
+        if (synapseCtxParam == null) {
+
+            log.debug("Synapse Context not available. Creating...");
+            Parameter param = ac.getParameter(SYNAPSE_CONFIGURATION);
+
+            if (param == null) {
+                throw new SynapseException("Axis2 configuration does not specify a '" +
+                    SYNAPSE_CONFIGURATION + "' parameter");
+            }
+
+            String synapseConfig = (String) param.getValue();
+            InputStream is = mc.getAxisService().getClassLoader().getResourceAsStream(synapseConfig.trim());
+
+            Axis2SynapseContext synCtx = new Axis2SynapseContext(is, mc.getAxisService().getClassLoader());
+            setSynapseContext(mc, synCtx);
+        }
+        return (SynapseContext) ac.getParameter(SYNAPSE_CONTEXT).getValue();
+    }
+
+    public static synchronized void setSynapseContext(MessageContext mc, SynapseContext synCtx) {
+
+        AxisConfiguration ac = mc.getConfigurationContext().getAxisConfiguration();
+        Parameter synapseCtxParam = new Parameter(SYNAPSE_CONTEXT, null);
+        synapseCtxParam.setValue(synCtx);
+
+        try {
+            ac.addParameter(synapseCtxParam);
+        } catch (AxisFault e) {
+            String msg = "Could not add parameter '" + SYNAPSE_CONTEXT + "' to the Axis2 configuration";
+            log.error(msg);
+            throw new SynapseException(msg, e);
+        }
+    }
+
+}

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseMessage.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseMessage.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseMessage.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/Axis2SynapseMessage.java Wed May  3 03:58:21 2006
@@ -22,7 +22,7 @@
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.context.MessageContext;
 import org.apache.synapse.Constants;
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.SynapseMessage;
 
 import java.util.HashMap;
@@ -43,9 +43,9 @@
 
     private boolean faultResponse = false;
 
-    public Axis2SynapseMessage(MessageContext mc, SynapseEnvironment se) {
+    public Axis2SynapseMessage(MessageContext mc, SynapseContext se) {
         setMessageContext(mc);
-        setSynapseEnvironment(se);
+        setSynapseContext(se);
     }
 
     public EndpointReference getFaultTo() {
@@ -211,12 +211,12 @@
         return this.faultResponse;
     }
 
-    public SynapseEnvironment getSynapseEnvironment() {
-        return Axis2SynapseEnvironmentFinder.getSynapseEnvironment(mc);
+    public SynapseContext getSynapseContext() {
+        return Axis2SynapseContextFinder.getSynapseContext(mc);
     }
 
-    public void setSynapseEnvironment(SynapseEnvironment env) {
-        Axis2SynapseEnvironmentFinder.setSynapseEnvironment(mc, env);
+    public void setSynapseContext(SynapseContext synCtx) {
+        Axis2SynapseContextFinder.setSynapseContext(mc, synCtx);
         return;
     }
 

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java Wed May  3 03:58:21 2006
@@ -14,15 +14,15 @@
         Mediator mediator = (Mediator) obj;
 /*
         if (EnvironmentAware.class.isAssignableFrom(mediator.getClass())) {
-            SynapseEnvironment se = (SynapseEnvironment) messageContext
-                    .getProperty(Constants.MEDIATOR_SYNAPSE_ENV_PROPERTY);
-            ((EnvironmentAware) mediator).setSynapseEnvironment(se);
+            SynapseContext se = (SynapseContext) messageContext
+                    .getProperty(Constants.MEDIATOR_SYNAPSE_CTX_PROPERTY);
+            ((EnvironmentAware) mediator).setSynapseContext(se);
             ((EnvironmentAware) mediator).setClassLoader(
                     messageContext.getAxisService().getClassLoader());
         }
         
 */
-        SynapseMessage smc = new Axis2SynapseMessage(messageContext, Axis2SynapseEnvironmentFinder.getSynapseEnvironment(messageContext));
+        SynapseMessage smc = new Axis2SynapseMessage(messageContext, Axis2SynapseContextFinder.getSynapseContext(messageContext));
         boolean returnValue = mediator.mediate(smc);
         messageContext.setProperty(Constants.MEDIATOR_RESPONSE_PROPERTY,
             new Boolean(returnValue));

Modified: 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=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java Wed May  3 03:58:21 2006
@@ -21,7 +21,7 @@
 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.SynapseContext;
 import org.apache.synapse.SynapseMessage;
 
 /**
@@ -35,17 +35,17 @@
 
     public void receive(MessageContext mc) throws AxisFault {
         log.debug("receiving message");
-        SynapseEnvironment env = Axis2SynapseEnvironmentFinder
-            .getSynapseEnvironment(mc);
+        SynapseContext synCtx = Axis2SynapseContextFinder
+            .getSynapseContext(mc);
         ////////////////////////////////////////////////////////////////////////
-        // SynapseEnvironment is set as a property in MessageContext. This is due
+        // SynapseContext 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);
+        SynapseMessage smc = new Axis2SynapseMessage(mc, synCtx);
+        smc.setSynapseContext(synCtx);
+        synCtx.injectMessage(smc);
 
         ///////////////////////////////////////////////////////////////////////
         // Response handling mechanism for 200/202 and 5XX

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractListMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractListMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractListMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractListMediatorFactory.java Wed May  3 03:58:21 2006
@@ -13,17 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
 
 
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseException;
 import org.apache.synapse.api.ListMediator;
 import org.apache.synapse.api.Mediator;
 import org.apache.axiom.om.OMElement;
@@ -37,24 +34,20 @@
  */
 public abstract class AbstractListMediatorFactory extends AbstractMediatorFactory {
 
-    Log log = LogFactory.getLog(getClass());
-
-    public void addChildrenAndSetName(SynapseEnvironment se, OMElement el, ListMediator m)
+    public void addChildren(SynapseContext synCtx, OMElement el, ListMediator m)
     {
-        super.setNameOnMediator(se, el, m);
-
         Iterator it = el.getChildElements();
-        List mediators = new LinkedList();
         while (it.hasNext()) {
             OMElement child = (OMElement) it.next();
-            Mediator med = MediatorFactoryFinder.getMediator(se, child);
-            if (med != null)
-                mediators.add(med);
-            else
-                log.info("Unknown child of all" + child.getLocalName());
+            Mediator med = MediatorFactoryFinder.getInstance().getMediator(synCtx, child);
+            if (med != null) {
+                m.addChild(med);
+            } else {
+                String msg = "Unknown mediator : " + child.getLocalName();
+                log.error(msg);
+                throw new SynapseException(msg);
+            }
         }
-        m.setList(mediators);
-
     }
 
 

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/AbstractMediatorFactory.java Wed May  3 03:58:21 2006
@@ -13,17 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.synapse.xml;
-
-import javax.xml.namespace.QName;
+package org.apache.synapse.config;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.SynapseEnvironment;
-import org.apache.synapse.api.Mediator;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMAttribute;
 
 /**
  *
@@ -34,20 +27,5 @@
  */
 public abstract class AbstractMediatorFactory implements MediatorFactory {
 
-    private Log log = LogFactory.getLog(getClass());
-   
-    public void setNameOnMediator(SynapseEnvironment se, OMElement el, Mediator m) {
-
-        OMAttribute nm = el.getAttribute(new QName("name"));
-        String name =null;
-        if (nm != null) {
-             name = nm.getAttributeValue().trim();
-            //m.setName(name);
-            //se.addMediator(name, m); TODO fix this later!
-        }
-        log.debug("compile "+el.getLocalName()+" with name '"+name+"' on "+m.getClass());
-
-    }
-
-
+    Log log = LogFactory.getLog(getClass());
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ClassMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ClassMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ClassMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ClassMediatorFactory.java Wed May  3 03:58:21 2006
@@ -13,12 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
 import org.apache.synapse.config.Constants;
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.ext.ClassMediator;
@@ -33,10 +33,8 @@
 public class ClassMediatorFactory extends AbstractMediatorFactory {
     private static final QName CLM_Q = new QName(Constants.SYNAPSE_NAMESPACE,
             "classmediator");
-    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+    public Mediator createMediator(SynapseContext se, OMElement el) {
         ClassMediator cmp = new ClassMediator();
-        super.setNameOnMediator(se, el, cmp);
-
         OMAttribute clsName = el.getAttribute(new QName("class"));
         if (clsName == null)
             throw new SynapseException("missing class attribute on element"

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/Constants.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/Constants.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/Constants.java Wed May  3 03:58:21 2006
@@ -27,6 +27,8 @@
     public static final QName ENDPOINT_ELT = new QName("endpoint");
     public static final QName PROPERTY_ELT = new QName("set-property");
 
+    public static final QName RULES_ELT = new QName("rules");
+
     public static final String SYNAPSE_NAMESPACE = "http://ws.apache.org/ns/synapse";
     public static final String SYNAPSE = "synapse";
     public static final String NULL_NAMESPACE = "";

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/DropMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/DropMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/DropMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/DropMediatorFactory.java Wed May  3 03:58:21 2006
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.config.Constants;
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.builtin.DropMediator;
@@ -27,9 +27,9 @@
 
 public class DropMediatorFactory extends AbstractMediatorFactory {
 
-    private static final QName DROP_Q = new QName(Constants.SYNAPSE_NAMESPACE,
-			"drop");
-    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+    private static final QName DROP_Q = new QName(Constants.SYNAPSE_NAMESPACE, "drop");
+
+    public Mediator createMediator(SynapseContext se, OMElement el) {
         return new DropMediator();
     }
 

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java Wed May  3 03:58:21 2006
@@ -13,15 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.config.Constants;
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.transform.FaultMediator;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
 
 /**
  *
@@ -31,27 +32,59 @@
  * 
  */
 public class FaultMediatorFactory extends AbstractMediatorFactory {
-    private static final QName HEADER_Q = new QName(
-            Constants.SYNAPSE_NAMESPACE, "fault");
 
-    private static final QName FAULTCODE = new QName(
-            Constants.SYNAPSE_NAMESPACE, "faultCode");
-    private static final QName REASON = new QName(
-            Constants.SYNAPSE_NAMESPACE, "reason");
+    private static final QName HEADER_Q = new QName(Constants.SYNAPSE_NAMESPACE, "fault");
 
-    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
-        FaultMediator fp = new FaultMediator();
+    private static final QName ATT_VERSION_Q = new QName(Constants.NULL_NAMESPACE, "version");
+    private static final QName CODE_Q        = new QName(Constants.SYNAPSE_NAMESPACE, "code");
+    private static final QName REASON_Q      = new QName(Constants.SYNAPSE_NAMESPACE, "reason");
 
-        OMElement code = el.getFirstChildWithName(FAULTCODE);
+    private static final QName ATT_VALUE_Q = new QName(Constants.NULL_NAMESPACE, "name");
+    private static final QName ATT_EXPR_Q  = new QName(Constants.NULL_NAMESPACE, "expression");
+
+    private static final String SOAP11 = "soap11";
+    private static final String SOAP12 = "soap12";
+
+    public Mediator createMediator(SynapseContext synMsg, OMElement elem) {
+
+        FaultMediator faultMediator = new FaultMediator();
+
+        OMAttribute version = elem.getAttribute(ATT_VERSION_Q);
+        if (version != null) {
+            if (SOAP11.equals(version.getAttributeValue())) {
+                faultMediator.setSoapVersion(FaultMediator.SOAP11);
+            } else if (SOAP12.equals(version.getAttributeValue())) {
+                faultMediator.setSoapVersion(FaultMediator.SOAP12);
+            }
+        }
+
+/*      TODO revisit later!
+        OMElement code = elem.getFirstChildWithName(CODE_Q);
         if (code != null) {
-            fp.setFaultCode(code.getTextAsQName());
+            OMAttribute value = code.getAttribute(ATT_VALUE_Q);
+            OMAttribute expression = code.getAttribute(ATT_EXPR_Q);
+
+            if (value != null) {
+                faultMediator.setCode(new QName(value.getAttributeValue()));
+            } else if (expression != null) {
+                //faultMediator.setCode();
+            } else {
+                //TODO throw exception
+            }
+
+        } else {
+            //TODO exception
         }
-        OMElement reason = el.getFirstChildWithName(REASON);
+*/
+
+        OMElement reason = elem.getFirstChildWithName(REASON_Q);
         if (reason != null) {
-            fp.setReason(reason.getText());
+            faultMediator.setReason(reason.getText());
+        }else {
+            //TODO exception
         }
-        super.setNameOnMediator(se, el, fp);
-        return fp;
+
+        return faultMediator;
     }
 
     public QName getTagQName() {

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java?rev=399252&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java Wed May  3 03:58:21 2006
@@ -0,0 +1,96 @@
+/*
+* 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.config;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.mediators.filters.FilterMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.jaxen.JaxenException;
+
+import javax.xml.namespace.QName;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+public class FilterMediatorFactory extends AbstractListMediatorFactory {
+
+    private static final QName FILTER_Q    = new QName(Constants.SYNAPSE_NAMESPACE, "filter");
+
+    public Mediator createMediator(SynapseContext synCtx, OMElement elem) {
+        FilterMediator filter = new FilterMediator();
+        super.addChildren(synCtx, elem, filter);
+
+        OMAttribute attXpath  = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "xpath"));
+        OMAttribute attSource = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "source"));
+        OMAttribute attRegex  = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "regex"));
+
+        if (attXpath != null) {
+            if (attXpath.getAttributeValue() != null && attXpath.getAttributeValue().trim().length() == 0) {
+                String msg = "Invalid attribute value specified for xpath";
+                log.error(msg);
+                throw new SynapseException(msg);
+
+            } else {
+                try {
+                    filter.setXpath(new AXIOMXPath(attXpath.getAttributeValue()));
+                } catch (JaxenException e) {
+                    String msg = "Invalid XPath expression for attribute xpath : " + attXpath.getAttributeValue();
+                    log.error(msg);
+                    throw new SynapseException(msg);
+                }
+            }
+
+        } else if (attSource != null && attRegex != null) {
+
+            if (
+                (attSource.getAttributeValue() != null && attSource.getAttributeValue().trim().length() == 0) ||
+                (attRegex.getAttributeValue()  != null && attRegex.getAttributeValue().trim().length() == 0) ){
+                String msg = "Invalid attribute values for source and/or regex specified";
+                log.error(msg);
+                throw new SynapseException(msg);
+
+            } else {
+                try {
+                    filter.setSource(new AXIOMXPath(attSource.getAttributeValue()));
+                } catch (JaxenException e) {
+                    String msg = "Invalid XPath expression for attribute source : " + attSource.getAttributeValue();
+                    log.error(msg);
+                    throw new SynapseException(msg);
+                }
+                try {
+                    filter.setRegex(Pattern.compile(attRegex.getAttributeValue()));
+                } catch (PatternSyntaxException pse) {
+                    String msg = "Invalid Regular Expression for attribute regex : " + attRegex.getAttributeValue();
+                    log.error(msg);
+                    throw new SynapseException(msg);
+                }
+            }
+
+        } else {
+            String msg = "An xpath or (source, regex) attributes are required for a filter";
+            log.error(msg);
+            throw new SynapseException(msg);
+        }
+        return filter;
+    }
+
+    public QName getTagQName() {
+        return FILTER_Q;
+    }
+}

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java Wed May  3 03:58:21 2006
@@ -13,11 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.config.Constants;
 import org.apache.synapse.api.Mediator;
@@ -41,9 +41,8 @@
         private static final QName TYPE_ATT_Q = new QName("type"),
             VALUE_ATT_Q = new QName("value");
 
-        public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+        public Mediator createMediator(SynapseContext se, OMElement el) {
             HeaderMediator hm = new HeaderMediator();
-            super.setNameOnMediator(se, el, hm);
             OMAttribute val = el.getAttribute(VALUE_ATT_Q);
             OMAttribute type = el.getAttribute(TYPE_ATT_Q);
             if (val == null || type == null) {

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/LogMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/LogMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/LogMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/LogMediatorFactory.java Wed May  3 03:58:21 2006
@@ -14,40 +14,103 @@
  * limitations under the License.
  */
 
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
-import org.apache.synapse.SynapseEnvironment;
-import org.apache.synapse.config.Constants;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseException;
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.builtin.LogMediator;
+import org.apache.synapse.mediators.MediatorProperty;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+import java.util.Iterator;
 
 /**
+ * Created a Log mediator that logs messages using commons-logging.
  *
- * 
- * <p>
- * Logs messages using Commons-logging. 
- * 
- * <xmp><log name="optional"/></xmp>
- * TODO add support for simple one-line log entry (doesn't cause body parsing)
- *
+ * <log [level="simple|headers|full"]>
+ *      <property> *
+ * </log>
  */
 public class LogMediatorFactory extends AbstractMediatorFactory {
-    private static final QName LOG_Q = new QName(Constants.SYNAPSE_NAMESPACE,
-            "log");
 
+    private static final QName LOG_Q    = new QName(Constants.SYNAPSE_NAMESPACE, "log");
+    private static final String SIMPLE  = "simple";
+    private static final String HEADERS = "headers";
+    private static final String FULL    = "full";
+    private static final String CUSTOM  = "custom";
 
     public QName getTagQName() {
         return LOG_Q;
     }
 
+    public Mediator createMediator(SynapseContext synCtx, OMElement elem) {
+
+        LogMediator logMediator = new LogMediator();
+
+        OMAttribute level = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "level"));
+        if (level != null) {
+            if (SIMPLE.equals(level)) {
+                logMediator.setLogLevel(LogMediator.SIMPLE);
+            } else if (HEADERS.equals(level)) {
+                logMediator.setLogLevel(LogMediator.HEADERS);
+            } else if (FULL.equals(level)) {
+                logMediator.setLogLevel(LogMediator.FULL);
+            } else if (CUSTOM.equals(level)) {
+                logMediator.setLogLevel(LogMediator.CUSTOM);
+            }
+        }
+
+        Iterator iter = elem.getChildrenWithName(new QName(Constants.NULL_NAMESPACE, "property"));
+        while (iter.hasNext()) {
+
+            OMElement propEle = (OMElement) iter.next();
+            OMAttribute attName  = propEle.getAttribute(MediatorProperty.ATT_NAME_Q);
+            OMAttribute attValue = propEle.getAttribute(MediatorProperty.ATT_VALUE_Q);
+            OMAttribute attExpr  = propEle.getAttribute(MediatorProperty.ATT_EXPR_Q);
+
+            MediatorProperty prop = new MediatorProperty();
+
+            if (attName == null || attName.getAttributeValue() == null || attName.getAttributeValue().trim().length() == 0) {
+                String msg = "Property name is a required attribute for a Log property";
+                log.error(msg);
+                throw new SynapseException(msg);
+            } else {
+                prop.setName(attName.getAttributeValue());
+            }
+
+            // if a value is specified, use it, else look for an expression
+            if (attValue != null) {
+                if (attValue.getAttributeValue() == null || attValue.getAttributeValue().trim().length() == 0) {
+                    String msg = "Property attribute value (if specified) is required for a Log property";
+                    log.error(msg);
+                    throw new SynapseException(msg);
+                } else {
+                    prop.setValue(attValue.getAttributeValue());
+                }
+
+            } else if (attExpr != null) {
+                if (attExpr.getAttributeValue() == null || attExpr.getAttributeValue().trim().length() == 0) {
+                    String msg = "Property attribute expression (if specified) is required for a Log property";
+                    log.error(msg);
+                    throw new SynapseException(msg);
+                } else {
+                    prop.setExpression(attValue.getAttributeValue());
+                }
+
+            } else {
+                String msg = "Property attribute value OR expression must be specified for a Log property";
+                log.error(msg);
+                throw new SynapseException(msg);
+            }
+
+            logMediator.addProperty(prop);
+        }
 
-    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
-        LogMediator lm = new LogMediator();
-        super.setNameOnMediator(se,el,lm);
-        return lm;
+        return logMediator;
     }
 
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactory.java Wed May  3 03:58:21 2006
@@ -14,15 +14,15 @@
  * limitations under the License.
  */
 
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.api.Mediator;
 import org.apache.axiom.om.OMElement;
 
 public interface MediatorFactory {
-    public Mediator createMediator(SynapseEnvironment se, OMElement el);
+    public Mediator createMediator(SynapseContext se, OMElement el);
     public QName getTagQName();
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java Wed May  3 03:58:21 2006
@@ -15,7 +15,7 @@
  */
 
 
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -27,8 +27,9 @@
 import org.apache.commons.logging.LogFactory;
 
 
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.config.MediatorFactory;
 import org.apache.synapse.api.Mediator;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
@@ -44,80 +45,97 @@
 
 public class MediatorFactoryFinder {
 
-	private static Map lookup = null;
+    private static Map factoryMap = new HashMap();
+	private Log log = LogFactory.getLog(getClass());
 
-	private static Log log = LogFactory
-			.getLog(MediatorFactoryFinder.class);
+	private static final Class[] mediatorFactories = {
+        SequenceMediatorFactory.class,
+        LogMediatorFactory.class,
+        SendMediatorFactory.class,
+        FilterMediatorFactory.class,
+        SynapseMediatorFactory.class,
+        DropMediatorFactory.class
+      };
+
+    private static MediatorFactoryFinder instance = null;
+
+    public static synchronized MediatorFactoryFinder getInstance() {
+        if (instance == null) {
+            instance = new MediatorFactoryFinder();
+        }
+        return instance;
+    }
+
+    /**
+     * Force re initialization next time
+     */
+    public synchronized void reset() {
+        factoryMap.clear();
+        instance = null;
+    }
 
-	private static Class[] mediatorFactories = {
-			SynapseMediatorFactory.class,
-			HeaderMediatorFactory.class,
-			ClassMediatorFactory.class,
-			ServiceMediatorFactory.class,
-			LogMediatorFactory.class, SendMediatorFactory.class,
-			FaultMediatorFactory.class,
-            SendMediatorFactory.class,
-            DropMediatorFactory.class
-            };
-
-	private static void initialise() {
-
-		if (lookup != null)
-			return;
-		lookup = new HashMap();
+    private MediatorFactoryFinder() {
 
+		factoryMap = new HashMap();
 		for (int i = 0; i < mediatorFactories.length; i++) {
 			Class c = mediatorFactories[i];
 			try {
-				lookup.put(((MediatorFactory) c.newInstance())
-						.getTagQName(), c);
+				factoryMap.put(((MediatorFactory) c.newInstance()).getTagQName(), c);
 			} catch (Exception e) {
-				throw new SynapseException("problem instantiating "+c.getName(), e);
+				throw new SynapseException("Error instantiating " + c.getName(), e);
 			}
 		}
-		log.debug("registering extensions");
-		log.debug(System.getProperty("java.class.path"));
-		// now try additional processors
-		Iterator it = Service.providers(MediatorFactory.class);
-		while (it.hasNext()) {
-			MediatorFactory mf = (MediatorFactory) it.next();
-			QName tag = mf.getTagQName();
-			lookup.put(tag, mf.getClass());
-			log.debug("added MediatorFactory " + mf.getClass() + " to handle " + tag);
-		}
-	}
+        // TODO revisit later registerExtensions();
+    }
+
+    //TODO revist later
+    private void registerExtensions() {
+        log.debug("registering extensions");
+        log.debug(System.getProperty("java.class.path"));
+        // now try additional processors
+        Iterator it = Service.providers(MediatorFactory.class);
+        while (it.hasNext()) {
+            MediatorFactory mf = (MediatorFactory) it.next();
+            QName tag = mf.getTagQName();
+            factoryMap.put(tag, mf.getClass());
+            log.debug("added MediatorFactory " + mf.getClass() + " to handle " + tag);
+        }
+    }
 
-                            	/**
-	 * @param qn
-	 * @return the class which implements the Processor for the given QName
-	 */
-	public static Class find(QName qn) {
-		initialise();
-		return (Class) lookup.get(qn);
-	}
-	
 	/**
 	 * This method returns a Processor given an OMElement. This will be used
 	 * recursively by the elements which contain processor elements themselves
 	 * (e.g. rules)
 	 * 
-	 * @param synapseEnv
+	 * @param synapseCtx
 	 * @param element
 	 * @return Processor
 	 */
-	public static Mediator getMediator(SynapseEnvironment synapseEnv, OMElement element) {
-		OMNamespace n = element.getNamespace();
-		
-		Class cls = find(new QName(n.getName(), element
-				.getLocalName()));
-		try {
+	public Mediator getMediator(SynapseContext synapseCtx, OMElement element) {
+
+		QName qName = new QName(element.getNamespace().getName(), element.getLocalName());
+        log.debug("getMediator(" + qName + ")");
+        Class cls = (Class) factoryMap.get(qName);
+
+        if (cls == null) {
+            String msg = "Unknown mediator referenced by configuration element : " + qName;
+            log.error(msg);
+            throw new SynapseException(msg);
+        }
+
+        try {
 			MediatorFactory mf = (MediatorFactory) cls.newInstance();
-			Mediator m = mf.createMediator(synapseEnv, element);
-			return m;
-		} catch (InstantiationException e) {
-			throw new SynapseException(e);
-		} catch (IllegalAccessException e) {
-			throw new SynapseException(e);
+			return mf.createMediator(synapseCtx, element);
+
+        } catch (InstantiationException e) {
+            String msg = "Error initializing mediator factory : " + cls;
+            log.error(msg);
+            throw new SynapseException(msg, e);
+
+        } catch (IllegalAccessException e) {
+            String msg = "Error initializing mediator factory : " + cls;
+            log.error(msg);
+            throw new SynapseException(msg, e);
 		}
 	}
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SendMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SendMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SendMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SendMediatorFactory.java Wed May  3 03:58:21 2006
@@ -14,34 +14,31 @@
  * limitations under the License.
  */
 
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
 
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.builtin.SendMediator;
-import org.apache.synapse.SynapseEnvironment;
-import org.apache.synapse.config.Constants;
+import org.apache.synapse.SynapseContext;
 import org.apache.axiom.om.OMElement;
 
+/**
+ * The Send mediator factory parses a Send element and creates an instance of the mediator
+ *
+ * //TODO support endpoints, failover and loadbalacing
+ */
 public class SendMediatorFactory extends AbstractMediatorFactory {
 
+    private static final QName SEND_Q = new QName(Constants.SYNAPSE_NAMESPACE, "send");
 
-    private static final QName SEND_Q = new QName(Constants.SYNAPSE_NAMESPACE,
-            "send");
-
-
-
-    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+    public Mediator createMediator(SynapseContext synMsg, OMElement el) {
         SendMediator sm =  new SendMediator();
-        super.setNameOnMediator(se, el,sm);
         return sm;
-
     }
 
     public QName getTagQName() {
-
         return SEND_Q;
     }
 

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SequenceMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SequenceMediatorFactory.java?rev=399252&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SequenceMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SequenceMediatorFactory.java Wed May  3 03:58:21 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.config;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.mediators.base.SequenceMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Builds an instance of a Sequence mediator through the Synapse configuration. It follows the following
+ * <sequence (ref="name" | name="name")> mediator* </sequence>
+ */
+public class SequenceMediatorFactory extends AbstractListMediatorFactory {
+
+    private static final QName SEQUENCE_Q = new QName(Constants.SYNAPSE_NAMESPACE, "sequence");
+
+    public QName getTagQName() {
+        return SEQUENCE_Q;
+    }
+
+    public Mediator createMediator(SynapseContext synCtx, OMElement elem) {
+
+        SequenceMediator seqMediator = new SequenceMediator();
+
+        OMAttribute n = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
+        if (n != null) {
+            seqMediator.setName(n.getAttributeValue());
+            super.addChildren(synCtx, elem, seqMediator);
+            synCtx.getConfiguration().addNamedMediator(n.getAttributeValue(), seqMediator);
+
+        } else {
+            n = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "ref"));
+            if (n != null) {
+                seqMediator.setRef(n.getAttributeValue());
+                
+            } else {
+                String msg = "A sequence mediator should be a named sequence or a reference to another sequence " +
+                    "(i.e. a name attribute or ref attribute is required.";
+                log.error(msg);
+                throw new SynapseException(msg);
+            }
+        }
+        return seqMediator;
+    }
+
+}

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ServiceMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ServiceMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ServiceMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/ServiceMediatorFactory.java Wed May  3 03:58:21 2006
@@ -15,12 +15,12 @@
  */
 
 
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
 
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.config.Constants;
 import org.apache.synapse.api.Mediator;
@@ -31,9 +31,8 @@
 public class ServiceMediatorFactory extends AbstractMediatorFactory {
     private static final QName tagName = new QName(Constants.SYNAPSE_NAMESPACE,
             "servicemediator");
-    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+    public Mediator createMediator(SynapseContext se, OMElement el) {
         ServiceMediator sm = new ServiceMediator();
-        super.setNameOnMediator(se,el,sm);
 
         OMAttribute attr = el.getAttribute(new QName("service"));
         if (attr == null)

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java?rev=399252&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java Wed May  3 03:58:21 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.config;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.mediators.base.SequenceMediator;
+import org.apache.synapse.mediators.base.SynapseMediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+public class SynapseConfigurationBuilder {
+
+    private static Log log = LogFactory.getLog(SynapseConfigurationBuilder.class);
+    private SynapseConfiguration config = new SynapseConfiguration();
+
+    public SynapseConfigurationBuilder() {}
+
+    public void setConfiguration(SynapseContext synCtx, InputStream is) {
+
+        synCtx.setConfiguration(config);
+
+        OMElement root = null;
+        try {
+            root = new StAXOMBuilder(is).getDocumentElement();
+        } catch (XMLStreamException e) {
+            String msg = "Error parsing Synapse configuration : " + e.getMessage();
+            log.error(msg);
+            throw new SynapseException(msg);
+        }
+        root.build();
+
+        OMContainer definitions = root.getFirstChildWithName(Constants.DEFINITIONS_ELT);
+        if (definitions != null) {
+            Iterator iter = definitions.getChildrenWithName(Constants.SEQUENCE_ELT);
+            while (iter.hasNext()) {
+                OMElement elt = (OMElement) iter.next();
+                defineSequence(synCtx, elt);
+            }
+        }
+
+        OMContainer endpoints = root.getFirstChildWithName(Constants.ENDPOINT_ELT);
+        if (endpoints != null) {
+            Iterator iter = endpoints.getChildrenWithName(Constants.ENDPOINT_ELT);
+            while (iter.hasNext()) {
+                OMElement elt = (OMElement) iter.next();
+                //defineEndpoint(synCtx, elt); //TODO process Endpoints
+            }
+        }
+
+        OMContainer properties = root.getFirstChildWithName(Constants.PROPERTY_ELT);
+        if (properties != null) {
+            Iterator iter = properties.getChildrenWithName(Constants.PROPERTY_ELT);
+            while (iter.hasNext()) {
+                OMElement elt = (OMElement) iter.next();
+                //defineProperty(synCtx, elt); //TODO process Properties
+            }
+        }
+
+        OMElement elem = root.getFirstChildWithName(Constants.RULES_ELT);
+        if (elem == null) {
+            String msg = "A valid Synapse configuration MUST specify the main mediator using the <rules> element";
+            log.error(msg);
+            throw new SynapseException(msg);
+        } else {
+            SynapseMediator sm = (SynapseMediator) MediatorFactoryFinder.getInstance().getMediator(synCtx, elem);
+            if (sm.getList().isEmpty()) {
+                String msg = "Invalid configuration, the main mediator specified by the <rules> element is empty";
+                log.error(msg);
+                throw new SynapseException(msg);
+            } else {
+                config.setMainMediator(sm);
+            }
+        }
+
+        if (is != null) {
+            try {
+                is.close();
+            } catch (IOException e) {}
+        }
+    }
+
+    private void defineSequence(SynapseContext synCtx, OMElement ele) {
+        SequenceMediator seq = (SequenceMediator) MediatorFactoryFinder.getInstance().getMediator(synCtx, ele);
+        config.addNamedMediator(seq.getName(), seq);
+    }
+
+    public static void main(String[] args) throws Exception {
+        SynapseConfigurationBuilder scb = new SynapseConfigurationBuilder();
+        InputStream is = new FileInputStream("/Temp/delete/simple.xml");
+        SynapseContext se = new org.apache.synapse.axis2.Axis2SynapseContext(is,null);
+        System.out.println(se.getConfiguration());
+    }
+
+}

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseMediatorFactory.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseMediatorFactory.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/config/SynapseMediatorFactory.java Wed May  3 03:58:21 2006
@@ -14,29 +14,27 @@
  * limitations under the License.
  */
 
-package org.apache.synapse.xml;
+package org.apache.synapse.config;
 
 import javax.xml.namespace.QName;
 
-import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.config.Constants;
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.base.SynapseMediator;
 import org.apache.axiom.om.OMElement;
 
-public class SynapseMediatorFactory extends
-        AbstractListMediatorFactory {
+public class SynapseMediatorFactory extends AbstractListMediatorFactory {
 
-    private final static QName tagname = new QName(Constants.SYNAPSE_NAMESPACE,
-            "synapse");
+    private final static QName tagname = new QName(Constants.SYNAPSE_NAMESPACE, "rules");
 
     public QName getTagQName() {
         return tagname;
     }
 
-    public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+    public Mediator createMediator(SynapseContext synCtx, OMElement elem) {
         SynapseMediator sm = new SynapseMediator();
-        //super.addChildrenAndSetName(se, el, sm); TODO fix this later
+        super.addChildren(synCtx, elem, sm);
         return sm;
     }
 

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java Wed May  3 03:58:21 2006
@@ -18,22 +18,22 @@
 
 import org.apache.synapse.SynapseMessage;
 import org.apache.synapse.api.Mediator;
+import org.apache.synapse.api.ListMediator;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-public abstract class AbstractListMediator extends AbstractMediator {
+public abstract class AbstractListMediator extends AbstractMediator implements ListMediator {
 
     protected List mediators = new ArrayList();
 
     public boolean mediate(SynapseMessage synMsg) {
-        log.debug("List mediator : mediate() " + getName());
+        log.debug(getType() + " mediate()");
 
         Iterator it = mediators.iterator();
         while (it.hasNext()) {
             Mediator m = (Mediator) it.next();
-            log.debug(m.getClass());
             if (!m.mediate(synMsg)) {
                 return false;
             }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/AbstractMediator.java Wed May  3 03:58:21 2006
@@ -23,7 +23,7 @@
 
     protected final Log log = LogFactory.getLog(getClass());
 
-    public String getName() {
-        return getClass().getName();
+    public String getType() {
+        return getClass().getSimpleName();
     }
 }

Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java?rev=399252&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/MediatorProperty.java Wed May  3 03:58:21 2006
@@ -0,0 +1,63 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators;
+
+import org.apache.synapse.config.Constants;
+
+import javax.xml.namespace.QName;
+
+public class MediatorProperty {
+
+    public static final QName PROPERTY_Q  = new QName(Constants.SYNAPSE_NAMESPACE, "property");
+    public static final QName ATT_NAME_Q  = new QName(Constants.NULL_NAMESPACE, "name");
+    public static final QName ATT_VALUE_Q = new QName(Constants.NULL_NAMESPACE, "value");
+    public static final QName ATT_EXPR_Q  = new QName(Constants.NULL_NAMESPACE, "expression");
+
+    private String name;
+    private String value;
+    private String expression;
+
+    public MediatorProperty() {}
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getExpression() {
+        return expression;
+    }
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+
+    public String getEvaluatedExpression() {
+        return expression;  //TODO later use XPath xtention eval
+    }
+
+}

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java Wed May  3 03:58:21 2006
@@ -16,6 +16,8 @@
 package org.apache.synapse.mediators.base;
 
 import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.AbstractListMediator;
 
 /**
@@ -35,11 +37,18 @@
      * @return as per standard mediator result
      */
     public boolean mediate(SynapseMessage synMsg) {
+        log.debug(getType() + " mediate()");
         if (ref == null) {
             return super.mediate(synMsg);
         } else {
-            return synMsg.getSynapseEnvironment().getConfiguration().
-                getNamedMediator(ref).mediate(synMsg);
+            Mediator m = synMsg.getSynapseContext().getConfiguration().getNamedMediator(ref);
+            if (m == null) {
+                String msg = "Sequence mediator instance named " + ref + " cannot be found.";
+                log.error(msg);
+                throw new SynapseException(msg);
+            } else {
+                return m.mediate(synMsg);
+            }
         }
     }
 

Modified: 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=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java Wed May  3 03:58:21 2006
@@ -25,6 +25,7 @@
 public class DropMediator extends AbstractMediator {
 
     public boolean mediate(SynapseMessage synMsg) {
+        log.debug(getType() + " mediate()");
         if (synMsg.getTo() == null) {
             return false;
         } else {

Modified: 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=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java Wed May  3 03:58:21 2006
@@ -42,7 +42,7 @@
     }
 
     public boolean mediate(SynapseMessage sm) {
-
+        log.debug(getType() + " mediate()");
         headerType.setHeader(sm, getValue());
         return true;
     }

Modified: 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=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java Wed May  3 03:58:21 2006
@@ -19,9 +19,11 @@
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.synapse.SynapseMessage;
 import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.MediatorProperty;
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.ArrayList;
 
 
 /**
@@ -36,10 +38,11 @@
     public static final int FULL = 3;
 
     private int logLevel = SIMPLE;
-    private String SEP = "\n";
-    private List properties = null;
+    private String SEP = ", ";
+    private List properties = new ArrayList();
 
     public boolean mediate(SynapseMessage synMsg) {
+        log.debug(getType() + " mediate()");
         log.info(getLogMessage(synMsg));
         return true;
     }
@@ -107,44 +110,31 @@
         if (properties != null && !properties.isEmpty()) {
             Iterator iter = properties.iterator();
             while (iter.hasNext()) {
-                Property prop = (Property) iter.next();
+                MediatorProperty prop = (MediatorProperty) iter.next();
                 sb.append(SEP + prop.getName() + " = " +
-                    prop.getValue() != null ? prop.getValue() : prop.getEvaluatedExpression());
+                    (prop.getValue() != null ? prop.getValue() : prop.getEvaluatedExpression()));
             }
         }
     }
 
-    public class Property {
-        private String name;
-        private String value;
-        private String expression;
-
-        public String getName() {
-            return name;
-        }
-
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        public String getValue() {
-            return value;
-        }
+    public int getLogLevel() {
+        return logLevel;
+    }
 
-        public void setValue(String value) {
-            this.value = value;
-        }
+    public void setLogLevel(int logLevel) {
+        this.logLevel = logLevel;
+    }
 
-        public String getExpression() {
-            return expression;
-        }
+    public String getSeperator() {
+        return SEP;
+    }
 
-        public void setExpression(String expression) {
-            this.expression = expression;
-        }
+    public void setSeperator(String SEP) {
+        this.SEP = SEP;
+    }
 
-        public String getEvaluatedExpression() {
-            return expression;  //TODO later use XPath xtention eval
-        }
+    public void addProperty(MediatorProperty p) {
+        properties.add(p);
     }
+
 }

Modified: 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=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java Wed May  3 03:58:21 2006
@@ -35,8 +35,8 @@
      * @return false always as this is a leaf mediator
      */
     public boolean mediate(SynapseMessage synMsg) {
-        log.debug(getName() + " mediate()");
-        synMsg.getSynapseEnvironment().send(synMsg);
+        log.debug(getType() + " mediate()");
+        synMsg.getSynapseContext().send(synMsg);
         return false;
     }
 }

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ClassMediator.java Wed May  3 03:58:21 2006
@@ -34,6 +34,7 @@
 
 
     public boolean mediate(SynapseMessage smc) {
+        log.debug(getType() + " mediate()");
         Mediator m = null;
 
         try {
@@ -42,7 +43,7 @@
             throw new SynapseException(e);
         }
         /*if (EnvironmentAware.class.isAssignableFrom(m.getClass())) {
-              ((EnvironmentAware) m).setSynapseEnvironment(se);
+              ((EnvironmentAware) m).setSynapseContext(se);
           }*/
         return m.mediate(smc);
 

Modified: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ServiceMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ServiceMediator.java?rev=399252&r1=399251&r2=399252&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ServiceMediator.java (original)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/mediators/ext/ServiceMediator.java Wed May  3 03:58:21 2006
@@ -42,6 +42,7 @@
     private String serviceName = null;
 
     public boolean mediate(SynapseMessage smc) {
+        log.debug(getType() + " mediate()");
         MessageContext messageContext = null;
         try {
             messageContext = ((Axis2SynapseMessage) smc)



---------------------------------------------------------------------
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