Added startImpl to provide BundleContext to providers 66/966/1
authorTony Tkacik <ttkacik@cisco.com>
Thu, 22 Aug 2013 15:23:37 +0000 (17:23 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Thu, 22 Aug 2013 15:24:18 +0000 (17:24 +0200)
Change-Id: Id92b7c469ffa6da22745854fc5d58862f232d6a2
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java
opendaylight/sal/yang-prototype/sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/impl/ToastConsumerImpl.java
opendaylight/sal/yang-prototype/sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterProvider.java

index b90bd23..a176664 100644 (file)
@@ -11,9 +11,13 @@ public abstract class AbstractBindingAwareConsumer implements BindingAwareConsum
         ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
         BindingAwareBroker broker = context.getService(brokerRef);
         broker.registerConsumer(this, context);
+        startImpl(context);
         //context.ungetService(brokerRef);
     }
 
+    @Deprecated
+    abstract protected void startImpl(BundleContext context);
+    
     @Override
     public final  void stop(BundleContext context) throws Exception {
         // TODO Auto-generated method stub
index dbdedc3..20a7c0d 100644 (file)
@@ -11,8 +11,12 @@ public abstract class AbstractBindingAwareProvider implements BindingAwareProvid
             ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
             BindingAwareBroker broker = context.getService(brokerRef);
             broker.registerProvider(this, context);
+            startImpl(context);
     }
-
+    
+    @Deprecated
+    abstract protected void startImpl(BundleContext context);
+    
     @Override
     public final void stop(BundleContext context) throws Exception {
             
index 0a73110..3fc9b0d 100644 (file)
@@ -64,6 +64,12 @@ public class ToastConsumerImpl extends AbstractBindingAwareConsumer implements B
         return false;
 
     }
+    
+    @Override
+    @Deprecated
+    protected void startImpl(BundleContext context) {
+        context.registerService(ToastConsumer.class, this, new Hashtable<String,String>());
+    }
 
     @Override
     public void onSessionInitialized(ConsumerContext session) {
index c776f36..7b5af8f 100644 (file)
@@ -56,4 +56,11 @@ public class ToasterProvider extends AbstractBindingAwareProvider {
        public Collection<? extends ProviderFunctionality> getFunctionality() {
                return Collections.emptySet();
        }
+       
+       @Override
+       @Deprecated
+       protected void startImpl(BundleContext context) {
+           // TODO Auto-generated method stub
+           
+       }
 }