Author: fmeschbe
Date: Thu Nov 26 07:20:03 2009
New Revision: 884427

URL: http://svn.apache.org/viewvc?rev=884427&view=rev
Log:
FELIX-1841 Improve service bind update by creating a special "update" method 
which directly calls the invokeBindMethod(ServiceReference) method instead of 
going through the regular bind() method, which may not call the correct bind 
method at all (or too many methods)

Modified:
    
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java

Modified: 
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=884427&r1=884426&r2=884427&view=diff
==============================================================================
--- 
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
 (original)
+++ 
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
 Thu Nov 26 07:20:03 2009
@@ -125,10 +125,10 @@
                                  m_dependencyMetadata.getInterface()
         );
         m_unbind = new UnbindMethod( m_componentManager,
-                                     m_dependencyMetadata.getUnbind(),
-                                     m_componentInstance.getClass(),
-                                     m_dependencyMetadata.getName(),
-                                     m_dependencyMetadata.getInterface()
+            m_dependencyMetadata.getUnbind(),
+            m_componentInstance.getClass(),
+            m_dependencyMetadata.getName(),
+            m_dependencyMetadata.getInterface()
         );
     }
 
@@ -208,11 +208,10 @@
                     m_size--;
                     serviceRemoved( ref );
                 }
-                else if ( "true".equalsIgnoreCase( 
m_componentManager.getBundle().getBundleContext().getProperty(
-                    "ds.rebind.enabled" ) ) )
+                else
                 {
-                    // service is bound, bind again to update reference 
properties
-                    bind();
+                    // update the service binding due to the new properties
+                    update( ref );
                 }
 
                 break;
@@ -921,6 +920,33 @@
 
 
     /**
+     * Handles an update in the service reference properties of a bound 
service.
+     * <p>
+     * For now this just calls the bind method with the service again if
+     * the <code>ds.rebind.enabled</code> configuration property is set to
+     * <code>true</code>. If the property is not set to <code>true</code> this
+     * method does nothing.
+     *
+     * @param ref The <code>ServiceReference</code> representing the updated
+     *      service.
+     */
+    private void update( final ServiceReference ref )
+    {
+        //        if ( 
m_componentManager.getActivator().getConfiguration().isRebindEnabled() )
+        if ( "true".equalsIgnoreCase( 
m_componentManager.getBundle().getBundleContext().getProperty(
+            "ds.rebind.enabled" ) ) )
+        {
+            // The updated method is only invoked if the implementation object 
is not
+            // null. This is valid for both immediate and delayed components
+            if ( m_dependencyMetadata.getBind() != null )
+            {
+                invokeBindMethod( ref );
+            }
+        }
+    }
+
+
+    /**
      * Revoke the given bindings. This method cannot throw an exception since
      * it must try to complete all that it can
      */


Reply via email to