geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r709707 - in /geronimo/gshell/trunk: ./ gshell-api/src/main/java/org/apache/geronimo/gshell/registry/ gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/ gshell-remote/gshell-remote-client/src/main/jav...
Date Sat, 01 Nov 2008 14:59:50 GMT
Author: gnodet
Date: Sat Nov  1 07:59:50 2008
New Revision: 709707

URL: http://svn.apache.org/viewvc?rev=709707&view=rev
Log:
Add a remote completer (until the remote bits are rewritten) and add a more descriptive command
group variable to be displayed if necessary

Added:
    geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteCompleterProxy.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CompleteMessage.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CompleteHandler.java
Modified:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/GroupCommand.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
    geronimo/gshell/trunk/pom.xml

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java?rev=709707&r1=709706&r2=709707&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java
(original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java
Sat Nov  1 07:59:50 2008
@@ -38,6 +38,8 @@
 
     String GROUP = "gshell.group";
 
+    String GROUP_NAME = "gshell.group.name";
+
     String COMMANDS_ROOT = "meta:/commands";
 
     String ALIASES_ROOT = "meta:/aliases";

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java?rev=709707&r1=709706&r2=709707&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
Sat Nov  1 07:59:50 2008
@@ -27,6 +27,7 @@
 import org.apache.geronimo.gshell.remote.message.ExecuteMessage;
 import org.apache.geronimo.gshell.remote.message.LoginMessage;
 import org.apache.geronimo.gshell.remote.message.OpenShellMessage;
+import org.apache.geronimo.gshell.remote.message.CompleteMessage;
 import org.apache.geronimo.gshell.security.crypto.CryptoContext;
 import org.apache.geronimo.gshell.whisper.message.Message;
 import org.apache.geronimo.gshell.whisper.message.MessageHandler;
@@ -181,6 +182,12 @@
         log.trace("Response: {}", resp);
     }
 
+    public int complete(String buffer, int cursor, List<String> candidates) throws
Exception {
+        CompleteMessage.Result result = (CompleteMessage.Result) session.request(new CompleteMessage(buffer,
cursor));
+        candidates.addAll(result.getCandidates());
+        return result.getPosition();
+    }
+
     private Object doExecute(final ExecuteMessage msg) throws Exception {
         assert msg != null;
 

Added: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteCompleterProxy.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteCompleterProxy.java?rev=709707&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteCompleterProxy.java
(added)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteCompleterProxy.java
Sat Nov  1 07:59:50 2008
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.remote.client.proxy;
+
+import java.util.List;
+
+import jline.Completor;
+import org.apache.geronimo.gshell.remote.client.RshClient;
+
+/**
+ * ???
+ *
+ * @version $Rev: 580765 $ $Date: 2007-09-30 20:52:39 +0200 (Sun, 30 Sep 2007) $
+ */
+public class RemoteCompleterProxy implements Completor {
+
+    private final RshClient client;
+
+    public RemoteCompleterProxy(RshClient client) {
+        assert client != null;
+
+        this.client = client;
+    }
+
+    public int complete(String buffer, int cursor, List candidates) {
+        try {
+            return client.complete(buffer, cursor, candidates);
+        } catch (Exception e) {
+            return -1;
+        }
+    }
+}

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java?rev=709707&r1=709706&r2=709707&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
Sat Nov  1 07:59:50 2008
@@ -218,6 +218,8 @@
             }
         });
 
+        console.addCompleter(new RemoteCompleterProxy(client));
+
         //
         // TODO: What are we to do with history here?  Really should be history on the server...
         //

Added: geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CompleteMessage.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CompleteMessage.java?rev=709707&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CompleteMessage.java
(added)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CompleteMessage.java
Sat Nov  1 07:59:50 2008
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.remote.message;
+
+import java.util.List;
+
+/**
+ * Client to server message asking for possible completions
+ *
+ * @version $Rev: 697487 $ $Date: 2008-09-21 14:37:42 +0200 (Sun, 21 Sep 2008) $
+ */
+public class CompleteMessage 
+    extends RshMessage
+{
+
+    private final String buffer;
+
+    private final int cursor;
+
+    public CompleteMessage(String buffer, int cursor) {
+        this.buffer = buffer;
+        this.cursor = cursor;
+    }
+
+    public String getBuffer() {
+        return buffer;
+    }
+
+    public int getCursor() {
+        return cursor;
+    }
+
+    /**
+     * Server to client message to return the candidates.
+     */
+    public static class Result
+        extends RshMessage
+    {
+        private final List<String> candidates;
+        private final int position;
+
+        public Result(final List<String> candidates, int position) {
+            this.candidates = candidates;
+            this.position = position;
+        }
+
+        public List<String> getCandidates() {
+            return candidates;
+        }
+
+        public int getPosition() {
+            return position;
+        }
+    }
+
+
+}

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=709707&r1=709706&r2=709707&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
Sat Nov  1 07:59:50 2008
@@ -19,12 +19,15 @@
 
 package org.apache.geronimo.gshell.remote.server;
 
+import java.util.List;
+
 import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.shell.ShellContext;
 import org.apache.geronimo.gshell.shell.ShellContextHolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import jline.Completor;
 
 /**
  * Provides the server-side encapsulation of the basic shell bits to allow remote clients
to invoke commands.
@@ -38,6 +41,8 @@
 
     private final CommandLineExecutor executor;
 
+    private List<Completor> completers;
+
     private boolean opened = true;
 
     public RemoteShellImpl(final CommandLineExecutor executor) {
@@ -45,6 +50,16 @@
         this.executor = executor;
     }
 
+    public List<Completor> getCompleters() {
+        return completers;
+    }
+
+    public void setCompleters(final List<Completor> completers) {
+        assert completers != null;
+
+        this.completers = completers;
+    }
+
     private void ensureOpened() {
         if (!opened) {
             throw new IllegalStateException("Not opened");

Added: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CompleteHandler.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/CompleteHandler.java?rev=709707&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CompleteHandler.java
(added)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CompleteHandler.java
Sat Nov  1 07:59:50 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.remote.server.handler;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+import org.apache.geronimo.gshell.remote.message.CompleteMessage;
+import org.apache.geronimo.gshell.remote.message.CloseShellMessage;
+import org.apache.geronimo.gshell.remote.server.RemoteShellImpl;
+import org.apache.geronimo.gshell.whisper.transport.Session;
+import org.apache.geronimo.gshell.shell.ShellContext;
+import org.apache.geronimo.gshell.shell.ShellContextHolder;
+import org.apache.geronimo.gshell.shell.Shell;
+import jline.Completor;
+
+public class CompleteHandler
+    extends ServerMessageHandlerSupport<CompleteMessage> {
+
+    public CompleteHandler() {
+        super(CompleteMessage.class);
+    }
+
+    public void handle(Session session, ServerSessionContext context, CompleteMessage message)
throws Exception {
+        assert session != null;
+        assert context != null;
+        assert message != null;
+
+        ShellContext prevContext = ShellContextHolder.get(true);
+        ShellContextHolder.set(context.shellContext);
+
+        List<String> candidates = new ArrayList<String>();
+        int position = -1;
+
+        try {
+            Shell shell = context.shellContext.getShell();
+            if (shell instanceof RemoteShellImpl) {
+                List<Completor> completors = ((RemoteShellImpl) shell).getCompleters();
+                for (Iterator i = completors.iterator(); i.hasNext();) {
+                    Completor comp = (Completor) i.next();
+                    if ((position = comp.complete(message.getBuffer(), message.getCursor(),
candidates)) != -1) {
+                        break;
+                    }
+                }
+            }
+        }
+        finally {
+            ShellContextHolder.set(prevContext);
+        }
+
+        CompleteMessage.Result reply = new CompleteMessage.Result(candidates, position);
+        reply.setCorrelationId(message.getId());
+        session.send(reply);
+    }
+}

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/GroupCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/GroupCommand.java?rev=709707&r1=709706&r2=709707&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/GroupCommand.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/GroupCommand.java
Sat Nov  1 07:59:50 2008
@@ -86,6 +86,15 @@
             log.debug("Changing to group: {}", file);
             
             context.getVariables().parent().set(CommandResolver.GROUP, file);
+            // FIXME: remove this ugly hack
+            String location = file.getName().toString();
+            if (location.startsWith(CommandResolver.COMMANDS_ROOT)) {
+                location = location.substring(CommandResolver.COMMANDS_ROOT.length());
+            }
+            if (location.startsWith("/")) {
+                location = location.substring(1);
+            }
+            context.getVariables().parent().set(CommandResolver.GROUP_NAME, location);
 
             return Result.SUCCESS;
         }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=709707&r1=709706&r2=709707&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
Sat Nov  1 07:59:50 2008
@@ -35,6 +35,7 @@
 import org.apache.geronimo.gshell.notification.ExitNotification;
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.shell.ShellContext;
+import org.apache.geronimo.gshell.registry.CommandResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -133,6 +134,9 @@
         // HACK: Set the default prompt here for now, probably want to get this from branding
         vars.set("gshell.prompt", "@|bold %{application.userName}|@%{application.localHost.hostName}:@|bold
%{branding.name}|> ");
         
+        vars.set(CommandResolver.GROUP, CommandResolver.COMMANDS_ROOT);
+        vars.set(CommandResolver.GROUP_NAME, "");
+
         branding = application.getModel().getBranding();
 
         opened = true;

Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=709707&r1=709706&r2=709707&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Sat Nov  1 07:59:50 2008
@@ -59,6 +59,24 @@
                 <groupId>org.slf4j</groupId>
                 <artifactId>slf4j-log4j12</artifactId>
                 <version>1.5.3</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>javax.jms</groupId>
+                        <artifactId>jms</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>com.sun.jdmk</groupId>
+                        <artifactId>jmxtools</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>com.sun.jmx</groupId>
+                        <artifactId>jmxri</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>javax.mail</groupId>
+                        <artifactId>mail</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
 
             <dependency>



Mime
View raw message