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 2008/08/27 16:01:08 UTC

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

Author: gnodet
Date: Wed Aug 27 07:01:06 2008
New Revision: 689482

URL: http://svn.apache.org/viewvc?rev=689482&view=rev
Log:
Make the shell work in smx4

Added:
    servicemix/sandbox/gshell-web/gshell-gwt/src/org/apache/servicemix/gshellweb/server/CommandExecutorHolder.java
    servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/
    servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/
    servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml
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/WEB-INF/web.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=689482&r1=689481&r2=689482&view=diff
==============================================================================
--- servicemix/sandbox/gshell-web/gshell-gwt/pom.xml (original)
+++ servicemix/sandbox/gshell-web/gshell-gwt/pom.xml Wed Aug 27 07:01:06 2008
@@ -1,20 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -36,19 +36,34 @@
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging-api</artifactId>
-      <version>1.0.4</version>
+      <version>1.1</version>
     </dependency>
 
     <dependency>
       <groupId>com.google.gwt</groupId>
       <artifactId>gwt-user</artifactId>
-      <version>1.5-RC1</version>
+      <version>1.5.1</version>
     </dependency>
 
     <dependency>
       <groupId>com.google.gwt</groupId>
       <artifactId>gwt-servlet</artifactId>
-      <version>1.5-RC1</version>
+      <version>1.5.1</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>com.google.gwt</groupId>
+      <artifactId>gwt-dev</artifactId>
+      <version>1.5.1</version>
+      <classifier>linux</classifier>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+        <groupId>org.apache.servicemix.kernel.gshell</groupId>
+        <artifactId>org.apache.servicemix.kernel.gshell.core</artifactId>
+        <version>${servicemix.kernel.version}</version>
+        <scope>provided</scope>
     </dependency>
 
     <!-- testing -->
@@ -87,66 +102,39 @@
 
   <build>
     <sourceDirectory>src</sourceDirectory>
+    <resources>
+      <resource>
+        <directory>src</directory>
+        <includes>
+          <include>**/*.css</include>
+          <include>**/*.gif</include>
+          <include>**/*.html</include>
+          <include>**/*.java</include>
+          <include>**/*.jpg</include>
+          <include>**/*.png</include>
+          <include>**/*.properties</include>
+          <include>**/*.xml</include>
+        </includes>
+      </resource>
+    </resources>
     <testSourceDirectory>test</testSourceDirectory>
     <testResources>
       <testResource>
         <directory>test</directory>
         <includes>
-            <include>*.xml</include>
-			<include>*.log</include>
+            <include>**/*.css</include>
+            <include>**/*.gif</include>
+            <include>**/*.html</include>
+            <include>**/*.java</include>
+            <include>**/*.jpg</include>
+            <include>**/*.png</include>
+            <include>**/*.properties</include>
+            <include>**/*.xml</include>
         </includes>
-        
       </testResource>
     </testResources>    
-    <!--
-        <resources>
-          <resource>
-            <directory>src/webapp</directory>
-          </resource>
-        </resources>
-    -->
-
-    <plugins>
-<!-- We might have to manually install the gwt plugins into maven
-       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-install-plugin</artifactId>
-        <version>2.2</version>
-        <executions>
-          <execution>
-            <id>gwt-servlet</id>
-            <goals>
-              <goal>install-file</goal>
-            </goals>
-            <phase>validate</phase>
-            <configuration>
-              <groupId>com.google.gwt</groupId>
-              <artifactId>gwt-servlet</artifactId>
-              <version>1.5-snapshot</version>
-              <packaging>jar</packaging>
-              <pomFile>gwt-servlet-1.5-snapshot.pom</pomFile>
-              <file>dependencies/gwt-servlet-1.5-snapshot.jar</file>
-            </configuration>
-          </execution>
-          <execution>
-            <id>gwt-user</id>
-            <goals>
-              <goal>install-file</goal>
-            </goals>
-            <phase>validate</phase>
-            <configuration>
-              <groupId>com.google.gwt</groupId>
-              <artifactId>gwt-user</artifactId>
-              <version>1.5-snapshot</version>
-              <packaging>jar</packaging>
-              <pomFile>gwt-user-1.5-snapshot.pom</pomFile>
-              <file>dependencies/gwt-user-1.5-snapshot.jar</file>
-            </configuration>
-          </execution>          
-        </executions>
-      </plugin>
--->
     
+    <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
@@ -158,40 +146,78 @@
       </plugin>
 
       <plugin>  
-        <groupId>gwtforge.gwtplugin</groupId>  
-        <artifactId>gwtforge.gwtplugin</artifactId>  
-        <!-- <version>1.4.61</version> -->
-        <version>1.5-dev-27-01-2008</version>
-
-        <!--Associate the plugin to the maven compile phase-->  
-        <executions>  
-          <execution>  
-            <phase>compile</phase>  
-            <goals>  
-              <goal>compile</goal>  
-            </goals>  
-          </execution>  
-        </executions>  
-  
-        <configuration>
-          <!-- The plugin will discover the modules by itself -->  
-          <!-- Define here the target compilation directory -->  
-          <out>.</out>
-          <!--  Define here the log level of the gwt compiler -->  
-          <!--  Could be : INFO , ERROR , WARN , SPAM -->  
-          <loglevel>ALL</loglevel>
-
-          <!-- OPTIONAL JVM OPTIONS -->  
-          <!-- See http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html#0.0.0.0./Heap/Size/7Coutline -->  
-          <!--  Define the java heap size -->  
-          <initialheapsize>500m</initialheapsize>  
-          <!--  Define the maximum java heap size  -->  
-          <maximumheapsize>500m</maximumheapsize>  
-          <!-- Define the heap size for young generation -->  
-          <younggenerationheapsize>250m</younggenerationheapsize>
-        </configuration>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>exec-maven-plugin</artifactId>
+          <version>1.1</version>
+          <executions>
+            <execution>
+              <!-- TODO can't find another phase that works thats called after test but before package -->
+              <!--<phase>process-test-classes</phase>-->
+              <phase>process-classes</phase>
+              <goals>
+                <goal>exec</goal>
+              </goals>
+            </execution>
+          </executions>
+
+          <configuration>
+            <executable>java</executable>
+            <classpathScope>test</classpathScope>
+            <includePluginDependencies>true</includePluginDependencies>
+            <includeProjectDependencies>true</includeProjectDependencies>
+
+            <arguments>
+              <argument>-Xmx512m</argument>
+              <argument>-classpath</argument>
+              <classpath/>
+              <argument>com.google.gwt.dev.GWTCompiler</argument>
+              <argument>-gen</argument>
+              <argument>target/gwt-gen</argument>
+              <argument>-out</argument>
+              <argument>target/${pom.artifactId}-${pom.version}</argument>
+              <argument>-logLevel</argument>
+              <argument>INFO</argument>
+              <argument>org.apache.servicemix.gshellweb.WebConsole</argument>
+            </arguments>
+          </configuration>
       </plugin>  
 
+        <plugin>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>maven-bundle-plugin</artifactId>
+            <version>1.4.3</version>
+            <configuration>
+                <instructions>
+                    <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>
+                    <Spring-Context>*;publish-context:=false;create-asynchronously:=false</Spring-Context>
+                </instructions>
+                <supportedProjectTypes>
+                  <supportedProjectType>war</supportedProjectType>
+                </supportedProjectTypes>
+                <manifestLocation>
+                    ${basedir}/target/${pom.artifactId}-${pom.version}/META-INF
+                </manifestLocation>
+            </configuration>
+            <executions>
+                <execution>
+                    <id>bundle-manifest</id>
+                    <phase>process-classes</phase>
+                    <goals>
+                        <goal>manifest</goal>
+                    </goals>
+                </execution>
+            </executions>
+        </plugin>
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-war-plugin</artifactId>
@@ -199,35 +225,22 @@
         <configuration>
           <webXml>webapp/WEB-INF/web.xml</webXml>
           <warSourceDirectory>webapp</warSourceDirectory>
+          <archive>
+            <manifestFile>${basedir}/target/${pom.artifactId}-${pom.version}/META-INF/MANIFEST.MF</manifestFile>
+          </archive>
         </configuration>
       </plugin>
 
       <plugin>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>maven-jetty-plugin</artifactId>
+        <version>6.1.12rc1</version>
         <configuration>
           <webAppSourceDirectory>${basedir}/target/${pom.artifactId}-${pom.version}</webAppSourceDirectory>
           <webXml>${basedir}/target/${pom.artifactId}-${pom.version}/WEB-INF/web.xml</webXml>
         </configuration>
       </plugin>
       
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>selenium-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <phase>pre-integration-test</phase>
-                        <goals>
-                            <goal>start-server</goal>
-                        </goals>
-                        <configuration>
-                            <background>true</background>
-                            <logOutput>true</logOutput>
-                        </configuration>
-                    </execution>
-                 
-                </executions>
-            </plugin>      
     </plugins>
   </build>
 

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=689482&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 Aug 27 07:01:06 2008
@@ -0,0 +1,23 @@
+package org.apache.servicemix.gshellweb.server;
+
+import org.apache.geronimo.gshell.command.CommandExecutor;
+
+/**
+ * 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 CommandExecutor commandExecutor;
+
+    public static CommandExecutor getCommandExecutor() {
+        return commandExecutor;
+    }
+
+    public void setCommandExecutor(CommandExecutor 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=689482&r1=689481&r2=689482&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 Aug 27 07:01:06 2008
@@ -22,18 +22,24 @@
 import java.util.TimerTask;
 import java.io.InputStream;
 import java.io.PipedInputStream;
-import java.io.Reader;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.io.PipedOutputStream;
 import java.io.IOException;
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 
 import javax.servlet.ServletException;
 
 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;
 
 public class ShellServiceImpl extends RemoteServiceServlet implements ShellService {
 
@@ -70,9 +76,14 @@
         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.outPipe.write(("Command: " + in + "\n").getBytes());
-        } catch (IOException e) {
+        } catch (Exception e) {
             handleException(sessionId, e);
+        } finally {
+            ProxyIO.setIO(null);
         }
     }
 
@@ -81,7 +92,7 @@
         Session session = useSession(sessionId);
         try {
             return session.outReader.readLine();
-        } catch (IOException e) {
+        } catch (Exception e) {
             handleException(sessionId, e);
             return null;
         }
@@ -92,14 +103,15 @@
         Session session = useSession(sessionId);
         try {
             return session.errReader.readLine();
-        } catch (IOException e) {
+        } catch (Exception e) {
             handleException(sessionId, e);
             return null;
         }
 	}
 
-    private void handleException(String sessionId, IOException e) {
+    private void handleException(String sessionId, Exception e) {
         System.err.println("Exception in session: " + sessionId + ": " + e);
+        e.printStackTrace(System.err);
     }
 
     private Session useSession(String sessionId) {
@@ -129,6 +141,9 @@
         private BufferedReader errReader;
         private PipedOutputStream outPipe;
         private PipedOutputStream errPipe;
+        private IO io;
+        private Environment environment;
+        private Variables variables;
 
         public Session() throws IOException {
             // TODO: bridge the out / err to gshell
@@ -140,6 +155,10 @@
             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);
+
             updateLastUsed();
         }
         public long getLastUsed() {

Added: 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=689482&view=auto
==============================================================================
--- servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml (added)
+++ servicemix/sandbox/gshell-web/gshell-gwt/webapp/META-INF/spring/gshell-gwt.xml Wed Aug 27 07:01:06 2008
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+  http://www.springframework.org/schema/beans
+  http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://www.springframework.org/schema/util
+  http://www.springframework.org/schema/util/spring-util.xsd
+  http://www.springframework.org/schema/osgi
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd
+  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>
+
+    <bean id="holder" class="org.apache.servicemix.gshellweb.server.CommandExecutorHolder">
+        <property name="commandExecutor" ref="commandExecutor" />
+    </bean>
+
+</beans>
\ No newline at end of file

Modified: servicemix/sandbox/gshell-web/gshell-gwt/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/gshell-web/gshell-gwt/webapp/WEB-INF/web.xml?rev=689482&r1=689481&r2=689482&view=diff
==============================================================================
--- servicemix/sandbox/gshell-web/gshell-gwt/webapp/WEB-INF/web.xml (original)
+++ servicemix/sandbox/gshell-web/gshell-gwt/webapp/WEB-INF/web.xml Wed Aug 27 07:01:06 2008
@@ -25,9 +25,18 @@
   <description>ServiceMix Web Console</description>
   <display-name>ServiceMix Console</display-name>
 
-  
   <welcome-file-list>
     <welcome-file>index.html</welcome-file>
-  </welcome-file-list>
+  </welcome-file-list>
   
+  <servlet>
+    <servlet-name>shell</servlet-name>
+    <servlet-class>org.apache.servicemix.gshellweb.server.ShellServiceImpl</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>shell</servlet-name>
+    <url-pattern>/org.apache.servicemix.gshellweb.WebConsole/shell</url-pattern>
+  </servlet-mapping>
+
 </web-app>

Modified: servicemix/sandbox/gshell-web/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/gshell-web/pom.xml?rev=689482&r1=689481&r2=689482&view=diff
==============================================================================
--- servicemix/sandbox/gshell-web/pom.xml (original)
+++ servicemix/sandbox/gshell-web/pom.xml Wed Aug 27 07:01:06 2008
@@ -94,6 +94,7 @@
   </repositories>
   
  <pluginRepositories>
+     <!--
     <pluginRepository>  
       <id>gwtforge</id>  
       <url>http://gwtforge.com/maven-repository/trunk/</url>  
@@ -102,6 +103,7 @@
       <id>gwt-maven</id>
       <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
     </pluginRepository>
+-->
   </pluginRepositories>
 
   <modules>