felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r758767 - in /felix/trunk/ipojo: composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ core/src/main/java/org/apache/felix/ipojo/util/ tests/core/servic...
Date Thu, 26 Mar 2009 17:41:00 GMT
Author: clement
Date: Thu Mar 26 17:40:07 2009
New Revision: 758767

URL: http://svn.apache.org/viewvc?rev=758767&view=rev
Log:
Fix issue Felix-1002
Static binding policy now stop the entire instance and restart it when the dependency is broken.
POJO objects are lost, and service tracking is reinitialized (this means that services may
be injected in a different order).

Modified:
    felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java
    felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
    felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml
    felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java
    felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java
    felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java
    felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java

Modified: felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java
(original)
+++ felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java
Thu Mar 26 17:40:07 2009
@@ -190,6 +190,13 @@
     public void freeze() {
         m_isFrozen = true;
     }
+    
+    /**
+     * Unfreezes.
+     */
+    public void unfreeze() {
+        m_isFrozen = false;
+    }
 
     public boolean isFrozen() {
         return m_isFrozen;

Modified: felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
(original)
+++ felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
Thu Mar 26 17:40:07 2009
@@ -124,6 +124,14 @@
     public void freeze() {
         m_isFrozen = true;
     }
+    
+    /**
+     * Unfreezes.
+     */
+    public void unfreeze() {
+        m_isFrozen = false;
+    }
+
 
     /**
      * Create an instance for the given reference. The instance is not added inside the map.

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
(original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
Thu Mar 26 17:40:07 2009
@@ -202,6 +202,14 @@
     public synchronized boolean isFrozen() {
         return m_isFrozen;
     }
+    
+    /**
+     * Unfreeze the dependency.
+     * @see org.apache.felix.ipojo.util.DependencyModel#unfreeze()
+     */
+    public synchronized void unfreeze() {
+        m_isFrozen = false;
+    }
 
     /**
      * Call the bind method.

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
(original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
Thu Mar 26 17:40:07 2009
@@ -201,6 +201,7 @@
      * @see DependencyModel#computeDependencyState()
      */
     public void start() {
+        m_state = UNRESOLVED;
         m_tracker = new Tracker(m_context, m_specification.getName(), this);
         m_tracker.open();
         computeDependencyState();
@@ -216,6 +217,7 @@
             m_tracker.close();
             m_tracker = null;
         }
+        m_matchingRefs.clear();
         ungetAllServices();
         m_state = UNRESOLVED;
     }
@@ -253,6 +255,16 @@
     public boolean isFrozen() {
         return false;
     }
+    
+    
+    /**
+     * Unfreezes the dependency.
+     * This method must be overide by concrete dependency to support
+     * the static binding policy. This method is called after tracking restarting.
+     */
+    public void unfreeze() {
+        // nothing to do
+    }
 
     /**
      * Does the service reference match ? This method must be override by
@@ -353,7 +365,6 @@
      * @param ref the new reference
      */
     private void manageArrival(ServiceReference ref) {
-
         // Create a local copy of the state and of the list size.
         int state = m_state;
         int size;
@@ -427,7 +438,15 @@
         if (isFrozen() && obj != null) {
             if (m_state != BROKEN) {
                 m_state = BROKEN;
-                invalidate();
+                invalidate();  // This will invalidate the instance.
+                // Reinitialize the dependency tracking
+                ComponentInstance instance = null;
+                synchronized (this) {
+                    instance = m_instance;
+                }
+                instance.stop(); // Stop the instance
+                unfreeze();
+                instance.start();
             }
         } else {
             synchronized (this) {

Modified: felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml (original)
+++ felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml Thu Mar 26 17:40:07
2009
@@ -99,6 +99,22 @@
 					<target>1.4</target>
 				</configuration>
 			</plugin>
+			<!--<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-junit4osgi-plugin 
+				</artifactId>
+				<version>1.1.0-SNAPSHOT</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>test</goal>
+						</goals>
+						<configuration>
+							<hideOutputs>false</hideOutputs>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>-->
 		</plugins>
 	</build>
 </project>

Modified: felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java
(original)
+++ felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java
Thu Mar 26 17:40:07 2009
@@ -99,6 +99,7 @@
 		
 		fooProvider.stop();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
 		
@@ -136,6 +137,7 @@
 		
 		fooProvider.stop();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
 		
@@ -173,6 +175,7 @@
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance5.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
         

Modified: felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java
(original)
+++ felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java
Thu Mar 26 17:40:07 2009
@@ -108,6 +108,7 @@
 		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(),
1.0);
 		
 		fooProvider2.start();
+		Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
 		
@@ -126,9 +127,10 @@
 		assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(),
1.0);
 		
 		fooProvider1.stop();
-		
+		// instance is stopped and then restarted, so bound to fooprovider 2.
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID); 
 		
 		id = null;
 		cs = null;
@@ -182,9 +184,10 @@
         assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(),
1.0);
 
         fooProvider1.stop();
-
+        
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
 
         id = null;
         cs = null;
@@ -238,9 +241,10 @@
         assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(),
1.0);
 
         fooProvider1.stop();
-
+        // Instance stopped and then restarted, bound to foo provider 2.
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
 
         id = null;
         cs = null;
@@ -294,9 +298,10 @@
         assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(),
1.0);
 
         fooProvider1.stop();
-
+        // Stop and then restarted, bound to foo provider 2.
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
 
         id = null;
         cs = null;

Modified: felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java
(original)
+++ felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java
Thu Mar 26 17:40:07 2009
@@ -81,7 +81,7 @@
 		fooProvider = null;
 	}
 	
-	public void atestSimple() {
+	public void testSimple() {
 		ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
 		assertNotNull("Check architecture availability", arch_ref);
 		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
@@ -107,6 +107,7 @@
 		
 		fooProvider.start();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
 		
@@ -129,6 +130,7 @@
 		
 		fooProvider.stop();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
 		
@@ -138,7 +140,7 @@
 		getContext().ungetService(cs_ref);		
 	}
 	
-	public void atestDelayedSimple() throws UnacceptableConfiguration, MissingHandlerException,
ConfigurationException {
+	public void testDelayedSimple() throws UnacceptableConfiguration, MissingHandlerException,
ConfigurationException {
 	    instance1.stop();
 	    fooProvider.start();
 	    instance1.start();
@@ -167,9 +169,9 @@
         assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(),
1.0);
         
         fooProvider.stop();
-        
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
// Dependency broken
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
// Dependency broken,re started with no service.
         
         id = null;
         cs = null;
@@ -177,7 +179,7 @@
         getContext().ungetService(cs_ref);       
     }
 	
-	public void atestVoid() {
+	public void testVoid() {
 		ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
 		assertNotNull("Check architecture availability", arch_ref);
 		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
@@ -202,6 +204,7 @@
 		
 		fooProvider.start();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
 		
@@ -223,6 +226,7 @@
 		
 		fooProvider.stop();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
 		
@@ -276,9 +280,11 @@
         assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(),
1.0);
         
         fooProvider.stop();
+        // The instance is restarted.
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() ==
ComponentInstance.INVALID); // Dependency broken
+        assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() ==
ComponentInstance.VALID); // Dependency broken and then (no service injected) restarted
         
         id = null;
         cs = null;
@@ -286,7 +292,7 @@
         getContext().ungetService(cs_ref);       
     }
 	
-	public void atestObject() {
+	public void testObject() {
 		ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
 		assertNotNull("Check architecture availability", arch_ref);
 		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
@@ -307,6 +313,7 @@
 		
 		fooProvider.start();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
 		
@@ -324,6 +331,7 @@
 		
 		fooProvider.stop();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
 		
@@ -344,7 +352,7 @@
 		getContext().ungetService(cs_ref);		
 	}
 	
-	public void atestDelayedObject() throws UnacceptableConfiguration, MissingHandlerException,
ConfigurationException {
+	public void testDelayedObject() throws UnacceptableConfiguration, MissingHandlerException,
ConfigurationException {
         instance3.stop();
         fooProvider.start();
         instance3.start();
@@ -374,8 +382,9 @@
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
// Dependency broken
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
// Dependency broken and restarted with no service
         
         id = null;
         cs = null;

Modified: felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java?rev=758767&r1=758766&r2=758767&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java
(original)
+++ felix/trunk/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java
Thu Mar 26 17:40:07 2009
@@ -24,11 +24,10 @@
 import org.apache.felix.ipojo.architecture.Architecture;
 import org.apache.felix.ipojo.architecture.InstanceDescription;
 import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
 import org.apache.felix.ipojo.test.scenarios.util.Utils;
 import org.osgi.framework.ServiceReference;
 
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
 public class SimpleDependencies extends OSGiTestCase {
 	
 	ComponentInstance instance1, instance2, instance3, instance4, instance5;
@@ -98,22 +97,29 @@
 		assertTrue("check CheckService invocation", cs.check());
 		
 		fooProvider.stop();
+		// instance1 has to be stopped and restarted.
+
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
 		
 		fooProvider.start();
 		
+	    arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.INVALID);
+		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID); //
The instance was invalidated and revalidated.
 		
 		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
-		assertNull("Check CheckService availability", cs_ref);
+		assertNotNull("Check CheckService availability", cs_ref);
+		cs = (CheckService) getContext().getService(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
 		
 		fooProvider.stop();
 		
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance1.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
+		assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
 		
 		id = null;
 		cs = null;
@@ -148,20 +154,23 @@
         assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(),
0);
         
 		fooProvider.stop();
-		
+        
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
 		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
 		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
 		
 		fooProvider.start();
         
+		arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.INVALID);
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
// The instance was revalidated.
         
         cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(),
instance2.getInstanceName());
-        assertNull("Check CheckService availability - 2", cs_ref);
+        assertNotNull("Check CheckService availability - 2", cs_ref);
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance2.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
 		
@@ -198,19 +207,22 @@
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
         
         fooProvider.start();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.INVALID);
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
         
         cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(),
instance3.getInstanceName());
-        assertNull("Check CheckService availability - 2", cs_ref);
+        assertNotNull("Check CheckService availability - 2", cs_ref);
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance3.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
         
@@ -247,19 +259,23 @@
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
         
         fooProvider.start();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.INVALID);
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+        
         
         cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(),
instance4.getInstanceName());
-        assertNull("Check CheckService availability - 2", cs_ref);
+        assertNotNull("Check CheckService availability - 2", cs_ref);
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
         
@@ -296,19 +312,22 @@
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
         
         fooProvider.start();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.INVALID);
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
         
         cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(),
instance5.getInstanceName());
-        assertNull("Check CheckService availability - 2", cs_ref);
+        assertNotNull("Check CheckService availability - 2", cs_ref);
         
         fooProvider.stop();
         
+        arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(),
instance4.getInstanceName());
         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
         assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
         



Mime
View raw message