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 2017/08/01 08:33:05 UTC

karaf git commit: [KARAF-5280] Only suppress welcome banner on local console

Repository: karaf
Updated Branches:
  refs/heads/master 496c8cd2e -> 6f862dc96


[KARAF-5280] Only suppress welcome banner on local console


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/6f862dc9
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/6f862dc9
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/6f862dc9

Branch: refs/heads/master
Commit: 6f862dc96bb0ec75a5a22e6990199edfedc32e6b
Parents: 496c8cd
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Aug 1 10:32:50 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Aug 1 10:33:00 2017 +0200

----------------------------------------------------------------------
 .../apache/karaf/shell/api/console/Session.java |  1 +
 .../shell/impl/console/ConsoleSessionImpl.java  | 28 +++++++++++++++-----
 .../impl/console/osgi/LocalConsoleManager.java  |  1 +
 3 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/6f862dc9/shell/core/src/main/java/org/apache/karaf/shell/api/console/Session.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/api/console/Session.java b/shell/core/src/main/java/org/apache/karaf/shell/api/console/Session.java
index 9308140..05930e0 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/api/console/Session.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/api/console/Session.java
@@ -51,6 +51,7 @@ public interface Session extends Runnable, Closeable {
     String PRINT_STACK_TRACES = "karaf.printStackTraces";
     String LAST_EXCEPTION = "karaf.lastException";
     String IGNORE_INTERRUPTS = "karaf.ignoreInterrupts";
+    String IS_LOCAL = "karaf.shell.local";
     String COMPLETION_MODE = "karaf.completionMode";
 
     String COMPLETION_MODE_GLOBAL = "global";

http://git-wip-us.apache.org/repos/asf/karaf/blob/6f862dc9/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index c2b127e..05ab109 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -308,12 +308,7 @@ public class ConsoleSessionImpl implements Session {
             threadIO.setStreams(session.getKeyboard(), out, err);
             thread = Thread.currentThread();
             running = true;
-            if (System.getProperty(SUPPRESS_WELCOME) == null) {
-                Properties brandingProps = Branding.loadBrandingProperties(terminal);
-                welcome(brandingProps);
-                setSessionProperties(brandingProps);
-                System.setProperty(SUPPRESS_WELCOME, "true");
-            }
+            welcomeBanner();
 
             AtomicBoolean reading = new AtomicBoolean();
 
@@ -384,6 +379,27 @@ public class ConsoleSessionImpl implements Session {
         }
     }
 
+    /**
+     * On the local console we only show the welcome banner once. This allows to suppress the banner
+     * on refreshs of the shell core bundle. 
+     * On ssh we show it every time.
+     */
+    private void welcomeBanner() {
+        if (!isLocal() || System.getProperty(SUPPRESS_WELCOME) == null) {
+            Properties brandingProps = Branding.loadBrandingProperties(terminal);
+            welcome(brandingProps);
+            setSessionProperties(brandingProps);
+            if (isLocal()) {
+                System.setProperty(SUPPRESS_WELCOME, "true");
+            }
+        }
+    }
+
+    private boolean isLocal() {
+        Boolean isLocal = (Boolean)session.get(Session.IS_LOCAL);
+        return isLocal != null && isLocal;
+    }
+
     private String getStatusLine(Job job, int width, String status) {
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < width - 1; i++) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/6f862dc9/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
index 90426d9..1bd3f20 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
@@ -74,6 +74,7 @@ public class LocalConsoleManager {
                                   new JLineTerminal(terminal),
                                   encoding,
                                   LocalConsoleManager.this::close);
+            session.put(Session.IS_LOCAL, true);
             registration = bundleContext.registerService(Session.class, session, null);
             String name = "Karaf local console user " + ShellUtil.getCurrentUserName();
             boolean delayconsole = Boolean.parseBoolean(System.getProperty(KARAF_DELAY_CONSOLE));