felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uiter...@apache.org
Subject svn commit: r1310294 - in /felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index: AdapterFilterIndex.java AspectFilterIndex.java
Date Fri, 06 Apr 2012 12:07:04 GMT
Author: uiterlix
Date: Fri Apr  6 12:07:03 2012
New Revision: 1310294

URL: http://svn.apache.org/viewvc?rev=1310294&view=rev
Log:
processed review comments on FELIX-3425.

Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java?rev=1310294&r1=1310293&r2=1310294&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java
Fri Apr  6 12:07:03 2012
@@ -39,11 +39,13 @@ import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 
+import quicktime.std.music.ToneDescription;
+
 /**
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class AdapterFilterIndex implements FilterIndex, ServiceTrackerCustomizer {
-	// (&(objectClass=com.beinformed.product.platform.interfaces.Resource)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))
+	// (&(objectClass=foo.Bar)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))
     private static final String FILTER_START = "(&(" + Constants.OBJECTCLASS + "=";
     private static final String FILTER_SUBSTRING_0 = ")(|(" + Constants.SERVICE_ID + "=";
     private static final String FILTER_SUBSTRING_1 = ")(" + DependencyManager.ASPECT + "=";
@@ -91,7 +93,7 @@ public class AdapterFilterIndex implemen
     /** Returns a value object with the relevant filter data, or <code>null</code>
if this filter was not valid. */
     private FilterData getFilterData(String clazz, String filter) {
         // something like:
-    	// (&(objectClass=com.beinformed.product.platform.interfaces.Resource)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))
   	
+    	// (&(objectClass=foo.Bar)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))
   	
         if ((filter != null)
             && (filter.startsWith(FILTER_START))
             && (filter.endsWith(FILTER_END))
@@ -125,13 +127,13 @@ public class AdapterFilterIndex implemen
         	SortedSet /* <ServiceReference> */ list = null;
         	synchronized (m_sidToServiceReferencesMap) {
         		list = (SortedSet) m_sidToServiceReferencesMap.get(Long.valueOf(data.serviceId));
+        		if (list != null) {
+        			Iterator iterator = list.iterator();
+        			while (iterator.hasNext()) {
+        				result.add((ServiceReference) iterator.next());
+        			}
+        		}
 			}
-            if (list != null) {
-                Iterator iterator = list.iterator();
-                while (iterator.hasNext()) {
-                    result.add((ServiceReference) iterator.next());
-                }
-            }
         }
         return result;
     }
@@ -139,16 +141,19 @@ public class AdapterFilterIndex implemen
     public void serviceChanged(ServiceEvent event) {
         ServiceReference reference = event.getServiceReference();
         Long sid = ServiceUtil.getServiceIdObject(reference);
+        List /* <ServiceListener> */ notificationList = new ArrayList();
         synchronized (m_sidToListenersMap) {
-            List /* <Integer, ServiceListener> */ list = (ArrayList) m_sidToListenersMap.get(sid);
+            List /* <ServiceListener> */ list = (ArrayList) m_sidToListenersMap.get(sid);
             if (list != null) {
-                Iterator iterator = list.iterator();
-                while (iterator.hasNext()) {
-                    ServiceListener listener = (ServiceListener) iterator.next();
-                    listener.serviceChanged(event);
-                }
+                notificationList.addAll(list);
             }
         }
+        // notify
+        Iterator iterator = notificationList.iterator();
+        while (iterator.hasNext()) {
+        	ServiceListener listener = (ServiceListener) iterator.next();
+        	listener.serviceChanged(event);
+        }
     }
 
     public void addServiceListener(ServiceListener listener, String filter) {

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java?rev=1310294&r1=1310293&r2=1310294&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java
Fri Apr  6 12:07:03 2012
@@ -94,7 +94,7 @@ public class AspectFilterIndex implement
     /** Returns a value object with the relevant filter data, or <code>null</code>
if this filter was not valid. */
     private FilterData getFilterData(String clazz, String filter) {
         // something like:
-        // (&(objectClass=com.beinformed.wiringtest.Model)(&(|(!(service.ranking=*))(service.ranking<=9))(|(service.id=37)(org.apache.felix.dependencymanager.aspect=37))))
+        // (&(objectClass=foo.Bar)(&(|(!(service.ranking=*))(service.ranking<=9))(|(service.id=37)(org.apache.felix.dependencymanager.aspect=37))))
         if ((filter != null)
             && (filter.startsWith(FILTER_START))
             && (filter.endsWith(FILTER_END))
@@ -132,16 +132,16 @@ public class AspectFilterIndex implement
         	SortedSet /* <ServiceReference> */ list = null;
         	synchronized (m_sidToServiceReferencesMap) {
         		list = (SortedSet) m_sidToServiceReferencesMap.get(Long.valueOf(data.serviceId));
+        		if (list != null) {
+        			Iterator iterator = list.iterator();
+        			while (iterator.hasNext()) {
+        				ServiceReference reference = (ServiceReference) iterator.next();
+        				if (ServiceUtil.getRanking(reference) <= data.ranking) {
+        					result.add(reference);
+        				}
+        			}
+        		}
 			}
-            if (list != null) {
-                Iterator iterator = list.iterator();
-                while (iterator.hasNext()) {
-                    ServiceReference reference = (ServiceReference) iterator.next();
-                    if (ServiceUtil.getRanking(reference) <= data.ranking) {
-                        result.add(reference);
-                    }
-                }
-            }
         }
         return result;
     }



Mime
View raw message