You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/03/25 12:45:52 UTC

svn commit: r758233 - in /servicemix/sandbox/gshell-web: ./ gshell-gwt/ gshell-gwt/src/org/apache/servicemix/gshellweb/server/ gshell-gwt/webapp/META-INF/spring/

Author: gnodet
Date: Wed Mar 25 11:45:49 2009
New Revision: 758233

URL: http://svn.apache.org/viewvc?rev=758233&view=rev
Log:
Upgrade to smx 4.0.0

Added:
    servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/CommandExecutorHolder.java
Modified:
    servicemix/sandbox/gshell-web/gshell-gwt/pom.xml
    servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/ShellServiceImpl.java
    servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml
    servicemix/sandbox/gshell-web/pom.xml

Modified: servicemix/sandbox/gshell-web/gshell-gwt/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/gshell-web/gshell-gwt/pom.xml?rev=758233&r1=758232&r2=758233&view=diff
==============================================================================
--- servicemix/sandbox/gshell-web/gshell-gwt/pom.xml (original)
+++ servicemix/sandbox/gshell-web/gshell-gwt/pom.xml Wed Mar 25 11:45:49 2009
@@ -42,19 +42,19 @@
     <dependency>
       <groupId>com.google.gwt</groupId>
       <artifactId>gwt-user</artifactId>
-      <version>1.5.1</version>
+      <version>1.5.3</version>
     </dependency>
 
     <dependency>
       <groupId>com.google.gwt</groupId>
       <artifactId>gwt-servlet</artifactId>
-      <version>1.5.1</version>
+      <version>1.5.3</version>
     </dependency>
     
     <dependency>
       <groupId>com.google.gwt</groupId>
       <artifactId>gwt-dev</artifactId>
-      <version>1.5.1</version>
+      <version>1.5.3</version>
       <classifier>linux</classifier>
       <scope>provided</scope>
     </dependency>
@@ -191,10 +191,7 @@
                     <Import-Package>
                         javax.servlet,
                         javax.servlet.http,
-                        org.apache.geronimo.gshell,
-                        org.apache.geronimo.gshell.command,
-                        org.apache.geronimo.gshell.shell,
-                        org.apache.geronimo.gshell.spring
+                        *
                     </Import-Package>
                     <Export-Package></Export-Package>
                     <Bundle-ClassPath>.,WEB-INF/classes,WEB-INF/lib/gwt-user-1.5.1.jar,WEB-INF/lib/gwt-servlet-1.5.1.jar</Bundle-ClassPath>

Added: servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/CommandExecutorHolder.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/CommandExecutorHolder.java?rev=758233&view=auto
==============================================================================
--- servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/CommandExecutorHolder.java (added)
+++ servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/CommandExecutorHolder.java Wed Mar 25 11:45:49 2009
@@ -0,0 +1,23 @@
+package org.apache.servicemix.gshellweb.server;
+
+import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Aug 27, 2008
+ * Time: 12:23:27 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class CommandExecutorHolder {
+
+    private static CommandLineExecutor commandExecutor;
+
+    public static CommandLineExecutor getCommandExecutor() {
+        return commandExecutor;
+    }
+
+    public void setCommandExecutor(CommandLineExecutor commandExecutor) {
+        CommandExecutorHolder.commandExecutor = commandExecutor;
+    }
+}

Modified: servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/ShellServiceImpl.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/ShellServiceImpl.java?rev=758233&r1=758232&r2=758233&view=diff
==============================================================================
--- servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/ShellServiceImpl.java (original)
+++ servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/ShellServiceImpl.java Wed Mar 25 11:45:49 2009
@@ -33,13 +33,11 @@
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 
 import org.apache.servicemix.gshellweb.client.ShellService;
-import org.apache.geronimo.gshell.spring.ProxyIO;
-import org.apache.geronimo.gshell.spring.EnvironmentTargetSource;
-import org.apache.geronimo.gshell.command.IO;
 import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.shell.Environment;
-import org.apache.geronimo.gshell.DefaultEnvironment;
-import org.apache.geronimo.gshell.DefaultVariables;
+import org.apache.geronimo.gshell.shell.ShellContext;
+import org.apache.geronimo.gshell.shell.Shell;
+import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
+import org.apache.geronimo.gshell.io.IO;
 
 public class ShellServiceImpl extends RemoteServiceServlet implements ShellService {
 
@@ -59,7 +57,7 @@
 
     public String login(String username, String password) {
         try {
-            Session session = new Session();
+            Session session = new Session(CommandExecutorHolder.getCommandExecutor());
             String sessionId = session.toString();
             sessions.put(sessionId, session);
             return sessionId;
@@ -76,14 +74,10 @@
         System.out.println("setNextLineIn [sessionId=" + sessionId + ", in=" + in + "]");
         Session session = useSession(sessionId);
         try {
-            EnvironmentTargetSource.setEnvironment(session.environment);
-            ProxyIO.setIO(session.io);
-            CommandExecutorHolder.getCommandExecutor().execute(in);
+            session.execute(in);
             session.outPipe.write(("Command: " + in + "\n").getBytes());
         } catch (Exception e) {
             handleException(sessionId, e);
-        } finally {
-            ProxyIO.setIO(null);
         }
     }
 
@@ -133,7 +127,8 @@
         }
     }
 
-    private static class Session {
+    private static class Session implements Shell, ShellContext {
+        private CommandLineExecutor executor;
         private long lastUsed;
         private InputStream out;
         private InputStream err;
@@ -142,10 +137,11 @@
         private PipedOutputStream outPipe;
         private PipedOutputStream errPipe;
         private IO io;
-        private Environment environment;
         private Variables variables;
 
-        public Session() throws IOException {
+        public Session(CommandLineExecutor executor) throws IOException {
+            this.executor = executor;
+
             // TODO: bridge the out / err to gshell
             outPipe = new PipedOutputStream();
             errPipe = new PipedOutputStream();
@@ -155,18 +151,63 @@
             err = new PipedInputStream(errPipe);
             errReader = new BufferedReader(new InputStreamReader(err));
 
-            io = new IO(new ByteArrayInputStream(new byte[0]), outPipe, errPipe);
-            variables = new DefaultVariables();
-            environment = new DefaultEnvironment(io, variables);
+            io = new IO(new ByteArrayInputStream(new byte[0]), outPipe, errPipe, true);
+            variables = new Variables();
 
             updateLastUsed();
         }
+
         public long getLastUsed() {
             return lastUsed;
         }
+
         public void updateLastUsed() {
             lastUsed = System.currentTimeMillis();
         }
+
+        public ShellContext getContext() {
+            return this;
+        }
+
+        public Object execute(String line) throws Exception {
+            return executor.execute(this, line);
+        }
+
+        public Object execute(String command, Object[] args) throws Exception {
+            return executor.execute(this, command, args);
+        }
+
+        public Object execute(Object... args) throws Exception {
+            return executor.execute(this, args);
+        }
+
+        public boolean isOpened() {
+            return false;  //To change body of implemented methods use File | Settings | File Templates.
+        }
+
+        public void close() {
+            //To change body of implemented methods use File | Settings | File Templates.
+        }
+
+        public boolean isInteractive() {
+            return true;
+        }
+
+        public void run(Object... args) throws Exception {
+            //To change body of implemented methods use File | Settings | File Templates.
+        }
+
+        public Shell getShell() {
+            return this;
+        }
+
+        public IO getIo() {
+            return io;
+        }
+
+        public Variables getVariables() {
+            return variables;
+        }
     }
 
 }

Modified: servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml?rev=758233&r1=758232&r2=758233&view=diff
==============================================================================
--- servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml (original)
+++ servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml Wed Mar 25 11:45:49 2009
@@ -32,7 +32,7 @@
   http://www.springframework.org/schema/osgi-compendium
   http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
 
-    <osgi:reference id="commandExecutor" interface="org.apache.geronimo.gshell.command.CommandExecutor">
+    <osgi:reference id="commandExecutor" interface="org.apache.geronimo.gshell.commandline.CommandLineExecutor">
     </osgi:reference>
 
     <bean id="holder" class="org.apache.servicemix.gshellweb.server.CommandExecutorHolder">

Modified: servicemix/sandbox/gshell-web/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/gshell-web/pom.xml?rev=758233&r1=758232&r2=758233&view=diff
==============================================================================
--- servicemix/sandbox/gshell-web/pom.xml (original)
+++ servicemix/sandbox/gshell-web/pom.xml Wed Mar 25 11:45:49 2009
@@ -22,7 +22,7 @@
   <parent>
       <groupId>org.apache.servicemix.features</groupId>
       <artifactId>features</artifactId>
-      <version>4.0-m2-SNAPSHOT</version>
+      <version>4.0.0</version>
   </parent>
 
   <groupId>org.apache.servicemix.gshell-web</groupId>