felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1771506 - /felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
Date Sat, 26 Nov 2016 17:38:53 GMT
Author: pderop
Date: Sat Nov 26 17:38:53 2016
New Revision: 1771506

URL: http://svn.apache.org/viewvc?rev=1771506&view=rev
Log:
FELIX-5429: do not invoke swap callback in case state is INSTANTIATED_AND_WAITING_FOR_REQUIRED
and dependency is optional and component has not been called in start().

Modified:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java?rev=1771506&r1=1771505&r2=1771506&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
Sat Nov 26 17:38:53 2016
@@ -1219,13 +1219,11 @@ public class ComponentImpl implements Co
         case INSTANTIATED_AND_WAITING_FOR_REQUIRED:
             // Only swap *non* instance-bound dependencies
             if (!dc.isInstanceBound()) {
-                if (dc.isRequired()) {
-                    dc.invokeCallback(EventType.SWAPPED, oldEvent, newEvent);
-                }
+            	invokeSwapCallback(dc, oldEvent, newEvent);
             }
             break;
         case TRACKING_OPTIONAL:
-            dc.invokeCallback(EventType.SWAPPED, oldEvent, newEvent);
+        	invokeSwapCallback(dc, oldEvent, newEvent);
             break;
         default:
         }
@@ -1494,6 +1492,17 @@ public class ComponentImpl implements Co
 	}
 	
 	/**
+	 * Invokes a swap callback, except if the dependency is optional and the component is 
+	 * not started (optional dependencies are always injected while the component is started).

+	 */
+	private void invokeSwapCallback(DependencyContext dc, Event oldEvent, Event newEvent) {
+		if (! dc.isRequired() && ! m_startCalled) {
+			return;
+		}
+        dc.invokeCallback(EventType.SWAPPED, oldEvent, newEvent);
+	}
+	
+	/**
 	 * Removes and closes all instance bound dependencies.
 	 * This method is called when a component is destroyed.
 	 */



Mime
View raw message