Fixing cyclic component dependency issue.

Change-Id: I7951df92b4a81f09f8ec3c1ae376a7d1125655df
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java
index e911b22..97db574 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java
@@ -119,15 +119,36 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected MessagingService messagingService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    // This must be optional to avoid a cyclic dependency
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
     protected ComponentConfigService cfgService;
 
+    /**
+     * Hook for wiring up optional reference to a service.
+     *
+     * @param service service being announced
+     */
+    protected void bindComponentConfigService(ComponentConfigService service) {
+        if (cfgService == null) {
+            cfgService = service;
+            cfgService.registerProperties(getClass());
+        }
+    }
+
+    /**
+     * Hook for unwiring optional reference to a service.
+     *
+     * @param service service being withdrawn
+     */
+    protected void unbindComponentConfigService(ComponentConfigService service) {
+        if (cfgService == service) {
+            cfgService.unregisterProperties(getClass(), false);
+            cfgService = null;
+        }
+    }
+
     @Activate
-    public void activate(ComponentContext context) {
-        cfgService.registerProperties(getClass());
-
-        modified(context);
-
+    public void activate() {
         localNode = clusterMetadataService.getLocalNode();
 
         messagingService.registerHandler(HEARTBEAT_MESSAGE,
@@ -143,7 +164,6 @@
 
     @Deactivate
     public void deactivate() {
-        cfgService.unregisterProperties(getClass(), false);
         messagingService.unregisterHandler(HEARTBEAT_MESSAGE);
         heartBeatSender.shutdownNow();
         heartBeatMessageHandler.shutdownNow();
diff --git a/core/store/dist/src/test/java/org/onosproject/store/cluster/impl/DistributedClusterStoreTest.java b/core/store/dist/src/test/java/org/onosproject/store/cluster/impl/DistributedClusterStoreTest.java
index 418359e..47d21cb 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/cluster/impl/DistributedClusterStoreTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/cluster/impl/DistributedClusterStoreTest.java
@@ -29,7 +29,7 @@
     @Before
     public void setUp() throws Exception {
         distributedClusterStore = new DistributedClusterStore();
-        distributedClusterStore.activate(null);
+        distributedClusterStore.activate();
     }
 
     @After