Skip to content

Commit

Permalink
Add DelegatingConfigService
Browse files Browse the repository at this point in the history
Allows for switches between static and dynamic config services without having to change UIDOperatorVerticle
  • Loading branch information
BehnamMozafari committed Jan 6, 2025
1 parent 6bd4a35 commit 80b6b19
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.uid2.operator.service;

import io.vertx.core.json.JsonObject;

import java.util.concurrent.atomic.AtomicReference;

public class DelegatingConfigService implements IConfigService{
private AtomicReference<IConfigService> activeConfigService;

public DelegatingConfigService(IConfigService initialConfigService) {
this.activeConfigService = new AtomicReference<>(initialConfigService);
}

public void updateConfigService(IConfigService newConfigService) {
this.activeConfigService = new AtomicReference<>(newConfigService);
}

@Override
public JsonObject getConfig() {
return activeConfigService.get().getConfig();
}
}

0 comments on commit 80b6b19

Please sign in to comment.