Skip to content

Commit

Permalink
fix(configuration): add Configuration Consumer for UserConfigService (#…
Browse files Browse the repository at this point in the history
…2198)

* add Configuration Consumer for UserConfigService

* fix autowired ConnectionAdapter bean
  • Loading branch information
PeachThinking authored Apr 12, 2024
1 parent 5e54cf2 commit 9c17497
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ConnectionTestingTest {
@Mock
private ConnectionSSLAdaptor sslAdaptor;
@Mock
private DefaultConnectionAdapter environmentAdapter;
private ConnectionAdapter environmentAdapter;

@Before
public void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;
Expand Down Expand Up @@ -59,6 +60,18 @@ public class UserConfigService {
.maximumSize(500).expireAfterWrite(60, TimeUnit.SECONDS)
.build(this::internalGetUserConfigurations);

private List<Consumer<Configuration>> configurationConsumers = new ArrayList<>();

@SkipAuthorize("odc internal usage")
public void addConfigurationConsumer(Consumer<Configuration> consumer) {
this.configurationConsumers.add(consumer);
}

@SkipAuthorize("odc internal usage")
public List<Consumer<Configuration>> getConfigurationConsumer() {
return this.configurationConsumers;
}

@PostConstruct
public void init() {
List<ConfigurationMeta> allConfigMetas = userConfigMetaService.listAllConfigMetas();
Expand Down Expand Up @@ -96,6 +109,9 @@ public List<Configuration> listUserConfigurations(@NotNull Long userId) {
if (keyToConfiguration.containsKey(configuration.getKey())) {
configuration.setValue(keyToConfiguration.get(configuration.getKey()).getValue());
}
for (Consumer<Configuration> consumer : getConfigurationConsumer()) {
consumer.accept(configuration);
}
}
return configurations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public class ConnectionService {
private ConnectProperties connectProperties;

@Autowired
private DefaultConnectionAdapter environmentAdapter;
private ConnectionAdapter environmentAdapter;

@Autowired
private ConnectionSSLAdaptor connectionSSLAdaptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class ConnectionTesting {
@Autowired
private ConnectProperties connectProperties;
@Autowired
private DefaultConnectionAdapter environmentAdapter;
private ConnectionAdapter environmentAdapter;
@Autowired
private ConnectionSSLAdaptor connectionSSLAdaptor;
@Autowired
Expand Down

0 comments on commit 9c17497

Please sign in to comment.