You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2012/05/04 15:01:04 UTC
svn commit: r1333924 [2/2] - in /karaf/trunk:
assemblies/features/framework/src/main/filtered-resources/resources/bin/
client/src/main/java/org/apache/karaf/client/
config/command/src/main/java/org/apache/karaf/config/command/completers/
dev/command/sr...
Added: karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/StreamWrapUtil.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/StreamWrapUtil.java?rev=1333924&view=auto
==============================================================================
--- karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/StreamWrapUtil.java (added)
+++ karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/StreamWrapUtil.java Fri May 4 13:01:01 2012
@@ -0,0 +1,88 @@
+/*
+ * 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.karaf.shell.console.impl.jline;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+
+import jline.Terminal;
+
+import org.fusesource.jansi.AnsiConsole;
+
+final class StreamWrapUtil {
+ private StreamWrapUtil() {
+ }
+
+ private static Object invokePrivateMethod(Object o, String methodName, Object[] params) throws Exception {
+ final Method methods[] = o.getClass().getDeclaredMethods();
+ for (int i = 0; i < methods.length; ++i) {
+ if (methodName.equals(methods[i].getName())) {
+ methods[i].setAccessible(true);
+ return methods[i].invoke(o, params);
+ }
+ }
+ return o;
+ }
+
+ /**
+ * unwrap stream so it can be recognized by the terminal and wrapped to get
+ * special keys in windows
+ *
+ * @param stream
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private static <T> T unwrapBIS(T stream) {
+ try {
+ return (T) invokePrivateMethod(stream, "getInIfOpen", null);
+ } catch (Throwable t) {
+ return stream;
+ }
+ }
+
+ private static PrintStream wrap(PrintStream stream) {
+ OutputStream o = AnsiConsole.wrapOutputStream(stream);
+ if (o instanceof PrintStream) {
+ return ((PrintStream) o);
+ } else {
+ return new PrintStream(o);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> T unwrap(T stream) {
+ try {
+ Method mth = stream.getClass().getMethod("getRoot");
+ return (T) mth.invoke(stream);
+ } catch (Throwable t) {
+ return stream;
+ }
+ }
+
+ static InputStream reWrapIn(Terminal terminal, InputStream stream) throws IOException {
+ return terminal.wrapInIfNeeded(unwrapBIS(stream));
+ }
+
+ static PrintStream reWrap(PrintStream stream) {
+ return wrap(unwrap(stream));
+ }
+}
Modified: karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/TerminalFactory.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/TerminalFactory.java?rev=1333924&r1=1333363&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/TerminalFactory.java (original)
+++ karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/impl/jline/TerminalFactory.java Fri May 4 13:01:01 2012
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.karaf.shell.console.jline;
+package org.apache.karaf.shell.console.impl.jline;
import jline.NoInterruptUnixTerminal;
import jline.Terminal;
Added: karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/util/ShellUtil.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/util/ShellUtil.java?rev=1333924&view=auto
==============================================================================
--- karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/util/ShellUtil.java (added)
+++ karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/util/ShellUtil.java Fri May 4 13:01:01 2012
@@ -0,0 +1,184 @@
+/*
+ * 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.karaf.shell.util;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.felix.service.command.CommandSession;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.startlevel.BundleStartLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ShellUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ShellUtil.class);
+
+ public static String getBundleName(Bundle bundle)
+ {
+ if (bundle != null)
+ {
+ String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
+ return (name == null)
+ ? "Bundle " + Long.toString(bundle.getBundleId())
+ : name + " (" + Long.toString(bundle.getBundleId()) + ")";
+ }
+ return "[STALE BUNDLE]";
+ }
+
+ public static String getUnderlineString(String s)
+ {
+ StringBuilder sb = new StringBuilder(s.length());
+ for (int i = 0; i < s.length(); i++)
+ {
+ sb.append('-');
+ }
+ return sb.toString();
+ }
+
+ public static String getValueString(Object obj)
+ {
+ if (obj == null) {
+ return "null";
+ }
+ else if (obj.getClass().isArray())
+ {
+ Object[] array = (Object[]) obj;
+ StringBuilder sb = new StringBuilder();
+ sb.append("[");
+ for (int i = 0; i < array.length; i++)
+ {
+ if (i != 0)
+ {
+ sb.append(", ");
+ }
+ sb.append(getValueString(array[i]));
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+ else if (obj instanceof String)
+ {
+ return (String) obj;
+ }
+ else if (obj instanceof Boolean)
+ {
+ return ((Boolean) obj).toString();
+ }
+ else if (obj instanceof Long)
+ {
+ return ((Long) obj).toString();
+ }
+ else if (obj instanceof Integer)
+ {
+ return ((Integer) obj).toString();
+ }
+ else if (obj instanceof Short)
+ {
+ return ((Short) obj).toString();
+ }
+ else if (obj instanceof Double)
+ {
+ return ((Double) obj).toString();
+ }
+ else if (obj instanceof Float)
+ {
+ return ((Float) obj).toString();
+ }
+ else if (obj instanceof URL)
+ {
+ return ((URL)obj).toExternalForm();
+ }
+ else if (obj instanceof URI)
+ {
+ try {
+ return ((URI)obj).toURL().toExternalForm();
+ } catch (MalformedURLException e) {
+ LOGGER.error("URI could not be transformed to URL",e);
+ return obj.toString();
+ }
+ }
+ else
+ {
+ return obj.toString();
+ }
+ }
+
+ /**
+ * Check if a bundle is a system bundle (start level < 50)
+ *
+ * @param bundleContext
+ * @param bundle
+ * @return true if the bundle has start level minor than 50
+ */
+ public static boolean isASystemBundle(BundleContext bundleContext, Bundle bundle) {
+ int level = bundle.adapt(BundleStartLevel.class).getStartLevel();
+ int sbsl = 49;
+ final String sbslProp = bundleContext.getProperty( "karaf.systemBundlesStartLevel" );
+ if (sbslProp != null) {
+ try {
+ sbsl = Integer.valueOf( sbslProp );
+ }
+ catch( Exception ignore ) {
+ // ignore
+ }
+ }
+ return level <= sbsl;
+ }
+
+ /**
+ * Ask the user to confirm the access to a system bundle
+ *
+ * @param bundleId
+ * @param session
+ * @return true if the user confirm
+ * @throws IOException
+ */
+ public static boolean accessToSystemBundleIsAllowed(long bundleId, CommandSession session) throws IOException {
+ for (;;) {
+ StringBuffer sb = new StringBuffer();
+ System.err.print("You are about to access system bundle " + bundleId + ". Do you wish to continue (yes/no): ");
+ System.err.flush();
+ for (;;) {
+ int c = session.getKeyboard().read();
+ if (c < 0) {
+ return false;
+ }
+ System.err.print((char) c);
+ if (c == '\r' || c == '\n') {
+ break;
+ }
+ sb.append((char) c);
+ }
+ String str = sb.toString();
+ if ("yes".equals(str)) {
+ return true;
+ }
+ if ("no".equals(str)) {
+ return false;
+ }
+ }
+ }
+
+}
Modified: karaf/trunk/shell/console/src/main/resources/META-INF/services/org/apache/karaf/shell/commands
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/console/src/main/resources/META-INF/services/org/apache/karaf/shell/commands?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/shell/console/src/main/resources/META-INF/services/org/apache/karaf/shell/commands (original)
+++ karaf/trunk/shell/console/src/main/resources/META-INF/services/org/apache/karaf/shell/commands Fri May 4 13:01:01 2012
@@ -14,4 +14,4 @@
## See the License for the specific language governing permissions and
## limitations under the License.
##---------------------------------------------------------------------------
-org.apache.karaf.shell.console.help.HelpAction
+org.apache.karaf.shell.console.impl.help.HelpAction
Modified: karaf/trunk/shell/console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/shell/console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml (original)
+++ karaf/trunk/shell/console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml Fri May 4 13:01:01 2012
@@ -27,25 +27,31 @@
</ext:property-placeholder>
<reference id="commandProcessor" interface="org.apache.felix.service.command.CommandProcessor">
- <reference-listener ref="consoleFactory"
+<!-- <reference-listener ref="consoleFactory"
bind-method="registerCommandProcessor"
unbind-method="unregisterCommandProcessor"/>
+ -->
</reference>
- <bean id="consoleFactory" class="org.apache.karaf.shell.console.jline.ConsoleFactory">
- <property name="start" value="$[karaf.startLocalConsole]"/>
- <property name="bundleContext" ref="blueprintBundleContext"/>
- <property name="terminalFactory" ref="terminalFactory"/>
+ <bean id="consoleFactoryService" class="org.apache.karaf.shell.console.impl.jline.ConsoleFactoryService">
+ </bean>
+ <service interface="org.apache.karaf.shell.console.ConsoleFactory" ref="consoleFactoryService" />
+
+ <bean id="consoleFactory" class="org.apache.karaf.shell.console.impl.jline.LocalConsoleManager" destroy-method="stop">
+ <argument value="$[karaf.startLocalConsole]"/>
+ <argument ref="blueprintBundleContext"/>
+ <argument ref="terminalFactory"/>
+ <argument ref="consoleFactoryService"/>
+ <argument ref="commandProcessor"/>
</bean>
- <bean id="converters" class="org.apache.karaf.shell.console.Converters">
+ <bean id="converters" class="org.apache.karaf.shell.console.impl.Converters">
<argument ref="blueprintBundleContext"/>
</bean>
<service ref="converters" interface="org.apache.felix.service.command.Converter"/>
- <bean id="terminalFactory" class="org.apache.karaf.shell.console.jline.TerminalFactory"
+ <bean id="terminalFactory" class="org.apache.karaf.shell.console.impl.jline.TerminalFactory"
destroy-method="destroy"/>
-
<service>
<interfaces>
<value>org.apache.felix.service.command.Function</value>
@@ -66,30 +72,31 @@
</property>
</bean>
</service>
- <bean id="help" class="org.apache.karaf.shell.console.help.HelpAction" activation="lazy" scope="prototype">
+
+ <bean id="help" class="org.apache.karaf.shell.console.impl.help.HelpAction" activation="lazy" scope="prototype">
<property name="provider" ref="helpSystem"/>
</bean>
- <bean id="helpSystem" class="org.apache.karaf.shell.console.help.HelpSystem" init-method="start" destroy-method="stop">
+ <bean id="helpSystem" class="org.apache.karaf.shell.console.impl.help.HelpSystem" destroy-method="stop">
<property name="context" ref="blueprintBundleContext"/>
</bean>
<service auto-export="interfaces" ranking="-20">
- <bean class="org.apache.karaf.shell.console.help.CommandListHelpProvider" />
+ <bean class="org.apache.karaf.shell.console.impl.help.CommandListHelpProvider" />
</service>
<service auto-export="interfaces" ranking="-10">
- <bean class="org.apache.karaf.shell.console.help.SingleCommandHelpProvider">
+ <bean class="org.apache.karaf.shell.console.impl.help.SingleCommandHelpProvider">
<property name="io">
<reference interface="org.apache.felix.service.threadio.ThreadIO"/>
</property>
</bean>
</service>
<service auto-export="interfaces" ref="subShellHelpProvider" ranking="-10"/>
- <bean id="subShellHelpProvider" class="org.apache.karaf.shell.console.help.SubShellHelpProvider" init-method="start" destroy-method="stop">
+ <bean id="subShellHelpProvider" class="org.apache.karaf.shell.console.impl.help.SubShellHelpProvider" init-method="start" destroy-method="stop">
<property name="context" ref="blueprintBundleContext"/>
</bean>
<service auto-export="interfaces" ranking="-5">
- <bean class="org.apache.karaf.shell.console.help.SimpleHelpProvider">
+ <bean class="org.apache.karaf.shell.console.impl.help.SimpleHelpProvider">
<property name="help">
<map>
<entry key="%root%"><value><![CDATA[${command-list|}]]></value></entry>
@@ -99,5 +106,4 @@
</bean>
</service>
-
</blueprint>
Modified: karaf/trunk/shell/console/src/test/java/org/apache/karaf/shell/console/ExampleSubclassMain.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/console/src/test/java/org/apache/karaf/shell/console/ExampleSubclassMain.java?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/shell/console/src/test/java/org/apache/karaf/shell/console/ExampleSubclassMain.java (original)
+++ karaf/trunk/shell/console/src/test/java/org/apache/karaf/shell/console/ExampleSubclassMain.java Fri May 4 13:01:01 2012
@@ -18,7 +18,8 @@ package org.apache.karaf.shell.console;
import jline.Terminal;
import org.apache.felix.gogo.runtime.CommandProcessorImpl;
-import org.apache.karaf.shell.console.jline.Console;
+import org.apache.karaf.shell.console.impl.Main;
+import org.apache.karaf.shell.console.impl.jline.ConsoleImpl;
import java.io.InputStream;
import java.io.PrintStream;
@@ -42,8 +43,8 @@ public class ExampleSubclassMain extends
}
@Override
- protected Console createConsole(CommandProcessorImpl commandProcessor, InputStream in, PrintStream out, PrintStream err, Terminal terminal) throws Exception {
- return new Console(commandProcessor, in, out, err, terminal, null) {
+ protected ConsoleImpl createConsole(CommandProcessorImpl commandProcessor, InputStream in, PrintStream out, PrintStream err, Terminal terminal) throws Exception {
+ return new ConsoleImpl(commandProcessor, in, out, err, terminal, null) {
/**
* If you don't overwrite, then karaf will use the welcome message found in the
Modified: karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java (original)
+++ karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java Fri May 4 13:01:01 2012
@@ -25,16 +25,16 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
-import java.security.PrivilegedAction;
-import java.util.List;
import java.util.Map;
+
import javax.security.auth.Subject;
import jline.Terminal;
+
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
-import org.apache.felix.service.command.Function;
-import org.apache.karaf.shell.console.jline.Console;
+import org.apache.karaf.shell.console.Console;
+import org.apache.karaf.shell.console.ConsoleFactory;
import org.apache.sshd.common.Factory;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
@@ -44,24 +44,25 @@ import org.apache.sshd.server.session.Se
import org.osgi.service.blueprint.container.ReifiedType;
/**
- * SSHD {@link org.apache.sshd.server.Command} factory which provides access to Shell.
- *
+ * SSHD {@link org.apache.sshd.server.Command} factory which provides access to
+ * Shell.
+ *
* @version $Rev: 731517 $ $Date: 2009-01-05 11:25:19 +0100 (Mon, 05 Jan 2009) $
*/
-public class ShellFactoryImpl implements Factory<Command>
-{
+public class ShellFactoryImpl implements Factory<Command> {
private CommandProcessor commandProcessor;
+ private ConsoleFactory consoleFactory;
- public void setCommandProcessor(CommandProcessor commandProcessor) {
+ public ShellFactoryImpl(CommandProcessor commandProcessor, ConsoleFactory consoleFactory) {
this.commandProcessor = commandProcessor;
+ this.consoleFactory = consoleFactory;
}
public Command create() {
return new ShellImpl();
}
- public class ShellImpl implements Command, SessionAware
- {
+ public class ShellImpl implements Command, SessionAware {
private InputStream in;
private OutputStream out;
@@ -96,57 +97,29 @@ public class ShellFactoryImpl implements
public void start(final Environment env) throws IOException {
try {
+ final Subject subject = ShellImpl.this.session != null ? ShellImpl.this.session
+ .getAttribute(KarafJaasPasswordAuthenticator.SUBJECT_ATTRIBUTE_KEY) : null;
final Terminal terminal = new SshTerminal(env);
- Console console = new Console(commandProcessor,
- in,
- new PrintStream(new LfToCrLfFilterOutputStream(out), true),
- new PrintStream(new LfToCrLfFilterOutputStream(err), true),
- terminal,
- new Runnable() {
- public void run() {
- destroy();
- }
- });
+ Runnable destroyCallback = new Runnable() {
+ public void run() {
+ destroy();
+ }
+ };
+ Console console = consoleFactory.createAndStart(subject, commandProcessor, in,
+ lfToCrLfPrintStream(out), lfToCrLfPrintStream(err), terminal, destroyCallback);
final CommandSession session = console.getSession();
- session.put("APPLICATION", System.getProperty("karaf.name", "root"));
- for (Map.Entry<String,String> e : env.getEnv().entrySet()) {
+ for (Map.Entry<String, String> e : env.getEnv().entrySet()) {
session.put(e.getKey(), e.getValue());
}
- session.put("#LINES", new Function() {
- public Object execute(CommandSession session, List<Object> arguments) throws Exception {
- return Integer.toString(terminal.getHeight());
- }
- });
- session.put("#COLUMNS", new Function() {
- public Object execute(CommandSession session, List<Object> arguments) throws Exception {
- return Integer.toString(terminal.getWidth());
- }
- });
- session.put(".jline.terminal", terminal);
- new Thread(console) {
- @Override
- public void run() {
- Subject subject = ShellImpl.this.session != null ? ShellImpl.this.session.getAttribute(KarafJaasPasswordAuthenticator.SUBJECT_ATTRIBUTE_KEY) : null;
- if (subject != null) {
- Subject.doAs(subject, new PrivilegedAction<Object>() {
- public Object run() {
- doRun();
- return null;
- }
- });
- } else {
- doRun();
- }
- }
- protected void doRun() {
- super.run();
- }
- }.start();
} catch (Exception e) {
throw (IOException) new IOException("Unable to start shell").initCause(e);
}
}
+ private PrintStream lfToCrLfPrintStream(OutputStream stream) {
+ return new PrintStream(new LfToCrLfFilterOutputStream(stream), true);
+ }
+
public void destroy() {
if (!closed) {
closed = true;
@@ -217,5 +190,4 @@ public class ShellFactoryImpl implements
}
-
}
Modified: karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java (original)
+++ karaf/trunk/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java Fri May 4 13:01:01 2012
@@ -27,7 +27,7 @@ import org.apache.karaf.shell.commands.C
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.BlueprintContainerAware;
import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.console.jline.Console;
+import org.apache.karaf.shell.console.SessionProperties;
import org.apache.sshd.ClientChannel;
import org.apache.sshd.ClientSession;
import org.apache.sshd.SshClient;
@@ -104,8 +104,8 @@ public class SshAction
future.await();
sshSession = future.getSession();
- Object oldIgnoreInterrupts = this.session.get(Console.IGNORE_INTERRUPTS);
- this.session.put( Console.IGNORE_INTERRUPTS, Boolean.TRUE );
+ Object oldIgnoreInterrupts = this.session.get(SessionProperties.IGNORE_INTERRUPTS);
+ this.session.put( SessionProperties.IGNORE_INTERRUPTS, Boolean.TRUE );
try {
System.out.println("Connected");
@@ -141,7 +141,7 @@ public class SshAction
channel.open();
channel.waitFor(ClientChannel.CLOSED, 0);
} finally {
- session.put( Console.IGNORE_INTERRUPTS, oldIgnoreInterrupts );
+ session.put( SessionProperties.IGNORE_INTERRUPTS, oldIgnoreInterrupts );
sshSession.close(false);
}
} finally {
Modified: karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml (original)
+++ karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml Fri May 4 13:01:01 2012
@@ -24,9 +24,13 @@
default-activation="lazy">
<type-converters>
- <bean class="org.apache.karaf.shell.ssh.ShellFactoryImpl" factory-method="getConverter" />
+ <bean class="org.apache.karaf.shell.ssh.ShellFactoryImpl" factory-method="getConverter" >
+
+ </bean>
<bean class="org.apache.karaf.shell.ssh.UserAuthFactoriesFactory" factory-method="getConverter" />
</type-converters>
+
+ <reference id="consoleFactory" interface="org.apache.karaf.shell.console.ConsoleFactory" />
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]">
<ext:default-properties>
@@ -76,7 +80,8 @@
<property name="host" value="${sshHost}"/>
<property name="shellFactory">
<bean class="org.apache.karaf.shell.ssh.ShellFactoryImpl">
- <property name="commandProcessor" ref="commandProcessor"/>
+ <argument ref="commandProcessor"/>
+ <argument ref="consoleFactory"/>
</bean>
</property>
<property name="commandFactory">
Modified: karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/commands/GenerateHelpMojo.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/commands/GenerateHelpMojo.java?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/commands/GenerateHelpMojo.java (original)
+++ karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/commands/GenerateHelpMojo.java Fri May 4 13:01:01 2012
@@ -40,8 +40,10 @@ import java.util.TreeSet;
import org.apache.karaf.shell.commands.Action;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.HelpOption;
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.commands.basic.ActionPreparator;
+import org.apache.karaf.shell.console.SessionProperties;
import org.apache.karaf.shell.console.commands.BlueprintCommand;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -248,7 +250,7 @@ public class GenerateHelpMojo extends Ab
}
});
Set<Option> options = new HashSet<Option>(optionsMap.keySet());
- if (includeHelpOption) options.add(HELP);
+ if (includeHelpOption) options.add(HelpOption.HELP);
out.println("<section>");
out.print(" <title>");
@@ -379,7 +381,7 @@ public class GenerateHelpMojo extends Ab
}
});
Set<Option> options = new HashSet<Option>(optionsMap.keySet());
- if (includeHelpOption) options.add(HELP);
+ if (includeHelpOption) options.add(HelpOption.HELP);
out.println("h1. " + command.scope() + ":" + command.name());
out.println();
Modified: karaf/trunk/webconsole/gogo/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/webconsole/gogo/pom.xml?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/webconsole/gogo/pom.xml (original)
+++ karaf/trunk/webconsole/gogo/pom.xml Fri May 4 13:01:01 2012
@@ -64,6 +64,14 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.karaf.jaas</groupId>
+ <artifactId>org.apache.karaf.jaas.boot</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.jaas</groupId>
+ <artifactId>org.apache.karaf.jaas.modules</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
Modified: karaf/trunk/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java
URL: http://svn.apache.org/viewvc/karaf/trunk/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java (original)
+++ karaf/trunk/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java Fri May 4 13:01:01 2012
@@ -34,13 +34,16 @@ import java.io.PrintWriter;
import java.net.URL;
import java.util.zip.GZIPOutputStream;
+import javax.security.auth.Subject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.console.jline.Console;
+import org.apache.karaf.jaas.boot.principal.UserPrincipal;
+import org.apache.karaf.shell.console.Console;
+import org.apache.karaf.shell.console.ConsoleFactory;
import org.apache.felix.webconsole.AbstractWebConsolePlugin;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
@@ -69,6 +72,8 @@ public class GogoPlugin extends Abstract
private CommandProcessor commandProcessor;
+ private ConsoleFactory consoleFactory;
+
@Override
@@ -86,10 +91,15 @@ public class GogoPlugin extends Abstract
this.commandProcessor = commandProcessor;
}
+ public void setConsoleFactory(ConsoleFactory consoleFactory) {
+ this.consoleFactory = consoleFactory;
+ }
+
/*
* Blueprint lifecycle callback methods
*/
+
public void start()
{
super.activate( bundleContext );
@@ -192,7 +202,6 @@ public class GogoPlugin extends Abstract
public class SessionTerminal implements Runnable {
private Terminal terminal;
- private Console console;
private PipedOutputStream in;
private PipedInputStream out;
private boolean closed;
@@ -205,18 +214,15 @@ public class GogoPlugin extends Abstract
in = new PipedOutputStream();
out = new PipedInputStream();
PrintStream pipedOut = new PrintStream(new PipedOutputStream(out), true);
-
- console = new Console(commandProcessor,
+
+ final Subject subject = new Subject();
+ subject.getPrincipals().add(new UserPrincipal("karaf"));
+ consoleFactory.createAndStart(subject, commandProcessor,
new PipedInputStream(in),
pipedOut,
pipedOut,
new WebTerminal(TERM_WIDTH, TERM_HEIGHT),
null);
- CommandSession session = console.getSession();
- session.put("APPLICATION", System.getProperty("karaf.name", "root"));
- session.put("USER", "karaf");
- session.put("COLUMNS", Integer.toString(TERM_WIDTH));
- session.put("LINES", Integer.toString(TERM_HEIGHT));
} catch (IOException e) {
e.printStackTrace();
throw e;
@@ -224,7 +230,6 @@ public class GogoPlugin extends Abstract
e.printStackTrace();
throw (IOException) new IOException().initCause(e);
}
- new Thread(console).start();
new Thread(this).start();
}
Modified: karaf/trunk/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml?rev=1333924&r1=1333923&r2=1333924&view=diff
==============================================================================
--- karaf/trunk/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml (original)
+++ karaf/trunk/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml Fri May 4 13:01:01 2012
@@ -21,9 +21,12 @@
<reference id="commandProcessor" interface="org.apache.felix.service.command.CommandProcessor" />
+ <reference id="consoleFactory" interface="org.apache.karaf.shell.console.ConsoleFactory"/>
+
<bean id="gogoPlugin" class="org.apache.karaf.webconsole.gogo.GogoPlugin" init-method="start" destroy-method="stop">
<property name="commandProcessor" ref="commandProcessor" />
<property name="bundleContext" ref="blueprintBundleContext" />
+ <property name="consoleFactory" ref="consoleFactory"/>
</bean>
<service ref="gogoPlugin" interface="javax.servlet.Servlet" >