You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by de...@apache.org on 2005/11/01 06:39:32 UTC

svn commit: r329985 - in /incubator/synapse/trunk/scratch/prototype1/src: META-INF/ org/apache/synapse/ org/apache/synapse/engine/ org/apache/synapse/engine/dispatchers/ org/apache/synapse/messagereceiver/ org/apache/synapse/module/

Author: deepal
Date: Mon Oct 31 21:39:09 2005
New Revision: 329985

URL: http://svn.apache.org/viewcvs?rev=329985&view=rev
Log:
Improved SynapseModule (class) , created  a module.xml that is required to configure the module correctly .

Add a dispatcher called SynpseDispatcher which will dispatch any of the incoming message into SynpaseService (a dummy service which has one operation too), and the operation will be SynapseOperation and the message receiver for that op is SynapseMessageReceiver. 

All the rules belong to one serviceGroup , so at SynapeEngine intilization time a ServiceGroup will be added to the axisConfig. And that service group contains services for each rules. 

Added:
    incubator/synapse/trunk/scratch/prototype1/src/META-INF/
    incubator/synapse/trunk/scratch/prototype1/src/META-INF/module.xml
    incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/dispatchers/
    incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/dispatchers/SynpaseDispatcher.java
Modified:
    incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java
    incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java
    incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml
    incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/messagereceiver/SynapseMessageReceiver.java
    incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java

Added: incubator/synapse/trunk/scratch/prototype1/src/META-INF/module.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/META-INF/module.xml?rev=329985&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/META-INF/module.xml (added)
+++ incubator/synapse/trunk/scratch/prototype1/src/META-INF/module.xml Mon Oct 31 21:39:09 2005
@@ -0,0 +1,7 @@
+<module name="synapse" class="org.apache.synapse.module.SynapseModule">
+    <inflow>
+        <handler name="synapseDiapstcher" class="org.apache.synapse.engine.dispatchers.SynpaseDispatcher">
+            <order phaseFirst="true" phase="Dispatch"/>
+        </handler>
+    </inflow>
+</module>
\ No newline at end of file

Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java?rev=329985&r1=329984&r2=329985&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java Mon Oct 31 21:39:09 2005
@@ -6,6 +6,8 @@
     public static final String MEDIATION_RESULT = "Mediation Result";
 
     public static final String SYNAPSE_ENGINE = "Synapse Engine";
+    String SYNAPSE_SERVICE ="SynapseServie";
+    String SYNAPSE_OPERATION ="SynapseOp";
     String DIRECTION_IN ="incomming" ;
     String DIRECTION_OUT ="outgoing" ;
     String DIRECTION ="direction" ;

Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java?rev=329985&r1=329984&r2=329985&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java Mon Oct 31 21:39:09 2005
@@ -2,6 +2,7 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisConfigurationImpl;
 import org.apache.axis2.context.MessageContext;
@@ -30,13 +31,17 @@
     private RuleSelector outgoingPostStageRuleSelector;
 
     private AxisConfiguration axisConfig;
+    private AxisServiceGroup mediatorServiceGroup;
 
     /**
      *
      */
     public void init(SynapseConfiguration synapseConfiguration)
             throws SynapseException {
+        //todo : Deepal , the axisConfiguartion creation has to be improevd
         axisConfig = new AxisConfigurationImpl();
+        mediatorServiceGroup = new AxisServiceGroup(axisConfig);
+        mediatorServiceGroup.setServiceGroupName("mediator_service_group");
         incomingPreStageRuleSelector = createRuleSelector(
                 synapseConfiguration.getIncomingPreStageRuleSet());
         incomingProcessingStageRuleSelector = createRuleSelector(
@@ -50,6 +55,13 @@
                 synapseConfiguration.getOutgoingProcessingStageRuleSet());
         outgoingPostStageRuleSelector = createRuleSelector(
                 synapseConfiguration.getOutgoingPostStageRuleSet());
+
+        // adding service group into axisConfig
+        try {
+            axisConfig.addServiceGroup(mediatorServiceGroup);
+        } catch (AxisFault axisFault) {
+            throw new SynapseException(axisFault);
+        }
     }
 
     public void processIncoming(MessageContext messageContext) {
@@ -182,7 +194,7 @@
                     String moduleName = (String) qoslist.get(j);
                     //todo engage all the mdoule to the service
                 }
-                axisConfig.addService(service);
+                mediatorServiceGroup.addService(service);
 //                rule.setAxisConfig();
             }
             return ruleSelector;

Added: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/dispatchers/SynpaseDispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/dispatchers/SynpaseDispatcher.java?rev=329985&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/dispatchers/SynpaseDispatcher.java (added)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/dispatchers/SynpaseDispatcher.java Mon Oct 31 21:39:09 2005
@@ -0,0 +1,54 @@
+package org.apache.synapse.engine.dispatchers;
+
+import org.apache.axis2.engine.AbstractDispatcher;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.synapse.SynapseConstants;
+
+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.
+*
+* @author : Deepal Jayasinghe (deepal@apache.org)
+*
+*/
+
+public class SynpaseDispatcher extends AbstractDispatcher {
+
+    public static final QName NAME =
+            new QName("http://synapse.ws.apache.org",
+                    "SynapseDispatcher");
+    String serviceName = null;
+    QName operationName = null;
+
+    public void initDispatcher() {
+        init(new HandlerDescription(NAME));
+    }
+
+    public AxisService findService(MessageContext messageContext) throws AxisFault {
+        return messageContext.getSystemContext().getAxisConfiguration()
+                .getService(SynapseConstants.SYNAPSE_SERVICE);
+    }
+
+    public AxisOperation findOperation(AxisService service,
+                                              MessageContext messageContext) throws AxisFault {
+        return service.getOperation(SynapseConstants.SYNAPSE_OPERATION);
+    }
+
+}

Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml?rev=329985&r1=329984&r2=329985&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml Mon Oct 31 21:39:09 2005
@@ -16,5 +16,4 @@
         <ruleSet class="org.apache.synapse.rule.RuleSelectorImpl" stage="PROCESS"/>
         <ruleSet class="org.apache.synapse.rule.RuleSelectorImpl" stage="OUT"/>
     </direction>
-
 </synapse>

Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/messagereceiver/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/messagereceiver/SynapseMessageReceiver.java?rev=329985&r1=329984&r2=329985&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/messagereceiver/SynapseMessageReceiver.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/messagereceiver/SynapseMessageReceiver.java Mon Oct 31 21:39:09 2005
@@ -10,8 +10,8 @@
 public class SynapseMessageReceiver extends AbstractInMessageReceiver {
     public void invokeBusinessLogic(MessageContext messageContext)
             throws AxisFault {
-        SynapseEngine synapseEngine = (SynapseEngine) messageContext
-                .getProperty(SynapseConstants.SYNAPSE_ENGINE);
+       SynapseEngine synapseEngine = (SynapseEngine) messageContext
+                .getParameter(SynapseConstants.SYNAPSE_ENGINE).getValue();
         synapseEngine.processIncoming(messageContext);
     }
 }

Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java?rev=329985&r1=329984&r2=329985&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java Mon Oct 31 21:39:09 2005
@@ -3,14 +3,15 @@
 import org.apache.axis2.modules.Module;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterImpl;
+import org.apache.axis2.description.*;
 import org.apache.synapse.engine.SynapseConfiguration;
 import org.apache.synapse.engine.SynapseDeployer;
 import org.apache.synapse.engine.SynapseEngine;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.messagereceiver.SynapseMessageReceiver;
 
+import javax.xml.namespace.QName;
 import java.io.File;
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
@@ -45,6 +46,16 @@
             syPara.setName(SynapseConstants.SYNAPSE_ENGINE);
             syPara.setValue(engine);
             axisConfiguration.addParameter(syPara);
+
+             //adding a dumy service to the axisConfig
+            AxisService service = new AxisService(
+                    new QName(SynapseConstants.SYNAPSE_SERVICE));
+            service.setClassLoader(axisConfiguration.getServiceClassLoader());
+            AxisOperation axisOp = new InOutAxisOperation(
+                    new QName(SynapseConstants.SYNAPSE_OPERATION));
+            axisOp.setMessageReceiver(new SynapseMessageReceiver());
+            service.addOperation(axisOp);
+            axisConfiguration.addService(service);
         } catch (SynapseException e) {
             throw new AxisFault(e);
         }



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