Thomas Vachuska

Fixing cyclic component dependency issue.

Change-Id: I7951df92b4a81f09f8ec3c1ae376a7d1125655df
......@@ -119,15 +119,36 @@ public class DistributedClusterStore
@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;
@Activate
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
/**
* 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());
}
}
modified(context);
/**
* 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() {
localNode = clusterMetadataService.getLocalNode();
messagingService.registerHandler(HEARTBEAT_MESSAGE,
......@@ -143,7 +164,6 @@ public class DistributedClusterStore
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
messagingService.unregisterHandler(HEARTBEAT_MESSAGE);
heartBeatSender.shutdownNow();
heartBeatMessageHandler.shutdownNow();
......
......@@ -29,7 +29,7 @@ public class DistributedClusterStoreTest {
@Before
public void setUp() throws Exception {
distributedClusterStore = new DistributedClusterStore();
distributedClusterStore.activate(null);
distributedClusterStore.activate();
}
@After
......