[SEBA-532] Removing dependencies on aaa, olt and dhcpl2realy from kafka

Change-Id: I3fc8dc497b71e6a4d88ad049f0b322a3830ea279
diff --git a/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java b/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java
index e68e307..6db44cb 100644
--- a/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java
+++ b/src/main/java/org/opencord/kafka/integrations/AaaKafkaIntegration.java
@@ -44,7 +44,9 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected EventBusService eventBusService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+            bind = "bindAuthenticationService",
+            unbind = "unbindAuthenticationService")
     protected AuthenticationService authenticationService;
 
     private final AuthenticationEventListener listener = new InternalAuthenticationListener();
@@ -56,15 +58,35 @@
     private static final String PORT_NUMBER = "portNumber";
     private static final String AUTHENTICATION_STATE = "authenticationState";
 
+    protected void bindAuthenticationService(AuthenticationService authenticationService) {
+        if (this.authenticationService == null) {
+            log.info("Binding AuthenticationService");
+            this.authenticationService = authenticationService;
+            log.info("Adding listener on AuthenticationService");
+            authenticationService.addListener(listener);
+        } else {
+            log.warn("Trying to bind AuthenticationService but it is already bound");
+        }
+    }
+
+    protected void unbindAuthenticationService(AuthenticationService authenticationService) {
+        if (this.authenticationService == authenticationService) {
+            log.info("Unbinding AuthenticationService");
+            this.authenticationService = null;
+            log.info("Removing listener on AuthenticationService");
+            authenticationService.removeListener(listener);
+        } else {
+            log.warn("Trying to unbind AuthenticationService but it is already unbound");
+        }
+    }
+
     @Activate
     public void activate() {
-        authenticationService.addListener(listener);
         log.info("Started");
     }
 
     @Deactivate
     public void deactivate() {
-        authenticationService.removeListener(listener);
         log.info("Stopped");
     }