FELIX-1626: Configurations loaded from the etc/ directory are only available after a delay
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@824271 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/assembly/src/main/filtered-resources/etc/config.properties b/karaf/assembly/src/main/filtered-resources/etc/config.properties
index 56a1f94..2472ed4 100644
--- a/karaf/assembly/src/main/filtered-resources/etc/config.properties
+++ b/karaf/assembly/src/main/filtered-resources/etc/config.properties
@@ -57,6 +57,7 @@
felix.fileinstall.dir = ${karaf.base}/etc
felix.fileinstall.filter = .*\\.cfg
felix.fileinstall.poll = 1000
+felix.fileinstall.noInitialDelay = true
#
# Hack for FELIX-1628
diff --git a/karaf/assembly/src/main/filtered-resources/etc/startup.properties b/karaf/assembly/src/main/filtered-resources/etc/startup.properties
index aec67b6..b1b679b 100644
--- a/karaf/assembly/src/main/filtered-resources/etc/startup.properties
+++ b/karaf/assembly/src/main/filtered-resources/etc/startup.properties
@@ -23,13 +23,13 @@
#
# Startup core services like logging
#
-org/apache/felix/org.apache.felix.fileinstall/${felix.fileinstall.version}/org.apache.felix.fileinstall-${felix.fileinstall.version}.jar=5
org/ops4j/pax/url/pax-url-mvn/${pax.url.version}/pax-url-mvn-${pax.url.version}.jar=5
org/ops4j/pax/url/pax-url-wrap/${pax.url.version}/pax-url-wrap-${pax.url.version}.jar=5
org/ops4j/pax/logging/pax-logging-api/${pax.logging.version}/pax-logging-api-${pax.logging.version}.jar=8
org/ops4j/pax/logging/pax-logging-service/${pax.logging.version}/pax-logging-service-${pax.logging.version}.jar=8
org/apache/felix/org.apache.felix.configadmin/${felix.configadmin.version}/org.apache.felix.configadmin-${felix.configadmin.version}.jar=10
org/apache/felix/org.apache.felix.prefs/${felix.prefs.version}/org.apache.felix.prefs-${felix.prefs.version}.jar=10
+org/apache/felix/org.apache.felix.fileinstall/${felix.fileinstall.version}/org.apache.felix.fileinstall-${felix.fileinstall.version}.jar=11
#
# The rest of the services..
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
index 7dfe7fb..8f864bb 100644
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
+++ b/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
@@ -470,7 +470,6 @@
Bundle b = context.installBundle(parts[0], new URL(parts[1]).openStream());
if (b != null) {
b.start();
- checkCmProperties(b);
}
}
catch (Exception ex) {
@@ -484,59 +483,6 @@
}
}
- /**
- * TODO: remove this hack when FELIX-1628 is properly implemented
- * Hack for FELIX-1626.
- * FileInstall has some delay before installing the configurations which can cause some problems
- *
- * @param b
- */
- private void checkCmProperties(final Bundle b) {
- final String cmDir = (String) configProps.get(PROPERTY_CM_DIRECTORY);
- if (cmProcessed || cmDir == null) {
- return;
- }
- try {
- // Try to load fileinstall internal classes.
- // Those are not exported, so this mean if the load succeeds, we have the fileinstall bundle
- final Class ciClass = b.loadClass("org.apache.felix.fileinstall.internal.ConfigInstaller");
- final Class fiClass = b.loadClass("org.apache.felix.fileinstall.internal.FileInstall");
- // If we have been able to load the classes, start a thread that will wait until
- // fileinstall is correctly configured using config admin and push all configs.
- new Thread() {
- public void run() {
- for (int i = 0; !cmProcessed && i < 100; i++) {
- try {
- Thread.sleep(50);
- Method mth = fiClass.getDeclaredMethod("getConfigurationAdmin", long.class);
- mth.setAccessible(true);
- if (mth.invoke(null, 0) != null) {
- Constructor cns = ciClass.getDeclaredConstructor(BundleContext.class);
- cns.setAccessible(true);
- Object ci = cns.newInstance(b.getBundleContext());
- mth = ciClass.getDeclaredMethod("setConfig", File.class);
- mth.setAccessible(true);
- cmProcessed = true;
-// System.err.println("Found ready FileInstall");
- for (File f : new File(cmDir).listFiles()) {
- if (f.getName().endsWith(".cfg")) {
-// System.err.println("Processing: " + f.getName());
- mth.invoke(ci, f);
- }
- }
- }
- } catch (Throwable t) {
- if (cmProcessed) {
- t.printStackTrace();
- }
- }
- }
- }
- }.start();
- } catch (Throwable t) {
- }
- }
-
private static String[] convertToMavenUrlsIfNeeded(String location, boolean convertToMavenUrls) {
String[] parts = location.split("\\|");
if (convertToMavenUrls) {