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/10/14 11:44:25 UTC
svn commit: r704418 - in /servicemix/smx4/kernel/trunk/gshell:
gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/
gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/
gshell-core/src/main/java/org/apa...
Author: gnodet
Date: Tue Oct 14 02:44:23 2008
New Revision: 704418
URL: http://svn.apache.org/viewvc?rev=704418&view=rev
Log:
SMX4KNL-114: prompt should print username@instance-name when using remote shell
Added:
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellInfoProxy.java
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshClient.java
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshCommand.java
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellProxy.java
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java?rev=704418&r1=704417&r2=704418&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java Tue Oct 14 02:44:23 2008
@@ -50,7 +50,7 @@
return null;
}
- exec.execute("remote rsh -u " + username + " -p " + password + " tcp://localhost:" + port);
+ exec.execute("remote rsh -u " + username + " -p " + password + " -n " + instance + " tcp://localhost:" + port);
}
finally {
getBundleContext().ungetService(ref);
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshClient.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshClient.java?rev=704418&r1=704417&r2=704418&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshClient.java (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshClient.java Tue Oct 14 02:44:23 2008
@@ -75,6 +75,8 @@
private Session session;
+ private String userName;
+
@Requirement(role=ClientMessageHandler.class)
private List<ClientMessageHandler> handlers;
@@ -112,6 +114,14 @@
return transport;
}
+ public String getUserName() {
+ return userName;
+ }
+
+ public String getInstanceName() {
+ return null;
+ }
+
public void close() {
transport.close();
}
@@ -119,6 +129,7 @@
public void login(final String username, final String password) throws Exception {
doHandshake();
doLogin(username, password);
+ this.userName = username;
}
private void doHandshake() throws Exception {
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshCommand.java?rev=704418&r1=704417&r2=704418&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshCommand.java (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/SpringRshCommand.java Tue Oct 14 02:44:23 2008
@@ -20,10 +20,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.io.FilterInputStream;
-import java.io.InputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
import java.io.IOException;
import jline.Terminal;
@@ -39,7 +35,6 @@
import org.apache.geronimo.gshell.remote.client.proxy.SpringRemoteShellProxy;
import org.apache.geronimo.gshell.remote.crypto.CryptoContext;
import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
-import org.apache.geronimo.gshell.whisper.stream.StreamFeeder;
/**
* Created by IntelliJ IDEA.
@@ -60,6 +55,9 @@
@Option(name="-p", aliases={"--password"}, metaVar="PASSWORD", description="Remote user password")
private String password;
+ @Option(name="-n", aliases={"--name"}, metaVar="NAME", description="Name of the instance to connect to")
+ private String name;
+
@Argument(metaVar="URI", required=true, index=0, description="Connect to remote server at URI")
private URI remote;
@@ -103,6 +101,10 @@
ncis.close();
} catch (IOException e) {}
}
+
+ public String getInstanceName() {
+ return SpringRshCommand.this.name;
+ }
};
client.initialize();
PromptReader prompter = new PromptReader(terminal, io);
Added: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellInfoProxy.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellInfoProxy.java?rev=704418&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellInfoProxy.java (added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellInfoProxy.java Tue Oct 14 02:44:23 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.io.File;
+import java.net.InetAddress;
+
+import org.apache.geronimo.gshell.shell.ShellInfo;
+import org.apache.geronimo.gshell.remote.client.SpringRshClient;
+
+public class SpringRemoteShellInfoProxy implements ShellInfo {
+
+ private SpringRshClient client;
+
+ public SpringRemoteShellInfoProxy(SpringRshClient client) {
+ this.client = client;
+ }
+
+ public File getHomeDir() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public InetAddress getLocalHost() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getUserName() {
+ return client.getUserName();
+ }
+
+ public String getInstanceName() {
+ return client.getInstanceName();
+ }
+}
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellProxy.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellProxy.java?rev=704418&r1=704417&r2=704418&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellProxy.java (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/SpringRemoteShellProxy.java Tue Oct 14 02:44:23 2008
@@ -30,6 +30,7 @@
import org.apache.geronimo.gshell.console.JLineConsole;
import org.apache.geronimo.gshell.remote.RemoteShell;
import org.apache.geronimo.gshell.remote.client.RshClient;
+import org.apache.geronimo.gshell.remote.client.SpringRshClient;
import org.apache.geronimo.gshell.remote.client.proxy.RemoteBrandingProxy;
import org.apache.geronimo.gshell.remote.client.proxy.RemoteShellInfoProxy;
import org.apache.geronimo.gshell.remote.client.proxy.RemoteHistoryProxy;
@@ -51,7 +52,7 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- private RshClient client;
+ private SpringRshClient client;
private IO io;
@@ -63,13 +64,13 @@
private RemoteEnvironmentProxy env;
- private RemoteShellInfoProxy shellInfo;
+ private SpringRemoteShellInfoProxy shellInfo;
private RemoteHistoryProxy history;
private RemoteBrandingProxy branding;
- public SpringRemoteShellProxy(final RshClient client, final IO io, final Terminal terminal) throws Exception {
+ public SpringRemoteShellProxy(final SpringRshClient client, final IO io, final Terminal terminal) throws Exception {
assert client != null;
assert io != null;
assert terminal != null;
@@ -87,7 +88,7 @@
// Setup other proxies
env = new RemoteEnvironmentProxy(client);
- shellInfo = new RemoteShellInfoProxy(client);
+ shellInfo = new SpringRemoteShellInfoProxy(client);
history = new RemoteHistoryProxy(client);
branding = new RemoteBrandingProxy(client);
@@ -214,8 +215,8 @@
// TODO: Get the real details and use them...
//
- String userName = "user"; // shellInfo.getUserName();
- String hostName = "remote"; // shellInfo.getLocalHost().getHostName();
+ String userName = shellInfo.getUserName();
+ String hostName = shellInfo.getInstanceName() != null ? shellInfo.getInstanceName() : "unknown";
String path = "/";
return renderer.render("@|bold " + userName + "|@" + hostName + ":@|bold " + path + "|> ");