felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1572732 - /felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java
Date Thu, 27 Feb 2014 21:07:31 GMT
Author: pderop
Date: Thu Feb 27 21:07:31 2014
New Revision: 1572732

URL: http://svn.apache.org/r1572732
Log:
Use varargs in add(Depedency) method in order to be able to optionally add many dependencies
atomically.

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=1572732&r1=1572731&r2=1572732&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 Thu
Feb 27 21:07:31 2014
@@ -4,6 +4,7 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Proxy;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -46,15 +47,21 @@ public class ComponentImpl implements Co
 	}
 	
 	@Override
-	public Component add(final Dependency d) {
+	public Component add(final Dependency[] dependencies) {
 		getExecutor().execute(new Runnable() {
 			@Override
 			public void run() {
-				DependencyContext dc = (DependencyContext) d;
-				m_dependencies.add(dc);
-				dc.add(ComponentImpl.this);
-				if (!(m_state == ComponentState.INACTIVE)) {
-					dc.setInstanceBound(true);
+				List<DependencyContext> instanceBoundDeps = new ArrayList();
+				for (Dependency d : dependencies) {
+					DependencyContext dc = (DependencyContext) d;
+					m_dependencies.add(dc);
+					dc.add(ComponentImpl.this);
+					if (!(m_state == ComponentState.INACTIVE)) {
+						dc.setInstanceBound(true);
+						instanceBoundDeps.add(dc);
+					}
+				}
+				for (DependencyContext dc : instanceBoundDeps) {
 					dc.start();
 				}
 				handleChange();



Mime
View raw message