karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf-cellar git commit: [KARAF-4664] Synchronizers init method check if BootFinished service is there
Date Wed, 07 Sep 2016 13:21:32 GMT
Repository: karaf-cellar
Updated Branches:
  refs/heads/master 473b65887 -> 6c125c4fc


[KARAF-4664] Synchronizers init method check if BootFinished service is there


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

Branch: refs/heads/master
Commit: 6c125c4fc185ae81ab53d27a726130149754a530
Parents: 473b658
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Wed Sep 7 14:59:48 2016 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Wed Sep 7 14:59:48 2016 +0200

----------------------------------------------------------------------
 .../karaf/cellar/bundle/BundleSynchronizer.java     | 11 ++++++++++-
 .../cellar/bundle/internal/osgi/Activator.java      |  2 +-
 config/pom.xml                                      |  7 +++++++
 .../cellar/config/ConfigurationSynchronizer.java    | 12 +++++++++++-
 .../cellar/config/internal/osgi/Activator.java      |  2 +-
 .../karaf/cellar/features/FeaturesEventHandler.java |  5 +++--
 .../karaf/cellar/features/FeaturesSupport.java      |  3 ++-
 .../karaf/cellar/features/FeaturesSynchronizer.java | 16 +++++++++++-----
 .../cellar/features/LocalFeaturesListener.java      |  5 +++--
 .../cellar/features/RepositoryEventHandler.java     |  5 +++--
 .../cellar/features/internal/osgi/Activator.java    |  8 ++++----
 http/balancer/pom.xml                               |  7 +++++++
 .../cellar/http/balancer/ServletSynchronizer.java   | 11 ++++++++++-
 .../http/balancer/internal/osgi/Activator.java      |  2 +-
 obr/pom.xml                                         |  7 +++++++
 .../karaf/cellar/obr/ObrBundleEventHandler.java     |  5 +++--
 .../org/apache/karaf/cellar/obr/ObrSupport.java     |  2 +-
 .../apache/karaf/cellar/obr/ObrUrlEventHandler.java |  5 +++--
 .../apache/karaf/cellar/obr/ObrUrlSynchronizer.java | 12 +++++++++++-
 .../karaf/cellar/obr/internal/osgi/Activator.java   |  6 +++---
 20 files changed, 102 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
----------------------------------------------------------------------
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
index a234672..76f2f1b 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
@@ -19,11 +19,13 @@ import org.apache.karaf.cellar.core.Synchronizer;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.features.BootFinished;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleReference;
 import org.osgi.service.cm.Configuration;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,7 +48,14 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer
{
         this.eventProducer = eventProducer;
     }
 
-    public void init() {
+    public void init(BundleContext bundleContext) {
+        // wait the end of Karaf boot process
+        ServiceTracker tracker = new ServiceTracker(bundleContext, BootFinished.class, null);
+        try {
+            tracker.waitForService(120000);
+        } catch (Exception e) {
+            LOGGER.warn("Can't start BootFinished service tracker", e);
+        }
         if (groupManager == null)
             return;
         Set<Group> groups = groupManager.listLocalGroups();

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
index ee023fe..0d1972b 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
@@ -106,7 +106,7 @@ public class Activator extends BaseActivator {
         synchronizer.setClusterManager(clusterManager);
         synchronizer.setBundleContext(bundleContext);
         synchronizer.setEventProducer(eventProducer);
-        synchronizer.init();
+        synchronizer.init(bundleContext);
         props = new Hashtable();
         props.put("resource", "bundle");
         register(Synchronizer.class, synchronizer, props);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/config/pom.xml
----------------------------------------------------------------------
diff --git a/config/pom.xml b/config/pom.xml
index d4528f0..588259c 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -64,6 +64,13 @@
             <scope>provided</scope>
         </dependency>
 
+        <!-- Karaf features -->
+        <dependency>
+            <groupId>org.apache.karaf.features</groupId>
+            <artifactId>org.apache.karaf.features.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
         <!-- Logging Dependencies -->
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
index 6bab460..6676668 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
@@ -19,8 +19,11 @@ import org.apache.karaf.cellar.core.Synchronizer;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.features.BootFinished;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.cm.Configuration;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,7 +47,14 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements
S
         this.eventProducer = eventProducer;
     }
 
-    public void init() {
+    public void init(BundleContext bundleContext) {
+        // wait the end of Karaf boot process
+        ServiceTracker tracker = new ServiceTracker(bundleContext, BootFinished.class, null);
+        try {
+            tracker.waitForService(120000);
+        } catch (Exception e) {
+            LOGGER.warn("Can't start BootFinished service tracker", e);
+        }
         if (groupManager == null)
             return;
         Set<Group> groups = groupManager.listLocalGroups();

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java
b/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java
index bd4d649..e601a92 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java
@@ -107,7 +107,7 @@ public class Activator extends BaseActivator implements ManagedService
{
         configurationSynchronizer.setClusterManager(clusterManager);
         configurationSynchronizer.setEventProducer(eventProducer);
         configurationSynchronizer.setStorage(storage);
-        configurationSynchronizer.init();
+        configurationSynchronizer.init(bundleContext);
         props = new Hashtable();
         props.put("resource", "config");
         register(Synchronizer.class, configurationSynchronizer, props);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
index af56749..1d9c7f9 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
@@ -21,6 +21,7 @@ import org.apache.karaf.cellar.core.event.EventHandler;
 import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.features.FeatureEvent;
 import org.apache.karaf.features.FeaturesService;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,8 +40,8 @@ public class FeaturesEventHandler extends FeaturesSupport implements EventHandle
     private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
 
     @Override
-    public void init() {
-        super.init();
+    public void init(BundleContext bundleContext) {
+        super.init(bundleContext);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
index 1104df2..583124a 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
@@ -20,6 +20,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.apache.karaf.features.Repository;
+import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,7 +36,7 @@ public class FeaturesSupport extends CellarSupport {
 
     protected FeaturesService featuresService;
 
-    public void init() {
+    public void init(BundleContext bundleContext) {
         // nothing to do
     }
 

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
index c25faf8..7524309 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
@@ -19,11 +19,10 @@ import org.apache.karaf.cellar.core.Synchronizer;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
-import org.apache.karaf.features.Feature;
-import org.apache.karaf.features.FeatureEvent;
-import org.apache.karaf.features.Repository;
-import org.apache.karaf.features.RepositoryEvent;
+import org.apache.karaf.features.*;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.Configuration;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,7 +47,14 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
     }
 
     @Override
-    public void init() {
+    public void init(BundleContext bundleContext) {
+        // wait the end of Karaf boot process
+        ServiceTracker tracker = new ServiceTracker(bundleContext, BootFinished.class, null);
+        try {
+            tracker.waitForService(120000);
+        } catch (Exception e) {
+            LOGGER.warn("Can't start BootFinished service tracker", e);
+        }
         if (groupManager == null)
             return;
         Set<Group> groups = groupManager.listLocalGroups();

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
b/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
index ada4c6b..0addd4f 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
@@ -21,6 +21,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeatureEvent;
 import org.apache.karaf.features.RepositoryEvent;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,8 +40,8 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
     private EventProducer eventProducer;
 
     @Override
-    public void init() {
-        super.init();
+    public void init(BundleContext bundleContext) {
+        super.init(bundleContext);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
index 7acf1a2..0f0ea2d 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
@@ -18,6 +18,7 @@ import org.apache.karaf.cellar.core.control.Switch;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventHandler;
 import org.apache.karaf.features.RepositoryEvent;
+import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,8 +36,8 @@ public class RepositoryEventHandler extends FeaturesSupport implements EventHand
     private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
 
     @Override
-    public void init() {
-        super.init();
+    public void init(BundleContext bundleContext) {
+        super.init(bundleContext);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/features/src/main/java/org/apache/karaf/cellar/features/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/internal/osgi/Activator.java
b/features/src/main/java/org/apache/karaf/cellar/features/internal/osgi/Activator.java
index 296d309..dc3968c 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/internal/osgi/Activator.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/internal/osgi/Activator.java
@@ -87,7 +87,7 @@ public class Activator extends BaseActivator {
         repositoryEventHandler.setFeaturesService(featuresService);
         repositoryEventHandler.setClusterManager(clusterManager);
         repositoryEventHandler.setGroupManager(groupManager);
-        repositoryEventHandler.init();
+        repositoryEventHandler.init(bundleContext);
         Hashtable props = new Hashtable();
         props.put("managed", "true");
         register(new Class[]{ EventHandler.class }, repositoryEventHandler, props);
@@ -98,7 +98,7 @@ public class Activator extends BaseActivator {
         featuresEventHandler.setClusterManager(clusterManager);
         featuresEventHandler.setGroupManager(groupManager);
         featuresEventHandler.setConfigurationAdmin(configurationAdmin);
-        featuresEventHandler.init();
+        featuresEventHandler.init(bundleContext);
         register(new Class[]{ EventHandler.class }, featuresEventHandler, props);
 
         LOGGER.debug("CELLAR FEATURE: init local features listener");
@@ -108,7 +108,7 @@ public class Activator extends BaseActivator {
         localFeaturesListener.setEventProducer(eventProducer);
         localFeaturesListener.setConfigurationAdmin(configurationAdmin);
         localFeaturesListener.setFeaturesService(featuresService);
-        localFeaturesListener.init();
+        localFeaturesListener.init(bundleContext);
         register(FeaturesListener.class, localFeaturesListener);
 
         LOGGER.debug("CELLAR FEATURE: init features synchronizer");
@@ -118,7 +118,7 @@ public class Activator extends BaseActivator {
         featuresSynchronizer.setEventProducer(eventProducer);
         featuresSynchronizer.setConfigurationAdmin(configurationAdmin);
         featuresSynchronizer.setFeaturesService(featuresService);
-        featuresSynchronizer.init();
+        featuresSynchronizer.init(bundleContext);
         props = new Hashtable();
         props.put("resource", "feature");
         register(Synchronizer.class, featuresSynchronizer, props);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/http/balancer/pom.xml
----------------------------------------------------------------------
diff --git a/http/balancer/pom.xml b/http/balancer/pom.xml
index 50fe351..5316b9d 100644
--- a/http/balancer/pom.xml
+++ b/http/balancer/pom.xml
@@ -84,6 +84,13 @@
             <artifactId>slf4j-api</artifactId>
             <scope>provided</scope>
         </dependency>
+
+        <!-- Karaf features -->
+        <dependency>
+            <groupId>org.apache.karaf.features</groupId>
+            <artifactId>org.apache.karaf.features.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/ServletSynchronizer.java
----------------------------------------------------------------------
diff --git a/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/ServletSynchronizer.java
b/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/ServletSynchronizer.java
index 20fdf81..e21c26b 100644
--- a/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/ServletSynchronizer.java
+++ b/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/ServletSynchronizer.java
@@ -16,11 +16,13 @@ package org.apache.karaf.cellar.http.balancer;
 import org.apache.karaf.cellar.core.*;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
+import org.apache.karaf.features.BootFinished;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,7 +41,14 @@ public class ServletSynchronizer implements Synchronizer {
     private BundleContext bundleContext;
     private EventProducer eventProducer;
 
-    public void init() {
+    public void init(BundleContext bundleContext) {
+        // wait the end of Karaf boot process
+        ServiceTracker tracker = new ServiceTracker(bundleContext, BootFinished.class, null);
+        try {
+            tracker.waitForService(120000);
+        } catch (Exception e) {
+            LOGGER.warn("Can't start BootFinished service tracker", e);
+        }
         if (groupManager == null)
             return;
         Set<Group> groups = groupManager.listLocalGroups();

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/internal/osgi/Activator.java
b/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/internal/osgi/Activator.java
index 086d74e..58d87b1 100644
--- a/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/internal/osgi/Activator.java
+++ b/http/balancer/src/main/java/org/apache/karaf/cellar/http/balancer/internal/osgi/Activator.java
@@ -100,7 +100,7 @@ public class Activator extends BaseActivator {
         synchronizer.setProxyRegistry(proxyRegistry);
         synchronizer.setGroupManager(groupManager);
         synchronizer.setBundleContext(bundleContext);
-        synchronizer.init();
+        synchronizer.init(bundleContext);
         props = new Hashtable();
         props.put("resource", "balanced.servlet");
         register(Synchronizer.class, synchronizer, props);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/obr/pom.xml
----------------------------------------------------------------------
diff --git a/obr/pom.xml b/obr/pom.xml
index 3dd75ba..e234464 100644
--- a/obr/pom.xml
+++ b/obr/pom.xml
@@ -63,6 +63,13 @@
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.bundlerepository</artifactId>
         </dependency>
+
+        <!-- Karaf features -->
+        <dependency>
+            <groupId>org.apache.karaf.features</groupId>
+            <artifactId>org.apache.karaf.features.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
index 5927284..9e9ad94 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
@@ -23,6 +23,7 @@ import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventHandler;
 import org.apache.karaf.cellar.core.event.EventType;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
 import org.osgi.service.cm.Configuration;
@@ -43,8 +44,8 @@ public class ObrBundleEventHandler extends ObrSupport implements EventHandler<Cl
     private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
 
     @Override
-    public void init() {
-        super.init();
+    public void init(BundleContext bundleContext) {
+        super.init(bundleContext);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
index 83cb781..4fae5d8 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
@@ -25,7 +25,7 @@ public class ObrSupport extends CellarSupport {
     protected BundleContext bundleContext;
     protected RepositoryAdmin obrService;
 
-    public void init() {
+    public void init(BundleContext bundleContext) {
         // nothing to do
     }
 

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
index 19ca432..b4587c1 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
@@ -19,6 +19,7 @@ import org.apache.karaf.cellar.core.control.Switch;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventHandler;
 import org.apache.karaf.cellar.core.event.EventType;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,8 +36,8 @@ public class ObrUrlEventHandler extends ObrSupport implements EventHandler<Clust
     private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
 
     @Override
-    public void init() {
-        super.init();
+    public void init(BundleContext bundleContext) {
+        super.init(bundleContext);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
index 2937618..b6d75d5 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
@@ -20,7 +20,10 @@ import org.apache.karaf.cellar.core.Group;
 import org.apache.karaf.cellar.core.Synchronizer;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.features.BootFinished;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.Configuration;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,7 +46,14 @@ public class ObrUrlSynchronizer extends ObrSupport implements Synchronizer
{
     }
 
     @Override
-    public void init() {
+    public void init(BundleContext bundleContext) {
+        // wait the end of Karaf boot process
+        ServiceTracker tracker = new ServiceTracker(bundleContext, BootFinished.class, null);
+        try {
+            tracker.waitForService(120000);
+        } catch (Exception e) {
+            LOGGER.warn("Can't start BootFinished service tracker", e);
+        }
         if (groupManager == null)
             return;
         Set<Group> groups = groupManager.listLocalGroups();

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/6c125c4f/obr/src/main/java/org/apache/karaf/cellar/obr/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/internal/osgi/Activator.java b/obr/src/main/java/org/apache/karaf/cellar/obr/internal/osgi/Activator.java
index c826f3d..ea9fc9d 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/internal/osgi/Activator.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/internal/osgi/Activator.java
@@ -83,7 +83,7 @@ public class Activator extends BaseActivator {
         urlEventHandler.setGroupManager(groupManager);
         urlEventHandler.setConfigurationAdmin(configurationAdmin);
         urlEventHandler.setObrService(repositoryAdmin);
-        urlEventHandler.init();
+        urlEventHandler.init(bundleContext);
         Hashtable props = new Hashtable();
         props.put("managed", "true");
         register(EventHandler.class, urlEventHandler, props);
@@ -94,7 +94,7 @@ public class Activator extends BaseActivator {
         bundleEventHandler.setClusterManager(clusterManager);
         bundleEventHandler.setGroupManager(groupManager);
         bundleEventHandler.setConfigurationAdmin(configurationAdmin);
-        bundleEventHandler.init();
+        bundleEventHandler.init(bundleContext);
         register(EventHandler.class, bundleEventHandler, props);
 
         LOGGER.debug("CELLAR OBR: init URL synchronizer");
@@ -104,7 +104,7 @@ public class Activator extends BaseActivator {
         urlSynchronizer.setGroupManager(groupManager);
         urlSynchronizer.setEventProducer(eventProducer);
         urlSynchronizer.setConfigurationAdmin(configurationAdmin);
-        urlSynchronizer.init();
+        urlSynchronizer.init(bundleContext);
         props = new Hashtable();
         props.put("resource", "obr.urls");
         register(Synchronizer.class, urlSynchronizer, props);


Mime
View raw message