You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2009/04/20 09:36:49 UTC

svn commit: r766607 - in /synapse/trunk/java: ./ modules/core/ modules/core/src/main/java/org/apache/synapse/ modules/core/src/main/java/org/apache/synapse/core/axis2/ modules/distribution/src/main/assembly/ modules/mar/ modules/packaging/package-arche...

Author: ruwan
Date: Mon Apr 20 07:36:49 2009
New Revision: 766607

URL: http://svn.apache.org/viewvc?rev=766607&view=rev
Log:
removing the synapse module and attaching the handlers programatically

Removed:
    synapse/trunk/java/modules/mar/
Modified:
    synapse/trunk/java/modules/core/pom.xml
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMustUnderstandHandler.java
    synapse/trunk/java/modules/distribution/src/main/assembly/bin.xml
    synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/repository/conf/axis2.xml
    synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/src/main/assembly/bin.xml
    synapse/trunk/java/modules/war/pom.xml
    synapse/trunk/java/pom.xml
    synapse/trunk/java/repository/conf/axis2.xml

Modified: synapse/trunk/java/modules/core/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/pom.xml?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/pom.xml (original)
+++ synapse/trunk/java/modules/core/pom.xml Mon Apr 20 07:36:49 2009
@@ -79,15 +79,10 @@
                         <configuration>
                             <tasks>
                                 <echo message="*** Creating a testing repository ***"/>
-
                                 <mkdir dir="target/test_repos"/>
                                 <mkdir dir="target/test_repos/synapse/modules"/>
                                 <mkdir dir="target/test_repos/synapse/services"/>
                                 <mkdir dir="target/test_repos/client/modules"/>
-
-                                <copy file="../mar/target/synapse-${version}.mar"
-                                    tofile="target/test_repos/synapse/modules/synapse-${version}.mar"/>
-
                             </tasks>
                         </configuration>
                         <goals>

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java Mon Apr 20 07:36:49 2009
@@ -24,10 +24,15 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.description.*;
+import org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher;
 import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.Handler;
 import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.engine.Phase;
 import org.apache.axis2.format.BinaryBuilder;
 import org.apache.axis2.format.PlainTextBuilder;
+import org.apache.axis2.phaseresolver.PhaseException;
+import org.apache.axis2.phaseresolver.PhaseMetadata;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.commons.util.datasource.DataSourceInformationRepositoryHelper;
@@ -36,10 +41,7 @@
 import org.apache.synapse.config.SynapseConfigurationBuilder;
 import org.apache.synapse.config.SynapsePropertiesLoader;
 import org.apache.synapse.core.SynapseEnvironment;
-import org.apache.synapse.core.axis2.Axis2SynapseEnvironment;
-import org.apache.synapse.core.axis2.MessageContextCreatorForAxis2;
-import org.apache.synapse.core.axis2.ProxyService;
-import org.apache.synapse.core.axis2.SynapseMessageReceiver;
+import org.apache.synapse.core.axis2.*;
 import org.apache.synapse.eventing.SynapseEventSource;
 import org.apache.synapse.task.*;
 
@@ -136,10 +138,32 @@
     }
 
     /**
-     * Starts the listener manager if the axis2 instancec is created by the Synapse
+     * Adds the synapse handlers to the inflow Dispatch phase and starts the listener manager
+     * if the axis2 instance is created by the Synapse
      */
     public void start() {
 
+        // add the Synapse handlers
+        if (configurationContext != null) {
+            List<Phase> inflowPhases
+                    = configurationContext.getAxisConfiguration().getInFlowPhases();
+            for (Phase inPhase : inflowPhases) {
+                // we are interested about the Dispatch phase in the inflow
+                if (PhaseMetadata.PHASE_DISPATCH.equals(inPhase.getPhaseName())) {
+                    try {
+                        inPhase.addHandler(prepareSynapseDispatcher());
+                        inPhase.addHandler(prepareMustUnderstandHandler());
+                    } catch (PhaseException e) {
+                        handleFatal("Couldn't start Synapse, " +
+                                "Cannot add the required Synapse handlers", e);
+                    }
+                }
+            }
+        } else {
+            handleFatal("Couldn't start Synapse, ConfigurationContext not found");
+        }
+
+        // if the axis2 instance is created by us, then start the listener manager
         if (information.isCreateNewInstance()) {
             if (listenerManager != null) {
                 listenerManager.start();
@@ -155,28 +179,54 @@
     public void stop() {
         try {
             cleanupDefault();
-            if (information.isCreateNewInstance()) {
 
-                if (listenerManager != null) {
-                    listenerManager.stop();
-                }
-
-                if (configurationContext != null &&
-                        configurationContext.getAxisConfiguration() != null) {
+            // first stop the listener manager
+            if (information.isCreateNewInstance() && listenerManager != null) {
+                listenerManager.stop();
+            }
+
+            // detach the synapse handlers
+            if (configurationContext != null) {
+                List<Phase> inflowPhases
+                        = configurationContext.getAxisConfiguration().getInFlowPhases();
+                for (Phase inPhase : inflowPhases) {
+                    // we are interested about the Dispatch phase in the inflow
+                    if (PhaseMetadata.PHASE_DISPATCH.equals(inPhase.getPhaseName())) {
+                        List<HandlerDescription> synapseHandlers
+                                = new ArrayList<HandlerDescription>();
+                        for (Handler handler : inPhase.getHandlers()) {
+                            if (SynapseDispatcher.NAME.equals(handler.getName()) ||
+                                    SynapseMustUnderstandHandler.NAME.equals(handler.getName())) {
+                                synapseHandlers.add(handler.getHandlerDesc());
+                            }
+                        }
 
-                    Map<String, AxisService> serviceMap =
-                            configurationContext.getAxisConfiguration().getServices();
-                    for (AxisService svc : serviceMap.values()) {
-                        svc.setActive(false);
+                        for (HandlerDescription handlerMD : synapseHandlers) {
+                            inPhase.removeHandler(handlerMD);
+                        }
                     }
+                }
+            } else {
+                handleException("Couldn't detach the Synapse handlers, " +
+                        "ConfigurationContext not found.");
+            }
 
-                    // stop all modules
-                    Map<String, AxisModule> moduleMap =
-                            configurationContext.getAxisConfiguration().getModules();
-                    for (AxisModule mod : moduleMap.values()) {
-                        if (mod.getModule() != null && !"synapse".equals(mod.getName())) {
-                            mod.getModule().shutdown(configurationContext);
-                        }
+            // continue stopping the axis2 environment if we created it
+            if (information.isCreateNewInstance() && configurationContext != null &&
+                    configurationContext.getAxisConfiguration() != null) {
+
+                Map<String, AxisService> serviceMap =
+                        configurationContext.getAxisConfiguration().getServices();
+                for (AxisService svc : serviceMap.values()) {
+                    svc.setActive(false);
+                }
+
+                // stop all modules
+                Map<String, AxisModule> moduleMap =
+                        configurationContext.getAxisConfiguration().getModules();
+                for (AxisModule mod : moduleMap.values()) {
+                    if (mod.getModule() != null && !"synapse".equals(mod.getName())) {
+                        mod.getModule().shutdown(configurationContext);
                     }
                 }
             }
@@ -365,6 +415,32 @@
         setupEventSources();
     }
 
+    private HandlerDescription prepareSynapseDispatcher() {
+        HandlerDescription handlerMD = new HandlerDescription(SynapseDispatcher.NAME);
+        // <order after="SOAPMessageBodyBasedDispatcher" phase="Dispatch"/>
+        PhaseRule rule = new PhaseRule(PhaseMetadata.PHASE_DISPATCH);
+        rule.setAfter(SOAPMessageBodyBasedDispatcher.NAME);
+        handlerMD.setRules(rule);
+        SynapseDispatcher synapseDispatcher = new SynapseDispatcher();
+        synapseDispatcher.initDispatcher();
+        handlerMD.setHandler(synapseDispatcher);
+        return handlerMD;
+    }
+
+    private HandlerDescription prepareMustUnderstandHandler() {
+        HandlerDescription handlerMD
+                = new HandlerDescription(SynapseMustUnderstandHandler.NAME);
+        // <order after="SynapseDispatcher" phase="Dispatch"/>
+        PhaseRule rule = new PhaseRule(PhaseMetadata.PHASE_DISPATCH);
+        rule.setAfter(SynapseDispatcher.NAME);
+        handlerMD.setRules(rule);
+        SynapseMustUnderstandHandler synapseMustUnderstandHandler
+                = new SynapseMustUnderstandHandler();
+        synapseMustUnderstandHandler.init(handlerMD);
+        handlerMD.setHandler(synapseMustUnderstandHandler);
+        return handlerMD;
+    }
+
     private void initDefault(ServerContextInformation contextInformation) {
         addDefaultBuildersAndFormatters(configurationContext.getAxisConfiguration());
         loadMediatorExtensions();
@@ -466,4 +542,9 @@
         log.fatal(msg);
         throw new SynapseException(msg);
     }
+
+    private void handleException(String msg) {
+        log.error(msg);
+        throw new SynapseException(msg);
+    }
 }

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java Mon Apr 20 07:36:49 2009
@@ -36,8 +36,10 @@
  */
 public class SynapseDispatcher extends AbstractDispatcher {
 
+    public static final String NAME = "SynapseDispatcher";
+
     public void initDispatcher() {
-        QName qn = new QName("http://synapse.apache.org", "SynapseDispatcher");
+        QName qn = new QName("http://synapse.apache.org", NAME);
         HandlerDescription hd = new HandlerDescription(qn.getLocalPart());
         super.init(hd);
     }

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMustUnderstandHandler.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMustUnderstandHandler.java?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMustUnderstandHandler.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMustUnderstandHandler.java Mon Apr 20 07:36:49 2009
@@ -34,6 +34,8 @@
  * even with unprocessed mustUnderstand headers
  */
 public class SynapseMustUnderstandHandler extends AbstractHandler {
+
+    public static final String NAME = "SynapseMustUnderstandHandler";
     
     public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
 

Modified: synapse/trunk/java/modules/distribution/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/distribution/src/main/assembly/bin.xml?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/distribution/src/main/assembly/bin.xml (original)
+++ synapse/trunk/java/modules/distribution/src/main/assembly/bin.xml Mon Apr 20 07:36:49 2009
@@ -112,13 +112,6 @@
             </includes>
         </fileSet>
         <fileSet>
-            <directory>../../modules/mar/target</directory>
-            <outputDirectory>synapse-${synapse.version}/repository/modules</outputDirectory>
-            <includes>
-                <include>synapse-${synapse.version}.mar</include>
-            </includes>
-        </fileSet>
-        <fileSet>
             <directory>src/main/release/docs</directory>
             <outputDirectory>synapse-${synapse.version}</outputDirectory>
             <includes>

Modified: synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/repository/conf/axis2.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/repository/conf/axis2.xml?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/repository/conf/axis2.xml (original)
+++ synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/repository/conf/axis2.xml Mon Apr 20 07:36:49 2009
@@ -1,21 +1,21 @@
-##
-##  Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you 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.
-##
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you 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.
+  -->
 <?xml version="1.0" encoding="UTF-8"?>
 <axisconfig name="AxisJava2.0">
     <!-- ================================================= -->
@@ -292,7 +292,6 @@
     <!-- ================================================= -->
     <!-- Comment this to disable Addressing -->
     <module ref="addressing"/>
-    <module ref="synapse"/>
 
     <!--Configuring module , providing parameters for modules whether they refer or not-->
     <!--<moduleConfig name="addressing">-->

Modified: synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/src/main/assembly/bin.xml?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/src/main/assembly/bin.xml (original)
+++ synapse/trunk/java/modules/packaging/package-archetype/src/main/resources/archetype-resources/src/main/assembly/bin.xml Mon Apr 20 07:36:49 2009
@@ -1,21 +1,21 @@
-##
-##  Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you 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.
-##
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you 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.
+  -->
 #set( $symbol_dollar = '$' )
 <?xml version="1.0" encoding="UTF-8"?>
 <assembly>
@@ -49,14 +49,6 @@
             <outputDirectory>repository/modules</outputDirectory>
             <outputFileNameMapping>${symbol_dollar}{artifact.artifactId}.${symbol_dollar}{artifact.extension}</outputFileNameMapping>
         </dependencySet>
-        <dependencySet>
-            <useProjectArtifact>false</useProjectArtifact>
-            <includes>
-                <include>org.apache.synapse:synapse-module</include>
-            </includes>
-            <outputDirectory>repository/modules</outputDirectory>
-            <outputFileNameMapping>synapse.mar</outputFileNameMapping>
-        </dependencySet>
     </dependencySets>
     <fileSets>
         <fileSet>

Modified: synapse/trunk/java/modules/war/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/war/pom.xml?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/modules/war/pom.xml (original)
+++ synapse/trunk/java/modules/war/pom.xml Mon Apr 20 07:36:49 2009
@@ -162,13 +162,6 @@
                             </includes>
                         </resource>
                         <resource>
-                            <directory>../mar/target</directory>
-                            <targetPath>WEB-INF/repository/modules</targetPath>
-                            <includes>
-                                <include>synapse-${synapse.version}.mar</include>
-                            </includes>
-                        </resource>
-                        <resource>
                             <directory>target/temp/lib</directory>
                             <targetPath>WEB-INF/repository/modules</targetPath>
                             <includes>

Modified: synapse/trunk/java/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/pom.xml?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/pom.xml (original)
+++ synapse/trunk/java/pom.xml Mon Apr 20 07:36:49 2009
@@ -799,7 +799,6 @@
         <module>modules/utils</module>
         <module>modules/transports</module>
         <module>modules/tasks</module>
-        <module>modules/mar</module>
         <module>modules/core</module>
         <module>modules/extensions</module>
         <module>modules/samples</module>

Modified: synapse/trunk/java/repository/conf/axis2.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/axis2.xml?rev=766607&r1=766606&r2=766607&view=diff
==============================================================================
--- synapse/trunk/java/repository/conf/axis2.xml (original)
+++ synapse/trunk/java/repository/conf/axis2.xml Mon Apr 20 07:36:49 2009
@@ -292,7 +292,6 @@
     <!-- ================================================= -->
     <!-- Comment this to disable Addressing -->
     <module ref="addressing"/>
-    <module ref="synapse"/>
 
     <!--Configuring module , providing parameters for modules whether they refer or not-->
     <!--<moduleConfig name="addressing">-->