Fixed bug when SAL Proxy service was not returned to the consumer 80/2080/3
authorTony Tkacik <ttkacik@cisco.com>
Tue, 22 Oct 2013 15:53:14 +0000 (17:53 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 23 Oct 2013 00:39:55 +0000 (00:39 +0000)
Change-Id: I5ba2e330c86925e8e893734a7f5b64ca1eb4c1e4
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend
opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java

index 740ae88..bd7f25c 100644 (file)
@@ -199,6 +199,8 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
 
         // Updating internal structure of registration
         routingTable.updateRoute(path, registration.instance)
+        // Update routing table / send announce to message bus
+        
         val success = paths.put(context, path);
     }
 
@@ -231,6 +233,11 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
 
         }
     }
+    
+    def createDelegate(Class<? extends RpcService> type) {
+        getManagedDirectProxy(type);
+    }
+    
 }
 
 class RoutedRpcRegistrationImpl<T extends RpcService> extends AbstractObjectRegistration<T> implements RoutedRpcRegistration<T> {
index a903124..bc53108 100644 (file)
@@ -44,6 +44,9 @@ class OsgiConsumerContext implements ConsumerContext {
             if (false == services.empty) {
                 val ref = services.iterator().next() as ServiceReference<T>;
                 return bundleContext.getService(ref) as T;
+            } else {
+                broker.createDelegate(module);
+                return getRpcService(module);
             }
         } catch (InvalidSyntaxException e) {
             log.error("Created filter was invalid:", e.message, e)
index f83b600..d8031e5 100644 (file)
@@ -37,10 +37,9 @@ public class ToasterTest {
     @Test
     public void properInitialized() throws Exception {
 
-        Collection<ServiceReference<ToasterService>> references = ctx.getServiceReferences(ToasterService.class, null);
-        assertEquals(2, references.size());
+        Thread.sleep(500); // Waiting for services to get wired.
 
-        consumer.createToast(WhiteBread.class, 5);
+        assertTrue(consumer.createToast(WhiteBread.class, 5));
 
     }