Repository: karaf Updated Branches: refs/heads/master 6d46540ff -> 5bdea7410
[KARAF-4493] Add support of etc/branding-ssh.properties file to brand the ssh terminal Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/df9f43e7 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/df9f43e7 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/df9f43e7 Branch: refs/heads/master Commit: df9f43e7645a019ef2968e1ac2ffec22bde27d8e Parents: 6d46540 Author: mhautman <[email protected]> Authored: Fri Jul 8 21:06:28 2016 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Mon Jul 18 07:27:55 2016 +0200 ---------------------------------------------------------------------- .../karaf/shell/impl/console/Branding.java | 45 ++++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/df9f43e7/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java ---------------------------------------------------------------------- diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java index ba3d98f..f454e93 100644 --- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java +++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java @@ -18,23 +18,17 @@ */ package org.apache.karaf.shell.impl.console; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - +import org.apache.karaf.shell.api.console.Terminal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.karaf.shell.api.console.Terminal; +import java.io.*; +import java.util.Properties; public final class Branding { - static final Logger LOGGER = LoggerFactory.getLogger(Branding.class); - + private Branding() { } public static Properties loadBrandingProperties() { @@ -47,15 +41,16 @@ public final class Branding { public static Properties loadBrandingProperties(Terminal terminal) { Properties props = new Properties(); if (terminal != null && terminal.getClass().getName().endsWith("SshTerminal")) { - //it's a ssh client, so load branding seperately loadProps(props, "org/apache/karaf/shell/console/branding-ssh.properties"); + return loadEtcBrandingFile("branding-ssh.properties",props); } else { loadProps(props, "org/apache/karaf/shell/console/branding.properties"); + return loadEtcBrandingFile("branding.properties",props); } + } - loadProps(props, "org/apache/karaf/branding/branding.properties"); - // load branding from etc/branding.properties - File etcBranding = new File(System.getProperty("karaf.etc"), "branding.properties"); + private static Properties loadEtcBrandingFile(String fileName, Properties props){ + File etcBranding = new File(System.getProperty("karaf.etc"), fileName); if (etcBranding.exists()) { FileInputStream etcBrandingIs = null; try { @@ -65,28 +60,12 @@ public final class Branding { } loadProps(props, etcBrandingIs); } - return props; } - + protected static void loadProps(Properties props, String resource) { - InputStream is = null; - try { - is = Branding.class.getClassLoader().getResourceAsStream(resource); - if (is != null) { - props.load(is); - } - } catch (IOException e) { - // ignore - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - // Ignore - } - } - } + InputStream is = Branding.class.getClassLoader().getResourceAsStream(resource); + loadProps(props, is); } protected static void loadProps(Properties props, InputStream is) {
