geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r942843 - in /geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo: ServerProxy.java server/StartServerMojo.java server/StopServerMojo.java
Date Mon, 10 May 2010 18:57:33 GMT
Author: gawor
Date: Mon May 10 18:57:32 2010
New Revision: 942843

URL: http://svn.apache.org/viewvc?rev=942843&view=rev
Log:
1) attempt to wait for server to stop and 2) decrease polling frequency to see if the server
is running

Modified:
    geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
    geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
    geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java

Modified: geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java?rev=942843&r1=942842&r2=942843&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
(original)
+++ geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
Mon May 10 18:57:32 2010
@@ -211,23 +211,43 @@ public class ServerProxy
         return lastError;
     }
 
+    private ObjectName getMBean(String name) throws Exception {
+        Set<ObjectName> objectNameSet =
+            mbeanConnection.queryNames(new ObjectName(name), null);
+        if (objectNameSet.isEmpty()) {
+            throw new Exception("Mbean not found");
+        } else if (objectNameSet.size() == 1) {
+            return objectNameSet.iterator().next();
+        } else {
+            throw new Exception("Multiple mbeans found");
+        }
+    }
+    
     public void shutdown() {
         try {
-            Set<ObjectName> objectNameSet =
-                mbeanConnection.queryNames(new ObjectName("osgi.core:type=framework,*"),
null);
-            if (objectNameSet.isEmpty()) {
-                throw new Exception("Framework mbean not found");
-            } else if (objectNameSet.size() == 1) {
-                mbeanConnection.invoke(objectNameSet.iterator().next(), "stopBundle",
-                                          new Object[] { 0 }, new String[] { long.class.getName()
});
-            }
-        }
-        catch (Exception e) {
+            ObjectName frameworkMBean = getMBean("osgi.core:type=framework,*");
+            mbeanConnection.invoke(frameworkMBean, "stopBundle",
+                                   new Object[] { 0 }, new String[] { long.class.getName()
});
+        } catch (Exception e) {
             log.warn("Unable to shutdown the server", e);
             lastError = e;
         }
     }
 
+    public void waitForStop() {    
+        // wait for first IOException
+        try {
+            while (true) {
+                ObjectName bundleStateMBean = getMBean("osgi.core:type=bundleState,*");
+                Thread.sleep(5 * 1000);
+            }
+        } catch (IOException e) {
+            // connection error means server is shutdown
+        } catch (Exception e) {
+            log.warn("Unexpected error while waiting for server shutdown", e);
+        }
+    }
+    
     //
     // Kernel invocation helpers
     //

Modified: geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java?rev=942843&r1=942842&r2=942843&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
(original)
+++ geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
Mon May 10 18:57:32 2010
@@ -375,7 +375,7 @@ public class StartServerMojo
                     log.debug("Server query failed; ignoring", error);
                 }
 
-                Thread.sleep(1000);
+                Thread.sleep(5 * 1000);
             }
         }
         server.closeConnection();

Modified: geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java?rev=942843&r1=942842&r2=942843&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java
(original)
+++ geronimo/server/trunk/framework/buildsupport/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java
Mon May 10 18:57:32 2010
@@ -62,6 +62,7 @@ public class StopServerMojo
             log.info("Stopping Geronimo server...");
             
             server.shutdown();
+            server.waitForStop();
             server.closeConnection();
 
             //



Mime
View raw message