You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by nt...@apache.org on 2009/09/24 00:28:27 UTC

svn commit: r818290 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: context/ConfigurationContext.java engine/ListenerManager.java

Author: nthaker
Date: Wed Sep 23 22:28:27 2009
New Revision: 818290

URL: http://svn.apache.org/viewvc?rev=818290&view=rev
Log:
AXIS2-4507

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?rev=818290&r1=818289&r2=818290&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java Wed Sep 23 22:28:27 2009
@@ -27,14 +27,17 @@
 import org.apache.axis2.clustering.ClusteringConstants;
 import org.apache.axis2.clustering.management.NodeManager;
 import org.apache.axis2.clustering.state.StateManager;
+import org.apache.axis2.description.AxisModule;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.DependencyManager;
 import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.engine.ServiceLifeCycle;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.java.security.AccessController;
+import org.apache.axis2.modules.Module;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.threadpool.ThreadFactory;
 import org.apache.axis2.util.threadpool.ThreadPool;
@@ -85,7 +88,8 @@
 
     private String cachedServicePath = null;
     protected List<ContextListener> contextListeners;
-
+    private boolean stopped = false;
+    
     /**
      * Constructor
      *
@@ -727,7 +731,43 @@
             serviceGroupContextMap.clear();
         }
     }
-
+    /**
+     * Called during shutdown to clean up all Contexts
+     */
+    public void shutdownModulesAndServices() throws AxisFault{
+        if(stopped){
+            return;
+        }
+        /*Shut down the modules*/
+        if(log.isDebugEnabled()){
+            log.debug("Invoke modules shutdown.");
+        }
+        HashMap modules = axisConfiguration.getModules();
+        if (modules != null) {
+            Iterator moduleitr = modules.values().iterator();
+            while (moduleitr.hasNext()) {
+                AxisModule axisModule = (AxisModule) moduleitr.next();
+                Module module = axisModule.getModule();
+                if (module != null) {
+                    module.shutdown(this);
+                }
+            }
+        }
+        cleanupContexts();
+        /*Shut down the services*/
+        if(log.isDebugEnabled()){
+            log.debug("Invoke services shutdown.");
+        }
+        for (Iterator services = axisConfiguration.getServices().values().iterator();
+        services.hasNext();) {
+            AxisService axisService = (AxisService) services.next();
+            ServiceLifeCycle serviceLifeCycle = axisService.getServiceLifeCycle();
+            if (serviceLifeCycle != null) {
+                serviceLifeCycle.shutDown(this, axisService);
+            }
+        }
+        stopped = true;
+    }
     /**
      * Invoked during shutdown to stop the ListenerManager and perform configuration cleanup
      *
@@ -736,6 +776,14 @@
     public void terminate() throws AxisFault {
         if (listenerManager != null) {
             listenerManager.stop();
+        }else{
+            if(log.isDebugEnabled()){
+                log.debug("Start Invoke modules and services shutdown.");
+            }
+            shutdownModulesAndServices();
+            if(log.isDebugEnabled()){
+                log.debug("End Invoke modules and services shutdown.");
+            }
         }
         axisConfiguration.cleanup();
         cleanupTemp();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java?rev=818290&r1=818289&r2=818290&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java Wed Sep 23 22:28:27 2009
@@ -184,6 +184,9 @@
         }
 
         // Stop the transport senders
+        if(log.isDebugEnabled()){
+            log.debug("Start invoke transport sender shutdown.");
+        }
         HashMap<String, TransportOutDescription> outTransports =
                 configctx.getAxisConfiguration().getTransportsOut();
         if (outTransports.size() > 0) {
@@ -196,30 +199,17 @@
                 }
             }
         }
-
-        // Shut down the services
-        for (Object o : configctx.getAxisConfiguration().getServices().values()) {
-            AxisService axisService = (AxisService)o;
-            ServiceLifeCycle serviceLifeCycle = axisService.getServiceLifeCycle();
-            if (serviceLifeCycle != null) {
-                serviceLifeCycle.shutDown(configctx, axisService);
-            }
+        if(log.isDebugEnabled()){
+            log.debug("End Invoke transport sender shutdown.");
         }
-        
-        // Shut down the modules
-        HashMap<String, AxisModule> modules = configctx.getAxisConfiguration().getModules();
-        if (modules != null) {
-            Iterator<AxisModule> moduleitr = modules.values().iterator();
-            while (moduleitr.hasNext()) {
-                AxisModule axisModule = moduleitr.next();
-                Module module = axisModule.getModule();
-                if (module != null) {
-                    module.shutdown(configctx);
-                }
-            }
+        /*Shutdown modules and Services */
+        if(log.isDebugEnabled()){
+            log.debug("Start Invoke modules and services shutdown.");
+        }
+        configctx.shutdownModulesAndServices();
+        if(log.isDebugEnabled()){
+            log.debug("End Invoke modules and services shutdown.");
         }
-        configctx.cleanupContexts();
-
         stopped = true;
     }
 



Re: svn commit: r818290 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: context/ConfigurationContext.java engine/ListenerManager.java

Posted by Amila Suriarachchi <am...@gmail.com>.
On Thu, Sep 24, 2009 at 3:58 AM, <nt...@apache.org> wrote:

> Author: nthaker
> Date: Wed Sep 23 22:28:27 2009
> New Revision: 818290
>
> URL: http://svn.apache.org/viewvc?rev=818290&view=rev
> Log:
> AXIS2-4507
>
> Modified:
>
>  webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
>
>  webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java
>
> Modified:
> webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
> URL:
> http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?rev=818290&r1=818289&r2=818290&view=diff
>
> ==============================================================================
> ---
> webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
> (original)
> +++
> webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
> Wed Sep 23 22:28:27 2009
> @@ -27,14 +27,17 @@
>  import org.apache.axis2.clustering.ClusteringConstants;
>  import org.apache.axis2.clustering.management.NodeManager;
>  import org.apache.axis2.clustering.state.StateManager;
> +import org.apache.axis2.description.AxisModule;
>  import org.apache.axis2.description.AxisService;
>  import org.apache.axis2.description.AxisServiceGroup;
>  import org.apache.axis2.description.Parameter;
>  import org.apache.axis2.engine.AxisConfiguration;
>  import org.apache.axis2.engine.DependencyManager;
>  import org.apache.axis2.engine.ListenerManager;
> +import org.apache.axis2.engine.ServiceLifeCycle;
>  import org.apache.axis2.i18n.Messages;
>  import org.apache.axis2.java.security.AccessController;
> +import org.apache.axis2.modules.Module;
>  import org.apache.axis2.util.JavaUtils;
>  import org.apache.axis2.util.threadpool.ThreadFactory;
>  import org.apache.axis2.util.threadpool.ThreadPool;
> @@ -85,7 +88,8 @@
>
>     private String cachedServicePath = null;
>     protected List<ContextListener> contextListeners;
> -
> +    private boolean stopped = false;
> +
>     /**
>      * Constructor
>      *
> @@ -727,7 +731,43 @@
>             serviceGroupContextMap.clear();
>         }
>     }
> -
> +    /**
> +     * Called during shutdown to clean up all Contexts
> +     */
> +    public void shutdownModulesAndServices() throws AxisFault{
> +        if(stopped){
> +            return;
> +        }
> +        /*Shut down the modules*/
> +        if(log.isDebugEnabled()){
> +            log.debug("Invoke modules shutdown.");
> +        }
> +        HashMap modules = axisConfiguration.getModules();
> +        if (modules != null) {
> +            Iterator moduleitr = modules.values().iterator();
> +            while (moduleitr.hasNext()) {
> +                AxisModule axisModule = (AxisModule) moduleitr.next();
> +                Module module = axisModule.getModule();
> +                if (module != null) {
> +                    module.shutdown(this);
> +                }
> +            }
> +        }
> +        cleanupContexts();
> +        /*Shut down the services*/
> +        if(log.isDebugEnabled()){
> +            log.debug("Invoke services shutdown.");
> +        }
> +        for (Iterator services =
> axisConfiguration.getServices().values().iterator();
> +        services.hasNext();) {
> +            AxisService axisService = (AxisService) services.next();
> +            ServiceLifeCycle serviceLifeCycle =
> axisService.getServiceLifeCycle();
> +            if (serviceLifeCycle != null) {
> +                serviceLifeCycle.shutDown(this, axisService);
> +            }
> +        }
> +        stopped = true;
> +    }
>     /**
>      * Invoked during shutdown to stop the ListenerManager and perform
> configuration cleanup
>      *
> @@ -736,6 +776,14 @@
>     public void terminate() throws AxisFault {
>         if (listenerManager != null) {
>             listenerManager.stop();
> +        }else{
> +            if(log.isDebugEnabled()){
> +                log.debug("Start Invoke modules and services shutdown.");
> +            }
> +            shutdownModulesAndServices();
> +            if(log.isDebugEnabled()){
> +                log.debug("End Invoke modules and services shutdown.");
> +            }
>         }
>

Why the service and module shutdown at the else part?
Why it should not be done if a listener manager exists?

thanks,
Amila.


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/