felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1573384 - /felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java
Date Sun, 02 Mar 2014 22:42:35 GMT
Author: pderop
Date: Sun Mar  2 22:42:35 2014
New Revision: 1573384

URL: http://svn.apache.org/r1573384
Log:
invoke autoconfig and propagate changes when no transition is performed in the performTransition
method.

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java?rev=1573384&r1=1573383&r2=1573384&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java Sun
Mar  2 22:42:35 2014
@@ -22,11 +22,11 @@ import org.osgi.framework.ServiceRegistr
 import dm.Component;
 import dm.ComponentDeclaration;
 import dm.ComponentDependencyDeclaration;
+import dm.ComponentState;
 import dm.ComponentStateListener;
 import dm.Dependency;
 import dm.DependencyManager;
 import dm.context.ComponentContext;
-import dm.context.ComponentState;
 import dm.context.DependencyContext;
 
 public class ComponentImpl implements Component, ComponentContext, ComponentDeclaration {
@@ -207,6 +207,12 @@ public class ComponentImpl implements Co
 		while (performTransition(oldState, newState));
 	}
 	
+	public void propagateChange() {
+		if (m_registration != null) {
+            m_registration.setProperties(calculateServiceProperties());
+		}
+	}
+	
     public Component setAutoConfig(Class clazz, boolean autoConfig) {
         m_autoConfig.put(clazz, Boolean.valueOf(autoConfig));
         return this;
@@ -349,6 +355,21 @@ public class ComponentImpl implements Co
 			notifyListeners(newState);
 			return true;
 		}
+		
+		switch(m_state) {
+		case INSTANTIATED_AND_WAITING_FOR_REQUIRED:
+			invokeAutoConfigInstanceBoundDependencies();
+			break;
+			
+		case TRACKING_OPTIONAL:
+			invokeAutoConfigDependencies();
+			if (hasSomePropagateDependencies()) {
+				propagateChange();
+			}
+			break;
+		default:
+		}
+		
 		return false;
 	}
 	
@@ -392,6 +413,16 @@ public class ComponentImpl implements Co
             m_registration = null;
         }
     }
+    
+    private boolean hasSomePropagateDependencies() {
+		for (int i = 0; i < m_dependencies.size(); i++) {
+			DependencyContext d = (DependencyContext) m_dependencies.get(i);
+			if (d.isPropagated()) {
+				return true;
+			}
+		}
+		return false;
+    }
 
     private Dictionary calculateServiceProperties() {
 		Dictionary properties = new Properties();



Mime
View raw message