felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r947498 - in /felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl: AdapterServiceImpl.java ResourceAdapterServiceImpl.java
Date Sun, 23 May 2010 21:28:15 GMT
Author: pderop
Date: Sun May 23 21:28:15 2010
New Revision: 947498

URL: http://svn.apache.org/viewvc?rev=947498&view=rev
Log:
register state listeners in Adapter/ResourceAdapter service

Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java?rev=947498&r1=947497&r2=947498&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
Sun May 23 21:28:15 2010
@@ -23,6 +23,7 @@ import java.util.Properties;
 
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.service.Service;
+import org.apache.felix.dm.service.ServiceStateListener;
 import org.osgi.framework.ServiceReference;
 
 /**
@@ -58,7 +59,6 @@ public class AdapterServiceImpl extends 
         
         public Service createService(Object[] properties) {
             ServiceReference ref = (ServiceReference) properties[0]; 
-            Object service = properties[1];
             Properties props = new Properties();
             String[] keys = ref.getPropertyKeys();
             for (int i = 0; i < keys.length; i++) {
@@ -73,7 +73,7 @@ public class AdapterServiceImpl extends 
             }
             List dependencies = m_service.getDependencies();
             dependencies.remove(0);
-            return m_manager.createService()
+            Service service = m_manager.createService()
                 .setInterface(m_serviceInterfaces, props)
                 .setImplementation(m_serviceImpl)
                 .setFactory(m_factory, m_factoryCreateMethod) // if not set, no effect
@@ -83,6 +83,10 @@ public class AdapterServiceImpl extends 
                 .add(m_manager.createServiceDependency()
                      .setService(m_adapteeInterface, ref)
                      .setRequired(true));
+            for (int i = 0; i < m_stateListeners.size(); i ++) {
+                service.addStateListener((ServiceStateListener) m_stateListeners.get(i));
+            }
+            return service;
         }
     }
 }

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java?rev=947498&r1=947497&r2=947498&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
Sun May 23 21:28:15 2010
@@ -25,6 +25,7 @@ import java.util.Properties;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.resources.Resource;
 import org.apache.felix.dm.service.Service;
+import org.apache.felix.dm.service.ServiceStateListener;
 
 /**
  * Resource adapter service implementation. This class extends the FilterService in order
to catch
@@ -68,19 +69,23 @@ public class ResourceAdapterServiceImpl 
             // the first dependency is always the dependency on the resource, which
             // will be replaced with a more specific dependency below
             dependencies.remove(0);
-            return m_manager.createService()
-                            .setInterface(m_serviceInterfaces, props)
-                            .setImplementation(m_serviceImpl)
-                            .setFactory(m_factory, m_factoryCreateMethod) // if not set,
no effect
-                            .setComposition(m_compositionInstance, m_compositionMethod) //
if not set, no effect
-                            .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy)
// if not set, no effect
-                            .add(dependencies)
-                            .add(m_manager.createResourceDependency()
-                                 .setResource(resource)
-                                 .setPropagate(m_propagate)
-                                 .setCallbacks(null, "changed", null)
-                                 .setAutoConfig(true)
-                                 .setRequired(true));            
+            Service service = m_manager.createService()
+                .setInterface(m_serviceInterfaces, props)
+                .setImplementation(m_serviceImpl)
+                .setFactory(m_factory, m_factoryCreateMethod) // if not set, no effect
+                .setComposition(m_compositionInstance, m_compositionMethod) // if not set,
no effect
+                .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy) // if
not set, no effect
+                .add(dependencies)
+                .add(m_manager.createResourceDependency()
+                     .setResource(resource)
+                     .setPropagate(m_propagate)
+                     .setCallbacks(null, "changed", null)
+                     .setAutoConfig(true)
+                     .setRequired(true));         
+            for (int i = 0; i < m_stateListeners.size(); i ++) {
+                service.addStateListener((ServiceStateListener) m_stateListeners.get(i));
+            }
+            return service;
         }
     }
 }



Mime
View raw message