[SEBA-593] Register listener to optional services

Change-Id: Iea408beb46b7a027518d52a93be94624c430f77b
diff --git a/app.xml b/app.xml
index 4038c44..586cbd8 100644
--- a/app.xml
+++ b/app.xml
@@ -20,5 +20,9 @@
      features="${project.artifactId}" apps="">
     <description>${project.description}</description>
     <artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
+    <artifact>mvn:${project.groupId}/aaa-api/${aaa.api.version}</artifact>
+    <artifact>mvn:${project.groupId}/dhcpl2relay-api/${dhcpl2relay.api.version}</artifact>
+    <artifact>mvn:${project.groupId}/olt-api/${olt.api.version}</artifact>
+    <artifact>mvn:${project.groupId}/sadis-api/${sadis.api.version}</artifact>
     <artifact>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/1.1.1_1</artifact>
 </app>
diff --git a/features.xml b/features.xml
index 2ce58dd..70492f0 100644
--- a/features.xml
+++ b/features.xml
@@ -19,6 +19,10 @@
              description="${project.description}">
         <feature>onos-api</feature>
         <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/aaa-api/${aaa.api.version}</bundle>
+        <bundle>mvn:${project.groupId}/dhcpl2relay-api/${dhcpl2relay.api.version}</bundle>
+        <bundle>mvn:${project.groupId}/olt-api/${olt.api.version}</bundle>
+        <bundle>mvn:${project.groupId}/sadis-api/${sadis.api.version}</bundle>
         <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/1.1.1_1</bundle>
     </feature>
 </features>
diff --git a/pom.xml b/pom.xml
index 6704176..648f1c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,7 @@
         <aaa.api.version>1.9.0-SNAPSHOT</aaa.api.version>
         <olt.api.version>3.0.1-SNAPSHOT</olt.api.version>
         <dhcpl2relay.api.version>1.6.0-SNAPSHOT</dhcpl2relay.api.version>
+        <sadis.api.version>3.1.0-SNAPSHOT</sadis.api.version>
     </properties>
 
     <dependencies>
@@ -74,26 +75,22 @@
 
         <dependency>
             <groupId>org.opencord</groupId>
-            <artifactId>aaa</artifactId>
+            <artifactId>aaa-api</artifactId>
             <version>${aaa.api.version}</version>
-            <optional>true</optional>
         </dependency>
 
         <dependency>
             <groupId>org.opencord</groupId>
             <artifactId>olt-api</artifactId>
             <version>${olt.api.version}</version>
-            <optional>true</optional>
         </dependency>
 
         <dependency>
             <groupId>org.opencord</groupId>
-            <artifactId>dhcpl2relay</artifactId>
+            <artifactId>dhcpl2relay-api</artifactId>
             <version>${dhcpl2relay.api.version}</version>
-            <optional>true</optional>
         </dependency>
 
-
     </dependencies>
 
     <build>
diff --git a/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java b/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java
index a09cb41..316032e 100644
--- a/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java
+++ b/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java
@@ -24,6 +24,7 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.device.DeviceService;
 import org.opencord.aaa.AuthenticationEvent;
@@ -50,6 +51,7 @@
     protected DeviceService deviceService;
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+            policy = ReferencePolicy.DYNAMIC,
             bind = "bindAuthenticationService",
             unbind = "unbindAuthenticationService")
     protected AuthenticationService authenticationService;
@@ -65,6 +67,7 @@
     private static final String AUTHENTICATION_STATE = "authenticationState";
 
     protected void bindAuthenticationService(AuthenticationService authenticationService) {
+        log.info("bindAuthenticationService");
         if (this.authenticationService == null) {
             log.info("Binding AuthenticationService");
             this.authenticationService = authenticationService;
@@ -76,6 +79,7 @@
     }
 
     protected void unbindAuthenticationService(AuthenticationService authenticationService) {
+        log.info("unbindAuthenticationService");
         if (this.authenticationService == authenticationService) {
             log.info("Unbinding AuthenticationService");
             this.authenticationService = null;
@@ -88,12 +92,12 @@
 
     @Activate
     public void activate() {
-        log.info("Started");
+        log.info("Started AaaKafkaIntegration");
     }
 
     @Deactivate
     public void deactivate() {
-        log.info("Stopped");
+        log.info("Stopped AaaKafkaIntegration");
     }
 
     private void handle(AuthenticationEvent event) {
diff --git a/src/main/java/org/opencord/kafka/integrations/AccessDeviceKafkaIntegration.java b/src/main/java/org/opencord/kafka/integrations/AccessDeviceKafkaIntegration.java
index 8dddb78..36954ad 100644
--- a/src/main/java/org/opencord/kafka/integrations/AccessDeviceKafkaIntegration.java
+++ b/src/main/java/org/opencord/kafka/integrations/AccessDeviceKafkaIntegration.java
@@ -24,6 +24,7 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.Port;
 import org.opencord.kafka.EventBusService;
@@ -46,6 +47,7 @@
     protected EventBusService eventBusService;
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+            policy = ReferencePolicy.DYNAMIC,
             bind = "bindAccessDeviceService",
             unbind = "unbindAccessDeviceService")
     protected AccessDeviceService accessDeviceService;
@@ -89,12 +91,12 @@
 
     @Activate
     public void activate() {
-        log.info("Started");
+        log.info("Started AccessDeviceKafkaIntegration");
     }
 
     @Deactivate
     public void deactivate() {
-        log.info("Stopped");
+        log.info("Stopped AccessDeviceKafkaIntegration");
     }
 
     private void handle(AccessDeviceEvent event, String status) {
diff --git a/src/main/java/org/opencord/kafka/integrations/DhcpL2RelayKafkaIntegration.java b/src/main/java/org/opencord/kafka/integrations/DhcpL2RelayKafkaIntegration.java
index 867bcfe..e1ca65a 100644
--- a/src/main/java/org/opencord/kafka/integrations/DhcpL2RelayKafkaIntegration.java
+++ b/src/main/java/org/opencord/kafka/integrations/DhcpL2RelayKafkaIntegration.java
@@ -24,6 +24,7 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.device.DeviceService;
 import org.opencord.dhcpl2relay.DhcpAllocationInfo;
@@ -51,6 +52,7 @@
     protected DeviceService deviceService;
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+            policy = ReferencePolicy.DYNAMIC,
             bind = "bindDhcpL2RelayService",
             unbind = "unbindDhcpL2RelayService")
     protected DhcpL2RelayService dhcpL2RelayService;
@@ -92,12 +94,12 @@
 
     @Activate
     public void activate() {
-        log.info("Started");
+        log.info("Started DhcpL2RelayKafkaIntegration");
     }
 
     @Deactivate
     public void deactivate() {
-        log.info("Stopped");
+        log.info("Stopped DhcpL2RelayKafkaIntegration");
     }
 
     private void handle(DhcpL2RelayEvent event) {