felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uiter...@apache.org
Subject svn commit: r1298477 - /felix/sandbox/uiterlix/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
Date Thu, 08 Mar 2012 17:24:27 GMT
Author: uiterlix
Date: Thu Mar  8 17:24:26 2012
New Revision: 1298477

URL: http://svn.apache.org/viewvc?rev=1298477&view=rev
Log:
fixed wrong dependency filter when first service passed is already an aspect service.

Modified:
    felix/sandbox/uiterlix/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java

Modified: felix/sandbox/uiterlix/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/uiterlix/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java?rev=1298477&r1=1298476&r2=1298477&view=diff
==============================================================================
--- felix/sandbox/uiterlix/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
(original)
+++ felix/sandbox/uiterlix/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
Thu Mar  8 17:24:26 2012
@@ -87,15 +87,25 @@ public class AdapterServiceImpl extends 
             ServiceReference ref = (ServiceReference) properties[0]; 
             Properties props = new Properties();
             String[] keys = ref.getPropertyKeys();
+            String serviceIdToTrack = null;
+            System.out.println("Copying properties");
             for (int i = 0; i < keys.length; i++) {
                 String key = keys[i];
-                if (key.equals(Constants.SERVICE_ID) || key.equals(Constants.SERVICE_RANKING)
|| key.equals(DependencyManager.ASPECT) || key.equals(Constants.OBJECTCLASS)) {
-                    // do not copy these
+                if (key.equals(DependencyManager.ASPECT)) {
+                	// if we're handed an aspect fetch the aspect property as the service id
to track, but do not copy it
+                	serviceIdToTrack = ref.getProperty(key).toString();
+                }
+                if (key.equals(Constants.SERVICE_ID) || key.equals(Constants.SERVICE_RANKING)
|| key.equals(Constants.OBJECTCLASS)) {
+                    // do not copy these either
                 }
                 else {
                     props.put(key, ref.getProperty(key));
                 }
             }
+            if (serviceIdToTrack == null) {
+            	// we're not handed an aspect so we can use the service id to track
+            	serviceIdToTrack = ref.getProperty(Constants.SERVICE_ID).toString();
+            }
             if (m_serviceProperties != null) {
                 Enumeration e = m_serviceProperties.keys();
                 while (e.hasMoreElements()) {
@@ -107,8 +117,8 @@ public class AdapterServiceImpl extends 
             dependencies.remove(0);
             ServiceDependency dependency = m_manager.createServiceDependency()
             	 // create a dependency on both the service id we're adapting and possible aspects
for this given service id
-            	 .setService(m_adapteeInterface, "(|(" + Constants.SERVICE_ID + "=" + ref.getProperty(Constants.SERVICE_ID)

-            			 	+ ")(" + DependencyManager.ASPECT + "=" + ref.getProperty(Constants.SERVICE_ID)
+ "))")
+            	 .setService(m_adapteeInterface, "(|(" + Constants.SERVICE_ID + "=" + serviceIdToTrack

+            			 	+ ")(" + DependencyManager.ASPECT + "=" + serviceIdToTrack + "))")
                  .setRequired(true);
             if (m_autoConfig != null) {
                 dependency.setAutoConfig(m_autoConfig);
@@ -116,7 +126,7 @@ public class AdapterServiceImpl extends 
             if (m_add != null || m_change != null || m_remove != null || m_swap != null)
{
                 dependency.setCallbacks(m_add, m_change, m_remove, m_swap);
             }
-            
+
             Component service = m_manager.createComponent()
                 .setInterface(m_serviceInterfaces, props)
                 .setImplementation(m_serviceImpl)



Mime
View raw message