servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r701359 - in /servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin: ./ internal/ internal/commands/
Date Fri, 03 Oct 2008 12:10:21 GMT
Author: gnodet
Date: Fri Oct  3 05:10:21 2008
New Revision: 701359

URL: http://svn.apache.org/viewvc?rev=701359&view=rev
Log:
SMX4KNL-111: Add a 'starting' state to the admin list command

Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java?rev=701359&r1=701358&r2=701359&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
Fri Oct  3 05:10:21 2008
@@ -26,7 +26,7 @@
 
     void changePort(String name, int port) throws Exception;
 
-    boolean isRunning(String name) throws Exception;
+    String getState(String name) throws Exception;
 
     void start(String name, String javaOpts) throws Exception;
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java?rev=701359&r1=701358&r2=701359&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
Fri Oct  3 05:10:21 2008
@@ -18,6 +18,10 @@
 
 public interface Instance {
 
+    String STOPPED = "Stopped";
+    String STARTING = "Starting";
+    String STARTED = "Started";
+
     String getName();
 
     String getLocation();
@@ -34,6 +38,6 @@
 
     void destroy() throws Exception;
 
-    boolean isRunning() throws Exception;
+    String getState() throws Exception;
 
 }

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java?rev=701359&r1=701358&r2=701359&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
Fri Oct  3 05:10:21 2008
@@ -53,8 +53,8 @@
         getExistingInstance(name).changePort(port);
     }
 
-    public boolean isRunning(String name) throws Exception {
-        return getExistingInstance(name).isRunning();
+    public String getState(String name) throws Exception {
+        return getExistingInstance(name).getState();
     }
 
     public void start(String name, String javaOpts) throws Exception {

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java?rev=701359&r1=701358&r2=701359&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
Fri Oct  3 05:10:21 2008
@@ -27,6 +27,7 @@
 import java.io.OutputStream;
 import java.util.Properties;
 import java.net.URI;
+import java.net.Socket;
 
 import org.apache.servicemix.jpm.Process;
 import org.apache.servicemix.jpm.ProcessBuilderFactory;
@@ -158,9 +159,21 @@
     }
 
 
-    public synchronized boolean isRunning() {
+    public synchronized String getState() {
         checkProcess();
-        return this.process != null;
+        if (this.process == null) {
+            return STOPPED;
+        } else {
+            try {
+                int port = getPort();
+                Socket s = new Socket("localhost", port);
+                s.close();
+                return STARTED;
+            } catch (Exception e) {
+                // ignore
+            }
+            return STARTING;
+        }
     }
 
     protected void checkProcess() {

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java?rev=701359&r1=701358&r2=701359&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java
Fri Oct  3 05:10:21 2008
@@ -45,7 +45,11 @@
             }
             sb.append(s);
             sb.append("] [");
-            sb.append(instance.isRunning() ? "Started" : "Stopped");
+            String state = instance.getState();
+            while (state.length() < "starting".length()) {
+                state += " ";
+            }
+            sb.append(state);
             sb.append("] [");
             s = Integer.toString(instance.getPid());
             for (int i = s.length(); i < 5; i++) {



Mime
View raw message