karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject karaf git commit: Treat EventAdminListener like any other listener
Date Mon, 15 May 2017 14:03:13 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 9b99ac740 -> d3c90b7e0


Treat EventAdminListener like any other listener


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

Branch: refs/heads/master
Commit: d3c90b7e0eadfbd5fd25ebffc60ab82694bc3907
Parents: 9b99ac7
Author: Christian Schneider <chris@die-schneider.net>
Authored: Mon May 15 16:03:07 2017 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Mon May 15 16:03:07 2017 +0200

----------------------------------------------------------------------
 .../karaf/features/internal/osgi/Activator.java       | 14 +++++++-------
 .../internal/service/FeaturesServiceImpl.java         | 12 +-----------
 .../apache/karaf/features/FeaturesServiceTest.java    |  8 ++++----
 .../internal/service/FeaturesServiceImplTest.java     | 10 +++++-----
 4 files changed, 17 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/d3c90b7e/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
index 720cbfb..8bd784e 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
@@ -201,19 +201,12 @@ public class Activator extends BaseActivator {
                 return new FileOutputStream(file);
             }
         };
-        EventAdminListener eventAdminListener;
-        try {
-            eventAdminListener = new EventAdminListener(bundleContext);
-        } catch (Throwable t) {
-            eventAdminListener = null;
-        }
         featuresService = new FeaturesServiceImpl(
                 bundleContext.getBundle(),
                 bundleContext,
                 bundleContext.getBundle(0).getBundleContext(),
                 stateStorage,
                 featureFinder,
-                eventAdminListener,
                 configurationAdmin,
                 resolver,
                 dg,
@@ -228,6 +221,13 @@ public class Activator extends BaseActivator {
                 scheduleMaxRun,
                 blacklisted,
                 configCfgStore);
+        
+        try {
+            EventAdminListener eventAdminListener = new EventAdminListener(bundleContext);
+            featuresService.registerListener(eventAdminListener);
+        } catch (Throwable t) {
+            // No EventAdmin support in this case 
+        }
         register(FeaturesService.class, featuresService);
 
         featuresListenerTracker = new ServiceTracker<>(

http://git-wip-us.apache.org/repos/asf/karaf/blob/d3c90b7e/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index d4e7ce1..81e72d7 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -135,7 +135,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
      */
     private final StateStorage storage;
     private final FeatureFinder featureFinder;
-    private final EventAdminListener eventAdminListener;
     private final ConfigurationAdmin configurationAdmin;
     private final Resolver resolver;
     private final FeatureConfigInstaller configInstaller;
@@ -196,7 +195,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
                                BundleContext systemBundleContext,
                                StateStorage storage,
                                FeatureFinder featureFinder,
-                               EventAdminListener eventAdminListener,
                                ConfigurationAdmin configurationAdmin,
                                Resolver resolver,
                                RegionDigraph digraph,
@@ -210,7 +208,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
                                long scheduleDelay,
                                int scheduleMaxRun,
                                String blacklisted) {
-        this(bundle, bundleContext,systemBundleContext, storage, featureFinder, eventAdminListener,
configurationAdmin,
+        this(bundle, bundleContext,systemBundleContext, storage, featureFinder, configurationAdmin,
                 resolver, digraph, overrides, featureResolutionRange, bundleUpdateRange,
updateSnaphots,
                 serviceRequirements, globalRepository, downloadThreads, scheduleDelay, scheduleMaxRun,
blacklisted,
                 FeaturesService.DEFAULT_CONFIG_CFG_STORE);
@@ -221,7 +219,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
                                BundleContext systemBundleContext,
                                StateStorage storage,
                                FeatureFinder featureFinder,
-                               EventAdminListener eventAdminListener,
                                ConfigurationAdmin configurationAdmin,
                                Resolver resolver,
                                RegionDigraph digraph,
@@ -241,7 +238,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
         this.systemBundleContext = systemBundleContext;
         this.storage = storage;
         this.featureFinder = featureFinder;
-        this.eventAdminListener = eventAdminListener;
         this.configurationAdmin = configurationAdmin;
         this.resolver = resolver;
         this.configInstaller = configurationAdmin != null ? new FeatureConfigInstaller(configurationAdmin,
configCfgStore) : null;
@@ -410,9 +406,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
      */
     @Override
     public void callListeners(FeatureEvent event) {
-        if (eventAdminListener != null) {
-            eventAdminListener.featureEvent(event);
-        }
         for (FeaturesListener listener : listeners) {
             listener.featureEvent(event);
         }
@@ -437,9 +430,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
      * Should never be called while holding a lock as we're calling outside our bundle.
      */
     protected void callListeners(RepositoryEvent event) {
-        if (eventAdminListener != null) {
-            eventAdminListener.repositoryEvent(event);
-        }
         for (FeaturesListener listener : listeners) {
             listener.repositoryEvent(event);
         }

http://git-wip-us.apache.org/repos/asf/karaf/blob/d3c90b7e/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
b/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
index 40ce483..f1c245e 100644
--- a/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
@@ -349,7 +349,7 @@ public class FeaturesServiceTest extends TestBase {
                 + "  <feature name='f2' version='0.2'><bundle>bundle2</bundle></feature>"
                 + "</features>");
 
-        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0, null);
+        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0, null);
         svc.addRepository(uri);
 
         assertEquals(feature("f2", "0.2"), svc.getFeatures("f2", "[0.1,0.3)")[0]);
@@ -375,7 +375,7 @@ public class FeaturesServiceTest extends TestBase {
         expect(fsl.getStartLevel()).andReturn(100);
         replay(bundleContext, bundle, fsl);
 
-        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, bundleContext, new
Storage(), null, null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0,
null);
+        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, bundleContext, new
Storage(), null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0, null);
         svc.addRepository(uri);
         try {
             List<String> features = new ArrayList<String>();
@@ -400,7 +400,7 @@ public class FeaturesServiceTest extends TestBase {
         URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                 + "  <featur><bundle>somebundle</bundle></featur></features>");
 
-        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0, null);
+        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0, null);
         try {
             svc.addRepository(uri);
             fail("exception expected");
@@ -418,7 +418,7 @@ public class FeaturesServiceTest extends TestBase {
                 + "  <feature name='f1'><bundle>file:bundle1</bundle><bundle>file:bundle2</bundle></feature>"
                 + "</features>");
 
-        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0, null);
+        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, resolver, null, null, null, null, null, null, null, 0, 0, 0, null);
         svc.addRepository(uri);
         Feature[] features = svc.getFeatures("f1");
         Assert.assertEquals(1, features.length);

http://git-wip-us.apache.org/repos/asf/karaf/blob/d3c90b7e/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
b/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
index 7ef79d1..8d592fc 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
@@ -56,7 +56,7 @@ public class FeaturesServiceImplTest extends TestBase {
     public void testGetFeature() throws Exception {
         Feature transactionFeature = feature("transaction", "1.0.0");
         final Map<String, Map<String, Feature>> features = features(transactionFeature);
-        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
+        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
             protected Map<String,Map<String,Feature>> getFeatures() throws Exception
{
                 return features;
             }
@@ -67,7 +67,7 @@ public class FeaturesServiceImplTest extends TestBase {
     
     @Test
     public void testGetFeatureStripVersion() throws Exception {
-        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
+        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
             protected Map<String,Map<String,Feature>> getFeatures() throws Exception
{
                 return features(feature("transaction", "1.0.0"));
             }
@@ -81,7 +81,7 @@ public class FeaturesServiceImplTest extends TestBase {
     
     @Test
     public void testGetFeatureNotAvailable() throws Exception {
-        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
+        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
             protected Map<String,Map<String,Feature>> getFeatures() throws Exception
{
                 return features(feature("transaction", "1.0.0"));
             }
@@ -95,7 +95,7 @@ public class FeaturesServiceImplTest extends TestBase {
                 feature("transaction", "1.0.0"),
                 feature("transaction", "2.0.0")
         );
-        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
+        final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new Storage(),
null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null) {
             protected Map<String,Map<String,Feature>> getFeatures() throws Exception
{
                 return features;
             }
@@ -113,7 +113,7 @@ public class FeaturesServiceImplTest extends TestBase {
             }
         } : null);
         try {
-            final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new
Storage(), null, null, null, this.resolver, null, "", null, null, null, null, null, 0, 0,
0, null);
+            final FeaturesServiceImpl impl = new FeaturesServiceImpl(null, null, null, new
Storage(), null, null, this.resolver, null, "", null, null, null, null, null, 0, 0, 0, null);
             impl.addRepository(URI.create("custom:cycle/a-references-b.xml"));
             impl.getFeatures();
         } finally {


Mime
View raw message