geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r577545 [3/3] - in /geronimo/sandbox/gshell/trunk: gshell-assembly/src/main/underlay/etc/ gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/ gshell-remote/gshell-remote-common/src/main/java/org/apache...
Date Thu, 20 Sep 2007 04:55:22 GMT
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/vm/VmTransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/vm/VmTransportServer.java?rev=577545&r1=577544&r2=577545&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/vm/VmTransportServer.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/vm/VmTransportServer.java
Wed Sep 19 21:55:19 2007
@@ -21,11 +21,8 @@
 
 import java.net.URI;
 
-import org.apache.geronimo.gshell.remote.message.MessageVisitor;
-import org.apache.geronimo.gshell.remote.security.SecurityFilter;
-import org.apache.geronimo.gshell.remote.transport.TransportServer;
-import org.apache.geronimo.gshell.remote.transport.TransportSupport;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransportServer;
+import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.transport.vmpipe.VmPipeAcceptor;
 import org.apache.mina.transport.vmpipe.VmPipeAddress;
 
@@ -35,81 +32,13 @@
  * @version $Rev$ $Date$
  */
 public class VmTransportServer
-    extends TransportSupport
-    implements TransportServer
+    extends TcpTransportServer
 {
-    protected final URI location;
-
-    protected final VmPipeAddress address;
-
-    protected VmPipeAcceptor acceptor;
-
-    protected boolean bound;
-
-    private SecurityFilter securityFilter;
-
     public VmTransportServer(final URI location) throws Exception {
-        assert location != null;
-
-        this.location = location;
-        this.address = new VmPipeAddress(location.getPort());
-    }
-
-    public URI getLocation() {
-        return location;
-    }
-
-    //
-    // NOTE: Setters exposed to support Plexus autowire()  Getters exposed to handle state
checking.
-    //
-
-    public void setSecurityFilter(final SecurityFilter securityFilter) {
-        this.securityFilter = securityFilter;
-    }
-
-    protected SecurityFilter getSecurityFilter() {
-        if (securityFilter == null) {
-            throw new IllegalStateException("Security filter not bound");
-        }
-
-        return securityFilter;
+        super(location, new VmPipeAddress(location.getPort()));
     }
 
-    protected synchronized void init() throws Exception {
-        acceptor = new VmPipeAcceptor();
-        acceptor.setLocalAddress(address);
-
-        //
-        // HACK: Need to manually wire in the visitor impl for now... :-(
-        //
-
-        setMessageVisitor((MessageVisitor) getContainer().lookup(MessageVisitor.class, "server"));
-
-        configure(acceptor);
-
-        DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain();
-
-        // Install the authentication filter right after the protocol filter
-        filterChain.addAfter(PROTOCOL_FILTER_NAME, SecurityFilter.NAME, getSecurityFilter());
-    }
-
-    public synchronized void bind() throws Exception {
-        if (bound) {
-            throw new IllegalStateException("Already bound");
-        }
-
-        init();
-
-        acceptor.bind();
-
-        bound = true;
-
-        log.info("Listening on: {}", address);
-    }
-
-    public synchronized void close() {
-        acceptor.unbind();
-
-        log.info("Closed");
+    protected IoAcceptor createAcceptor() throws Exception {
+        return new VmPipeAcceptor();
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java?rev=577545&r1=577544&r2=577545&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
Wed Sep 19 21:55:19 2007
@@ -42,7 +42,7 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=RemoteShell.class, instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
+@Component(role=RemoteShell.class) // instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class DefaultRemoteShell
     implements RemoteShell, Initializable
 {

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java?rev=577545&r1=577544&r2=577545&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
Wed Sep 19 21:55:19 2007
@@ -19,6 +19,8 @@
 
 package org.apache.geronimo.gshell.remote.server;
 
+import java.io.PrintWriter;
+import java.util.Date;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -34,6 +36,8 @@
 import org.apache.geronimo.gshell.remote.message.MessageVisitor;
 import org.apache.geronimo.gshell.remote.message.MessageVisitorSupport;
 import org.apache.geronimo.gshell.remote.message.OpenShellMessage;
+import org.apache.geronimo.gshell.remote.stream.SessionInputStream;
+import org.apache.geronimo.gshell.remote.stream.SessionOutputStream;
 import org.apache.geronimo.gshell.shell.Environment;
 import org.apache.mina.common.IoSession;
 import org.codehaus.plexus.ContainerConfiguration;
@@ -60,10 +64,6 @@
     @Requirement
     private PlexusContainer container;
 
-    //
-    // Remote Shell Access
-    //
-
     private ClassWorld getClassWorld() {
         return container.getContainerRealm().getWorld();
     }
@@ -81,7 +81,7 @@
         session.setAttribute(PlexusContainer.class.getName(), container);
 
         // Setup the I/O context (w/o auto-flushing)
-        IO io = new IO(getInputStream(session), getOutputStream(session), false);
+        IO io = new IO(SessionInputStream.lookup(session), SessionOutputStream.lookup(session),
false);
 
         //
         // FIXME: We need to set the verbosity of this I/O context as specified by the client
@@ -154,7 +154,34 @@
 
         String text = msg.getText();
 
-        msg.reply(new EchoMessage(text));
+        //
+        // HACK:
+        //
+        
+        if ("NOISE MAKER".equals(text)) {
+            log.info("Making noise...");
+            
+            final IoSession session = msg.getSession();
+            final PrintWriter out = new PrintWriter(SessionOutputStream.lookup(session),
false);
+
+            new Thread("NOISE MAKER") {
+                public void run() {
+                    while (true) {
+                        out.println("FROM SERVER: " + new Date());
+                        out.flush();
+                        
+                        try {
+                            Thread.sleep(5000);
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }.start();
+        }
+        else {
+            msg.reply(new EchoMessage(text));
+        }
     }
 
     public void visitOpenShell(final OpenShellMessage msg) throws Exception {
@@ -195,7 +222,7 @@
         msg.reply(new EchoMessage("CLOSE SHELL SUCCESS"));
     }
 
-    private ExecutorService executorService = Executors.newCachedThreadPool();
+    private ExecutorService executor = Executors.newCachedThreadPool();
 
     public void visitExecute(final ExecuteMessage msg) throws Exception {
         assert msg != null;
@@ -206,7 +233,7 @@
 
         final RemoteShell shell = getRemoteShell(session);
 
-        Runnable executeCommandTask = new Runnable() {
+        Runnable task = new Runnable() {
             public void run() {
                 log.info("EXECUTE: {}", msg);
                 
@@ -241,6 +268,12 @@
             }
         };
 
-        executorService.submit(executeCommandTask);
+        task.run();
+
+        //
+        // HACK: More blind testing...
+        //
+
+        // executor.execute(task);
     }
 }



Mime
View raw message