felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1064774 - in /felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal: ConfigInstaller.java FileInstall.java
Date Fri, 28 Jan 2011 16:56:17 GMT
Author: gnodet
Date: Fri Jan 28 16:56:17 2011
New Revision: 1064774

URL: http://svn.apache.org/viewvc?rev=1064774&view=rev
Log:
[FELIX-2798] ArtifactListener services are not ordered according to the OSGi ranking

Modified:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java?rev=1064774&r1=1064773&r2=1064774&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
Fri Jan 28 16:56:17 2011
@@ -33,6 +33,7 @@ import java.util.Properties;
 
 import org.apache.felix.cm.file.ConfigurationHandler;
 import org.apache.felix.fileinstall.ArtifactInstaller;
+import org.apache.felix.fileinstall.ArtifactListener;
 import org.apache.felix.fileinstall.internal.Util.Logger;
 import org.apache.felix.utils.collections.DictionaryAsMap;
 import org.apache.felix.utils.properties.InterpolationHelper;
@@ -65,7 +66,13 @@ public class ConfigInstaller implements 
         if (registration == null)
         {
             Properties props = new Properties();
-            registration = this.context.registerService(ConfigurationListener.class.getName(),
this, props);
+            registration = this.context.registerService(
+                    new String[] {
+                        ConfigurationListener.class.getName(),
+                        ArtifactListener.class.getName(),
+                        ArtifactInstaller.class.getName()
+                    },
+                    this, props);
         }
     }
 

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java?rev=1064774&r1=1064773&r2=1064774&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
Fri Jan 28 16:56:17 2011
@@ -41,7 +41,8 @@ public class FileInstall implements Bund
     static ServiceTracker padmin;
     static ServiceTracker startLevel;
     static Runnable cmSupport;
-    static List /* <ArtifactListener> */ listeners = new ArrayList /* <ArtifactListener>
*/();
+    static final Map /* <ServiceReference, ArtifactListener> */ listeners = new TreeMap
/* <ServiceReference, ArtifactListener> */();
+    static final BundleTransformer bundleTransformer = new BundleTransformer();
     BundleContext context;
     Map watchers = new HashMap();
     ServiceTracker listenersTracker;
@@ -51,7 +52,6 @@ public class FileInstall implements Bund
     public void start(BundleContext context) throws Exception
     {
         this.context = context;
-        addListener(new BundleTransformer());
 
         Hashtable props = new Hashtable();
         props.put("url.handler.protocol", JarDirUrlHandler.PROTOCOL);
@@ -69,12 +69,18 @@ public class FileInstall implements Bund
             public Object addingService(ServiceReference serviceReference)
             {
                 ArtifactListener listener = (ArtifactListener) super.addingService(serviceReference);
-                addListener(listener);
+                addListener(serviceReference, listener);
                 return listener;
             }
+            public void modifiedService(ServiceReference reference, Object service)
+            {
+                super.modifiedService(reference, service);
+                removeListener(reference);
+                addListener(reference, (ArtifactListener) service);
+            }
             public void removedService(ServiceReference serviceReference, Object o)
             {
-                removeListener((ArtifactListener) o);
+                removeListener(serviceReference);
             }
         };
         listenersTracker.open();
@@ -221,20 +227,20 @@ public class FileInstall implements Bund
         watcher.start();
     }
 
-    private void addListener(ArtifactListener listener)
+    private void addListener(ServiceReference reference, ArtifactListener listener)
     {
         synchronized (listeners)
         {
-            listeners.add(listener);
+            listeners.put(reference, listener);
         }
         notifyWatchers();
     }
 
-    private void removeListener(ArtifactListener listener)
+    private void removeListener(ServiceReference reference)
     {
         synchronized (listeners)
         {
-            listeners.remove(listener);
+            listeners.remove(reference);
         }
         notifyWatchers();
     }
@@ -260,7 +266,9 @@ public class FileInstall implements Bund
     {
         synchronized (listeners)
         {
-            return new ArrayList(listeners);
+            List l = new ArrayList(listeners.values());
+            l.add(bundleTransformer);
+            return l;
         }
     }
 
@@ -349,7 +357,6 @@ public class FileInstall implements Bund
                 ConfigurationAdmin cm = (ConfigurationAdmin) super.addingService(serviceReference);
                 configInstaller = new ConfigInstaller(context, cm);
                 configInstaller.init();
-                fileInstall.addListener(configInstaller);
                 return cm;
             }
 
@@ -358,7 +365,6 @@ public class FileInstall implements Bund
                 if (configInstaller != null)
                 {
                     configInstaller.destroy();
-                    fileInstall.removeListener(configInstaller);
                     configInstaller = null;
                 }
                 super.removedService(serviceReference, o);



Mime
View raw message