karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf] branch karaf-4.2.x updated: [KARAF-6224] Be sure configuration is loaded in early stage of activator start
Date Sun, 22 Sep 2019 16:13:56 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new e6023a5  [KARAF-6224] Be sure configuration is loaded in early stage of activator
start
e6023a5 is described below

commit e6023a5bb313f1304d02b93a13d214f878cff704
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
AuthorDate: Sat Sep 21 18:51:31 2019 +0200

    [KARAF-6224] Be sure configuration is loaded in early stage of activator start
    
    (cherry picked from commit e90873ca9149f5ba42a25fb4791bb55e381aa054)
---
 .../apache/karaf/management/internal/Activator.java  |  4 ++++
 .../java/org/apache/karaf/shell/ssh/Activator.java   |  4 ++++
 .../org/apache/karaf/util/tracker/BaseActivator.java | 20 ++++++++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
b/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
index 187d8a6..d6ea93d 100644
--- a/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
+++ b/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
@@ -70,6 +70,10 @@ public class Activator extends BaseActivator implements ManagedService
{
             return;
         }
 
+        if (!ensureStartupConfiguration("org.apache.karaf.management")) {
+            return;
+        }
+
         EventAdminLogger logger = null;
         if (getBoolean("audit.eventadmin.enabled", true)) {
             try {
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
index 6c633e4..a35fe35 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
@@ -93,6 +93,10 @@ public class Activator extends BaseActivator implements ManagedService
{
             return;
         }
 
+        if (!ensureStartupConfiguration("org.apache.karaf.shell")) {
+            return;
+        }
+
         RegexCommandLoggingFilter filter = new RegexCommandLoggingFilter();
         filter.setPattern("ssh (.*?)-P +([^ ]+)");
         filter.setGroup(2);
diff --git a/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java b/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java
index eb8644f..de39cb0 100644
--- a/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java
+++ b/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java
@@ -16,6 +16,7 @@
  */
 package org.apache.karaf.util.tracker;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
@@ -38,6 +39,8 @@ import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
 import org.osgi.framework.*;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -144,6 +147,23 @@ public class BaseActivator implements BundleActivator, Runnable, ThreadFactory
{
         }
     }
 
+    protected boolean ensureStartupConfiguration(String configId) throws IOException {
+        if (this.configuration != null) {
+            return true;
+        }
+        ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
+        if (configurationAdmin != null) {
+            Configuration configuration = configurationAdmin.getConfiguration(configId);
+            Dictionary<String, Object> properties = (configuration == null) ? null
: configuration.getProperties();
+
+            if (properties != null) {
+                this.configuration = properties;
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * Called in {@link #doOpen()}.
      *


Mime
View raw message