You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2007/01/11 23:42:24 UTC

svn commit: r495417 - in /webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core: Messages.properties SimpleResource.java

Author: danj
Date: Thu Jan 11 14:42:24 2007
New Revision: 495417

URL: http://svn.apache.org/viewvc?view=rev&rev=495417
Log:
Fix for MUSE-178 - set hasBeenShutdown flag before calling capability shutdown routines. This way, non-capability 
code (such as ResourceManagerListeners) that learn of the resource destruction will be able to confirm it using 
the hasBeenShutdown() method.

Also added new log messages for capability shutdown events.

Modified:
    webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/Messages.properties
    webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/SimpleResource.java

Modified: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/Messages.properties?view=diff&rev=495417&r1=495416&r2=495417
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/Messages.properties Thu Jan 11 14:42:24 2007
@@ -22,6 +22,8 @@
 ContextPathNotFound=No resource definition was found for context path 'XXX'. The valid endpoints for this endpoint (as described in muse.xml) are\: XXX
 CapabilityInitialized=The resource at 'XXX' has started initialization of capability 'XXX'.
 CapabilityInitializationComplete = The resource at 'XXX' has completed initialization of capability 'XXX.
+CapabilityPreparedForShutdown=The resource at 'XXX' has started the shutdown process on capability 'XXX'.
+CapabilityShutdown=The resource at 'XXX' has completed the shutdown process for capability 'XXX.
 ExistingResourceEPR=The unique EPR of this resource instance (object) has already been set - once a resource has an identifying EPR, it cannot be changed over its lifetime.
 ResourceAlreadyDestroyed=The resource has already been destroyed. Make sure other resources do not hold stale references to it.
 NoEnvironment=The router's Environment must be set with setEnvironment() before it can be initialized (via initialize()). Make sure that a org.apache.muse.core.Environment is provided right after the router is instantiated.

Modified: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/SimpleResource.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/SimpleResource.java?view=diff&rev=495417&r1=495416&r2=495417
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/SimpleResource.java (original)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/SimpleResource.java Thu Jan 11 14:42:24 2007
@@ -272,7 +272,7 @@
     
     /**
      * 
-     * This method can be overrided to provide additional capability 
+     * This method can be overridden to provide additional capability 
      * initialization logic that applies generally to all capabilities. 
      * Capability-specific initialization logic should be provided by 
      * overriding Capability.initialize().
@@ -466,6 +466,17 @@
         //
         if (hasBeenShutdown())
             throw new SoapFault(_MESSAGES.get("ResourceAlreadyDestroyed"));
+
+        //
+        // set this flag early so that code that is invoked because of 
+        // capability shutdown tasks knows that the resource is dying
+        //
+        _hasBeenShutdown = true;
+        
+        //
+        // shutdown actual resource function (in capabilities)
+        //
+        shutdownCapabilities();
                 
         ResourceManager manager = getResourceManager();
 
@@ -492,8 +503,51 @@
         _log.info(_MESSAGES.get("ResourceDestroyed", new Object[]{ _contextPath }));
         _contextPath = null;
         _log = null;
+    }
+    
+    /**
+     * 
+     * This method can be overridden to provide additional capability 
+     * shutdown logic that applies generally to all capabilities. 
+     * Capability-specific shutdown logic should be provided by 
+     * overriding Capability.shutdown().
+     * 
+     */
+    protected void shutdownCapabilities()
+        throws SoapFault
+    {
+        String contextPath = getContextPath();
+        Logger log = getLog();
+
+        Iterator i = getCapabilityURIs().iterator();
         
-        _hasBeenShutdown = true;
+        //
+        // first warn all capabilities of pending shutdown
+        //
+        while (i.hasNext())
+        {
+            String nextURI = (String)i.next();
+            Capability next = getCapability(nextURI);
+            next.prepareShutdown();
+            
+            Object[] filler = { contextPath, nextURI };
+            log.fine(_MESSAGES.get("CapabilityPreparedForShutdown", filler));
+        }
+        
+        i = getCapabilityURIs().iterator();
+        
+        //
+        // then call shutdown() for internal capability tasks
+        //
+        while (i.hasNext())
+        {
+            String nextURI = (String)i.next();
+            Capability next = getCapability(nextURI);
+            next.shutdown();
+            
+            Object[] filler = { contextPath, nextURI };
+            log.fine(_MESSAGES.get("CapabilityShutdown", filler));
+        }
     }
     
     /**



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