geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r416195 - in /geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean: ShellServerDaemonGBean.java ShellServerGBean.java
Date Thu, 22 Jun 2006 01:51:47 GMT
Author: jdillon
Date: Wed Jun 21 18:51:46 2006
New Revision: 416195

URL: http://svn.apache.org/viewvc?rev=416195&view=rev
Log:
Adding basic gbean impl

Added:
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java
  (contents, props changed)
      - copied, changed from r416192, geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerGBean.java
Removed:
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerGBean.java

Copied: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java
(from r416192, geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerGBean.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java?p2=geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java&p1=geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerGBean.java&r1=416192&r2=416195&rev=416195&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerGBean.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java
Wed Jun 21 18:51:46 2006
@@ -20,39 +20,92 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 
+import org.apache.geronimo.gshell.server.SocketServerDaemon;
+import org.apache.geronimo.gshell.server.SocketServerDaemon.SocketHandler;
+import org.apache.geronimo.gshell.server.ShellServer;
+
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.Log;
 
+import java.net.Socket;
+
 /**
- * Shell server GBean.
+ * Shell server daemon GBean.
  *
  * @version $Id$
  */
-public class ShellServerGBean
+public class ShellServerDaemonGBean
     implements GBeanLifecycle
 {
-    private static final Log log = LogFactory.getLog(ShellServerGBean.class);
+    private static final Log log = LogFactory.getLog(ShellServerDaemonGBean.class);
+
+    private SocketServerDaemon daemon;
+
+    //
+    // Attributes
+    //
+
+    private int port = 5057;
+
+    public void setPort(final int port) {
+        this.port = port;
+    }
+
+    public int getPort() {
+        return port;
+    }
 
     //
     // GBeanLifecycle
     //
 
     public void doStart() throws Exception {
-        //
-        // TODO:
-        //
+        if (daemon != null) {
+            log.warn("Already started; ignoring start request");
+            return;
+        }
+
+        log.info("Starting");
+
+        SocketHandler handler = new SocketHandler() {
+            ShellServer server = new ShellServer();
+
+            public void handle(final Socket socket) throws Exception {
+                assert socket != null;
+
+                server.service(socket);
+            }
+        };
+
+        daemon = new SocketServerDaemon(getPort(), handler);
+        daemon.start();
+
+        log.info("Started");
     }
 
     public void doStop() throws Exception {
-        //
-        // TODO:
-        //
+        if (daemon == null) {
+            log.warn("Not started; ignoring stop request");
+            return;
+        }
+
+        log.info("Stopping");
+
+        daemon.stop();
+        daemon = null;
+
+        log.info("Stopped");
     }
 
     public void doFail() {
-        //
-        // TODO:
-        //
+        log.warn("Service failed; stopping");
+
+        try {
+            doStop();
+        }
+        catch (Exception e) {
+            log.warn("Stop after failure failed; ignorning", e);
+        }
     }
 
     //
@@ -62,7 +115,9 @@
     public static final GBeanInfo GBEAN_INFO;
 
     static {
-        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ShellServerGBean", ShellServerGBean.class);
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(
+            "Shell Server Daemon",
+            ShellServerDaemonGBean.class);
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-gbean/src/main/java/org/apache/geronimo/gshell/server/gbean/ShellServerDaemonGBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message