geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r671360 - in /geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config: ConfigurationModel.java ConfigurationStatus.java KernelConfigurationManager.java
Date Tue, 24 Jun 2008 21:52:26 GMT
Author: dwoods
Date: Tue Jun 24 14:52:26 2008
New Revision: 671360

URL: http://svn.apache.org/viewvc?rev=671360&view=rev
Log:
GERONIMO-3974 Shutdown exceptions on IBM JVM

Modified:
    geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
    geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java
    geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java?rev=671360&r1=671359&r2=671360&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
Tue Jun 24 14:52:26 2008
@@ -226,4 +226,12 @@
         }
         return result;
     }
+    
+    public LinkedHashSet getStartedChildren(Artifact configurationId) {
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
+        if (configurationStatus == null) {
+            return new LinkedHashSet();
+        }
+        return configurationStatus.getStartedChildren();
+    }
 }

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java?rev=671360&r1=671359&r2=671360&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java
Tue Jun 24 14:52:26 2008
@@ -85,6 +85,35 @@
     public Artifact getConfigurationId() {
         return configurationId;
     }
+    
+    public LinkedHashSet getStartedChildren() {
+        LinkedHashSet childrenStatuses = new LinkedHashSet();
+        getStartedChildrenInternal(childrenStatuses);
+
+        LinkedHashSet childrenIds = new LinkedHashSet(childrenStatuses.size());
+        for (Iterator iterator = childrenStatuses.iterator(); iterator.hasNext();) {
+            ConfigurationStatus configurationStatus = (ConfigurationStatus) iterator.next();
+            childrenIds.add(configurationStatus.configurationId);
+        }
+
+        return childrenIds;
+    }
+
+    private void getStartedChildrenInternal(LinkedHashSet childrenStatuses) {
+        // if we aren't started, there is nothing to do
+        if (!started) {
+            return;
+        }
+
+        // visit all children
+        for (Iterator iterator = startChildren.iterator(); iterator.hasNext();) {
+            ConfigurationStatus child = (ConfigurationStatus) iterator.next();
+            if (child.isStarted() && !child.configurationId.equals(configurationId))
{
+                child.getStartedChildrenInternal(childrenStatuses);
+            }
+        }
+        childrenStatuses.add(this);
+    }
 
     public boolean isLoaded() {
         return loaded;

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?rev=671360&r1=671359&r2=671360&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
Tue Jun 24 14:52:26 2008
@@ -18,6 +18,7 @@
 package org.apache.geronimo.kernel.config;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.Map;
@@ -78,7 +79,7 @@
         this.artifactManager = artifactManager;
         this.classLoader = classLoader;
 
-        shutdownHook = new ShutdownHook(kernel);
+        shutdownHook = new ShutdownHook(kernel, configurationModel);
     }
 
     private static ArtifactResolver createArtifactResolver(ArtifactResolver artifactResolver,
ArtifactManager artifactManager, Collection repositories) {
@@ -298,9 +299,11 @@
 
     private static class ShutdownHook implements Runnable {
         private final Kernel kernel;
+        private final ConfigurationModel configurationModel;
 
-        public ShutdownHook(Kernel kernel) {
+        public ShutdownHook(Kernel kernel, ConfigurationModel configurationModel) {
             this.kernel = kernel;
+            this.configurationModel = configurationModel;
         }
 
         public void run() {
@@ -309,21 +312,37 @@
                 if (configs.isEmpty()) {
                     return;
                 }
+                LinkedHashSet orderedConfigs = new LinkedHashSet();
                 for (Iterator i = configs.iterator(); i.hasNext();) {
                     AbstractName configName = (AbstractName) i.next();
-                    if (kernel.isLoaded(configName)) {
-                        try {
-                            kernel.stopGBean(configName);
-                        } catch (GBeanNotFoundException e) {
-                            // ignore
-                        } catch (InternalKernelException e) {
-                            log.warn("Could not stop configuration: " + configName, e);
-                        }
-                        try {
-                            kernel.unloadGBean(configName);
-                        } catch (GBeanNotFoundException e) {
-                            // ignore
+                    if (kernel.isLoaded(configName) && !orderedConfigs.contains(configName))
{
+                        LinkedHashSet startedChildren = configurationModel.getStartedChildren(configName.getArtifact());
+                        for (Iterator iterator = startedChildren.iterator(); iterator.hasNext();)
{
+                            Artifact configurationId = (Artifact) iterator.next();
+                            Set childConfig = kernel.listGBeans(new AbstractNameQuery(configurationId,
Collections.emptyMap() , Configuration.class.getName()));
+                            if (!childConfig.isEmpty()) {
+                                AbstractName childConfigName = (AbstractName) childConfig.iterator().next();
+                                if (!orderedConfigs.contains(childConfigName))
+                                    orderedConfigs.add(childConfigName);
+                            }
                         }
+                        orderedConfigs.add(configName);
+                    }
+                }
+
+                for (Iterator i = orderedConfigs.iterator(); i.hasNext();) {
+                    AbstractName configName = (AbstractName) i.next();
+                    try {
+                        kernel.stopGBean(configName);
+                    } catch (GBeanNotFoundException e) {
+                        // ignore
+                    } catch (InternalKernelException e) {
+                        log.warn("Could not stop configuration: " + configName, e);
+                    }
+                    try {
+                        kernel.unloadGBean(configName);
+                    } catch (GBeanNotFoundException e) {
+                        // ignore
                     }
                 }
             }



Mime
View raw message