Used a Java 5 style for() loop by accident. Extended the signature for creating resource adapters so you can also specify a callback instance and name for the changed method.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@959668 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java
index 57e3e5d..7a86446 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.dm;
 
-import java.util.Dictionary;
 import java.util.List;
 
 import org.apache.felix.dm.dependencies.BundleDependency;
@@ -165,8 +164,8 @@
         return m_manager.createAdapterService(serviceInterface, serviceFilter);
     }
     
-    public Service createResourceAdapter(String resourceFilter, boolean propagate) {
-        return m_manager.createResourceAdapterService(resourceFilter, propagate);
+    public Service createResourceAdapter(String resourceFilter, boolean propagate, Object callbackInstance, String callbackChanged) {
+        return m_manager.createResourceAdapterService(resourceFilter, propagate, callbackInstance, callbackChanged);
     }
     
     public Service createBundleAdapterService(int bundleStateMask, String bundleFilter, boolean propagate) {
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
index 659ec49..4d5f507 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
@@ -189,7 +189,7 @@
     public Service createAspectService(Class serviceInterface, String serviceFilter, int ranking, String attributeName) {
         return new AspectServiceImpl(this, serviceInterface, serviceFilter, ranking, attributeName);
     }
-
+    
     /**
      * Creates a new adapter. The adapter will be applied to any service that
      * matches the specified interface and filter. For each matching service
@@ -237,11 +237,13 @@
      *
      * @param resourceFilter the filter condition to use with the resource
      * @param propagate <code>true</code> if properties from the resource should be propagated to the service
+     * @param callbackInstance 
+     * @param callbackChanged 
      * @return a service that acts as a factory for generating resource adapters
      * @see Resource
      */
-    public Service createResourceAdapterService(String resourceFilter, boolean propagate) {
-        return new ResourceAdapterServiceImpl(this, resourceFilter, propagate);
+    public Service createResourceAdapterService(String resourceFilter, boolean propagate, Object callbackInstance, String callbackChanged) {
+        return new ResourceAdapterServiceImpl(this, resourceFilter, propagate, callbackInstance, callbackChanged);
     }
     
     /**
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
index 8c54524..50fd4e2 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
@@ -85,8 +85,8 @@
                      .setService(m_adapteeInterface, ref)
                      .setRequired(true));
             
-            for (Object d : dependencies) {
-                service.add(((Dependency) d).createCopy());
+            for (int i = 0; i < dependencies.size(); i++) {
+                service.add(((Dependency) dependencies.get(i)).createCopy());
             }
             
             for (int i = 0; i < m_stateListeners.size(); i ++) {
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
index 830357b..b715446 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
@@ -88,8 +88,8 @@
                 .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy) // if not set, no effect
                 .add(getAspectDependency());
             
-            for (Object d : dependencies) {
-                service.add(((Dependency) d).createCopy());
+            for (int i = 0; i < dependencies.size(); i++) {
+                service.add(((Dependency) dependencies.get(i)).createCopy());
             }
 
             for (int i = 0; i < m_stateListeners.size(); i ++) {
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
index 4a8b464..5b5b8a3 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
@@ -86,8 +86,8 @@
                     .setAutoConfig(true)
                     .setRequired(true));
 
-            for (Object d : dependencies) {
-                service.add(((Dependency) d).createCopy());
+            for (int i = 0; i < dependencies.size(); i++) {
+                service.add(((Dependency) dependencies.get(i)).createCopy());
             }
 
             for (int i = 0; i < m_stateListeners.size(); i ++) {
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
index dc60d78..ea6f3e9 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
@@ -32,21 +32,25 @@
  * Resource adapter service implementation. This class extends the FilterService in order to catch
  * some Service methods for configuring actual resource adapter service implementation.
  */
-public class ResourceAdapterServiceImpl extends FilterService
-{
+public class ResourceAdapterServiceImpl extends FilterService {
+    private Object m_callbackInstance = null;
+    private String m_callbackChanged = "changed";
+    
     /**
      * Creates a new Resource Adapter Service implementation.
      * @param dm the dependency manager used to create our internal adapter service
      */
-    public ResourceAdapterServiceImpl(DependencyManager dm, String resourceFilter, boolean propagate)    {
+    public ResourceAdapterServiceImpl(DependencyManager dm, String resourceFilter, boolean propagate, Object callbackInstance, String callbackChanged) {
         super(dm.createService()); // This service will be filtered by our super class, allowing us to take control.
+        m_callbackInstance = callbackInstance;
+        m_callbackChanged = callbackChanged;
         m_service.setImplementation(new ResourceAdapterImpl(resourceFilter, propagate))
-                 .add(dm.createResourceDependency()
-                      .setFilter(resourceFilter)
-                      .setAutoConfig(false)
-                      .setCallbacks("added", "removed"));
+            .add(dm.createResourceDependency()
+                 .setFilter(resourceFilter)
+                 .setAutoConfig(false)
+                 .setCallbacks("added", "removed"));
     }
-    
+
     public class ResourceAdapterImpl extends AbstractDecorator {
         private final String m_resourceFilter;
         private final boolean m_propagate;
@@ -79,12 +83,12 @@
                 .add(m_manager.createResourceDependency()
                      .setResource(resource)
                      .setPropagate(m_propagate)
-                     .setCallbacks(null, "changed", null)
+                     .setCallbacks(m_callbackInstance, null, m_callbackChanged, null)
                      .setAutoConfig(true)
                      .setRequired(true));
             
-            for (Object d : dependencies) {
-                service.add(((Dependency) d).createCopy());
+            for (int i = 0; i < dependencies.size(); i++) {
+                service.add(((Dependency) dependencies.get(i)).createCopy());
             }
 
             for (int i = 0; i < m_stateListeners.size(); i ++) {