Skip to content

Commit

Permalink
[KARAF-6224] Be sure configuration is loaded in early stage of activa…
Browse files Browse the repository at this point in the history
…tor start
  • Loading branch information
jbonofre committed Sep 22, 2019
1 parent 66827d1 commit a997575
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
Expand Up @@ -65,6 +65,10 @@ protected void doStart() throws Exception {
return;
}

if (!ensureStartupConfiguration("org.apache.karaf.http")) {
return;
}

final ServletEventHandler servletEventHandler = new ServletEventHandler();
register(ServletListener.class, servletEventHandler);

Expand Down
Expand Up @@ -42,6 +42,10 @@ protected void doStart() throws Exception {
return;
}

if (!ensureStartupConfiguration("org.apache.karaf.kar")) {
return;
}

boolean noAutoRefreshBundles = getBoolean("noAutoRefreshBundles", false);
boolean noAutoStartBundles = getBoolean("noAutoStartBundles", false);
String karStorage = getString("karStorage", System.getProperty("karaf.data") + File.separator + "kar");
Expand Down
Expand Up @@ -46,6 +46,10 @@ protected void doStart() throws Exception {
return;
}

if (!ensureStartupConfiguration("org.apache.karaf.log")) {
return;
}

int size = getInt("size", 500);
String pattern = getString("pattern", "%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n");
String errorColor = getString("errorColor", "31");
Expand Down
Expand Up @@ -70,6 +70,10 @@ protected void doStart() throws Exception {
return;
}

if (!ensureStartupConfiguration("org.apache.karaf.management")) {
return;
}

EventAdminLogger logger = null;
if (getBoolean("audit.eventadmin.enabled", true)) {
try {
Expand Down
Expand Up @@ -36,6 +36,10 @@ public class Activator extends BaseActivator implements ManagedService {

@Override
protected void doStart() throws Exception {
if (!ensureStartupConfiguration("org.apache.karaf.profile")) {
return;
}

Path root = Paths.get(getString("profilesDirectory", System.getProperty("karaf.home") + "/profiles"));
ProfileServiceImpl service = new ProfileServiceImpl(root);
register(ProfileService.class, service);
Expand Down
Expand Up @@ -93,6 +93,10 @@ protected void doStart() throws Exception {
return;
}

if (!ensureStartupConfiguration("org.apache.karaf.shell")) {
return;
}

RegexCommandLoggingFilter filter = new RegexCommandLoggingFilter();
filter.setPattern("ssh (.*?)-P +([^ ]+)");
filter.setGroup(2);
Expand Down
Expand Up @@ -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;
Expand All @@ -38,6 +39,8 @@
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;

Expand Down Expand Up @@ -144,6 +147,23 @@ protected void doStop() {
}
}

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()}.
*
Expand Down

0 comments on commit a997575

Please sign in to comment.