You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/09/22 09:52:31 UTC

svn commit: r697691 - in /geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server: RemoteShellImpl.java handler/OpenShellHandler.java handler/ServerSessionContext.java

Author: jdillon
Date: Mon Sep 22 00:52:31 2008
New Revision: 697691

URL: http://svn.apache.org/viewvc?rev=697691&view=rev
Log:
Re-implemented RemoteShellImpl, hacked in the ShellContext just to make it work again

Modified:
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java?rev=697691&r1=697690&r2=697691&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java Mon Sep 22 00:52:31 2008
@@ -43,6 +43,8 @@
     @Autowired
     private CommandLineExecutor executor;
 
+    private ShellContext context;
+
     private boolean opened = true;
 
     public RemoteShellImpl() {}
@@ -66,9 +68,17 @@
     public ShellContext getContext() {
         ensureOpened();
 
-        // FIXME:
+        if (context == null) {
+            throw new IllegalStateException("Shell context has not been initialized");
+        }
+        return context;
+    }
+
+    // HACK: Allow context to be forced into the shell
+    public void setContext(final ShellContext context) {
+        assert context != null;
 
-        return null;
+        this.context = context;
     }
 
     public ShellInfo getInfo() {
@@ -78,35 +88,36 @@
     }
 
     public Object execute(final String line) throws Exception {
-        ensureOpened();
+        assert line != null;
 
-        // FIXME:
+        ensureOpened();
 
-        return null;
+        return executor.execute(getContext(), line);
     }
 
     public Object execute(final String command, final Object[] args) throws Exception {
-        ensureOpened();
+        assert command != null;
+        assert args != null;
 
-        // FIXME:
+        ensureOpened();
 
-        return null;
+        return executor.execute(getContext(), command, args);
     }
 
     public Object execute(final Object... args) throws Exception {
-        ensureOpened();
+        assert args != null;
 
-        // FIXME:
+        ensureOpened();
 
-        return null;
+        return executor.execute(getContext(), args);
     }
 
     public Object execute(final Object[][] commands) throws Exception {
-        ensureOpened();
+        assert commands != null;
 
-        // FIXME:
+        ensureOpened();
 
-        return null;
+        return executor.execute(getContext(), commands);
     }
 
     public boolean isInteractive() {

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java?rev=697691&r1=697690&r2=697691&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java Mon Sep 22 00:52:31 2008
@@ -20,12 +20,15 @@
 package org.apache.geronimo.gshell.remote.server.handler;
 
 import org.apache.geronimo.gshell.remote.RemoteShell;
-import org.apache.geronimo.gshell.remote.message.EchoMessage;
 import org.apache.geronimo.gshell.remote.message.OpenShellMessage;
 import org.apache.geronimo.gshell.remote.server.RemoteIO;
+import org.apache.geronimo.gshell.remote.server.RemoteShellImpl;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.whisper.transport.Session;
+import org.apache.geronimo.gshell.shell.ShellContext;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.command.Variables;
 
 import java.util.UUID;
 
@@ -61,9 +64,22 @@
         // Setup the I/O context (w/o auto-flushing)
         context.io = new RemoteIO(session);
 
+        context.variables = new Variables();
+
         // Create a new shell instance
         context.shell = context.container.getBean("remoteShell", RemoteShell.class);
-        
+
+        // HACK: Need to force the context into the shell
+        ((RemoteShellImpl)context.shell).setContext(new ShellContext() {
+            public IO getIo() {
+                return context.io;
+            }
+
+            public Variables getVariables() {
+                return context.variables;
+            }
+        });
+
         OpenShellMessage.Result reply = new OpenShellMessage.Result();
         reply.setCorrelationId(message.getId());
         session.send(reply);

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java?rev=697691&r1=697690&r2=697691&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java Mon Sep 22 00:52:31 2008
@@ -29,6 +29,7 @@
 import org.apache.geronimo.gshell.remote.server.RemoteIO;
 import org.apache.geronimo.gshell.whisper.util.SessionAttributeBinder;
 import org.apache.geronimo.gshell.spring.BeanContainer;
+import org.apache.geronimo.gshell.command.Variables;
 
 /**
  * Container for server-side session state.
@@ -47,6 +48,8 @@
 
     public RemoteIO io;
 
+    public Variables variables;
+
     public RemoteShell shell;
 
     public Object getIdentityToken() {
@@ -74,6 +77,7 @@
         container = null;
 
         io = null;
+        variables = null;
         identity = null;
         pk = null;
     }