On Thu, Sep 24, 2009 at 3:58 AM, <ntha...@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/

Reply via email to