You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/11/20 19:44:23 UTC

svn commit: r719321 - /servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java

Author: gnodet
Date: Thu Nov 20 10:44:23 2008
New Revision: 719321

URL: http://svn.apache.org/viewvc?rev=719321&view=rev
Log:
SMX4-161: The first spec implementation bundle deployed is always used instead of the last one

Modified:
    servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java

Modified: servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java?rev=719321&r1=719320&r2=719321&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java (original)
+++ servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java Thu Nov 20 10:44:23 2008
@@ -26,14 +26,14 @@
 
 public class OsgiLocator {
 
-    private static Map<String, Set<Callable<Class>>> factories;
+    private static Map<String, List<Callable<Class>>> factories;
 
     private OsgiLocator() {
     }
 
     public static synchronized void unregister(String id, Callable<Class> factory) {
         if (factories != null) {
-            Set<Callable<Class>> l = factories.get(id);
+            List<Callable<Class>> l = factories.get(id);
             if (l != null) {
                 l.remove(factory);
             }
@@ -42,11 +42,11 @@
 
     public static synchronized void register(String id, Callable<Class> factory) {
         if (factories == null) {
-            factories = new HashMap<String, Set<Callable<Class>>>();
+            factories = new HashMap<String, List<Callable<Class>>>();
         }
-        Set<Callable<Class>> l = factories.get(id);
+        List<Callable<Class>> l = factories.get(id);
         if (l ==  null) {
-            l = new HashSet<Callable<Class>>();
+            l = new ArrayList<Callable<Class>>();
             factories.put(id, l);
         }
         l.add(factory);
@@ -54,9 +54,9 @@
 
     public static synchronized Class locate(String factoryId) {
         if (factories != null) {
-            Set<Callable<Class>> l = factories.get(factoryId);
+            List<Callable<Class>> l = factories.get(factoryId);
             if (l != null && !l.isEmpty()) {
-                Callable<Class> c = l.iterator().next();
+                Callable<Class> c = l.get(l.size() - 1);
                 try {
                     return c.call();
                 } catch (Exception e) {
@@ -66,10 +66,10 @@
         return null;
     }
 
-	public static synchronized List<Class> locateAll(String factoryId) {
-		List<Class> classes = new ArrayList<Class>();
+    public static synchronized List<Class> locateAll(String factoryId) {
+        List<Class> classes = new ArrayList<Class>();
         if (factories != null) {
-            Set<Callable<Class>> l = factories.get(factoryId);
+            List<Callable<Class>> l = factories.get(factoryId);
             if (l != null) {
                 for (Callable<Class> c : l) {
                 	try {
@@ -80,6 +80,6 @@
             }
         }
         return classes;
-	}
+    }
 
 }