felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r959668 - in /felix/trunk/dependencymanager: core/src/main/java/org/apache/felix/dm/ core/src/main/java/org/apache/felix/dm/impl/ runtime/src/main/java/org/apache/felix/dm/runtime/ test/src/test/java/org/apache/felix/dm/test/
Date Thu, 01 Jul 2010 14:01:02 GMT
Author: marrs
Date: Thu Jul  1 14:01:02 2010
New Revision: 959668

URL: http://svn.apache.org/viewvc?rev=959668&view=rev
Log:
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.

Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
    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/AspectServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
    felix/trunk/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ResourceAdapterServiceBuilder.java
    felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2348_ResourceAdapterTest.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java?rev=959668&r1=959667&r2=959668&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyActivatorBase.java
Thu Jul  1 14:01:02 2010
@@ -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 @@ public abstract class DependencyActivato
         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) {

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java?rev=959668&r1=959667&r2=959668&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
Thu Jul  1 14:01:02 2010
@@ -189,7 +189,7 @@ public class DependencyManager {
     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 @@ public class DependencyManager {
      *
      * @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);
     }
     
     /**

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=959668&r1=959667&r2=959668&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
Thu Jul  1 14:01:02 2010
@@ -85,8 +85,8 @@ public class AdapterServiceImpl extends 
                      .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 ++) {

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java?rev=959668&r1=959667&r2=959668&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
Thu Jul  1 14:01:02 2010
@@ -88,8 +88,8 @@ public class AspectServiceImpl extends F
                 .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 ++) {

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java?rev=959668&r1=959667&r2=959668&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
Thu Jul  1 14:01:02 2010
@@ -86,8 +86,8 @@ public class BundleAdapterServiceImpl ex
                     .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 ++) {

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=959668&r1=959667&r2=959668&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
Thu Jul  1 14:01:02 2010
@@ -32,21 +32,25 @@ import org.apache.felix.dm.service.Servi
  * 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 @@ public class ResourceAdapterServiceImpl 
                 .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 ++) {

Modified: felix/trunk/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ResourceAdapterServiceBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ResourceAdapterServiceBuilder.java?rev=959668&r1=959667&r2=959668&view=diff
==============================================================================
--- felix/trunk/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ResourceAdapterServiceBuilder.java
(original)
+++ felix/trunk/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ResourceAdapterServiceBuilder.java
Thu Jul  1 14:01:02 2010
@@ -44,7 +44,7 @@ public class ResourceAdapterServiceBuild
         String[] service = srvMeta.getStrings(Params.service, null);
         Dictionary<String, Object> properties = srvMeta.getDictionary(Params.properties,
null);
         boolean propagate = "true".equals(srvMeta.getString(Params.propagate, "false"));
-        Service srv = dm.createResourceAdapterService(filter, propagate)
+        Service srv = dm.createResourceAdapterService(filter, propagate, null, "changed")
                         .setInterface(service, properties);       
         String factoryMethod = srvMeta.getString(Params.factoryMethod, null);
         if (factoryMethod == null)

Modified: felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2348_ResourceAdapterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2348_ResourceAdapterTest.java?rev=959668&r1=959667&r2=959668&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2348_ResourceAdapterTest.java
(original)
+++ felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2348_ResourceAdapterTest.java
Thu Jul  1 14:01:02 2010
@@ -64,7 +64,7 @@ public class FELIX2348_ResourceAdapterTe
         DependencyManager m = new DependencyManager(context);
         // helper class that ensures certain steps get executed in sequence
         Ensure e = new Ensure();
-        m.add(m.createResourceAdapterService("(&(path=/test)(name=*.txt)(repository=TestRepository))",
false)
+        m.add(m.createResourceAdapterService("(&(path=/test)(name=*.txt)(repository=TestRepository))",
false, null, "changed")
               .setImplementation(new ResourceAdapter(e)));
         m.add(m.createService().setImplementation(new ResourceProvider(e)).add(m.createServiceDependency().setService(ResourceHandler.class).setCallbacks("add",
"remove")));
         e.waitForStep(3, 5000);



Mime
View raw message