Skip to content

Commit

Permalink
Changes as per review comments - Round 1
Browse files Browse the repository at this point in the history
  • Loading branch information
reshmabidikar committed Nov 22, 2023
1 parent e4c6ae0 commit 88861bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions osgi/src/main/java/org/killbill/billing/osgi/BundleRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ private void stopAndUninstallBundle(final Bundle bundle, final String pluginName
registry.remove(pluginName);
}

public void startBundles(final List<String> mandatoryPlugins) {
log.info("List of mandatory plugins: {}",mandatoryPlugins);
public void startBundles(final Iterable<String> mandatoryPlugins) {
log.info("List of mandatory plugins: {}", mandatoryPlugins);
final List<String> pluginsStarted = new LinkedList<>();
for (final BundleWithConfig bundleWithConfig : bundleWithConfigs) {
final boolean isBundleStarted = fileInstall.startBundle(bundleWithConfig.getBundle());
Expand All @@ -116,7 +116,7 @@ public void startBundles(final List<String> mandatoryPlugins) {

}

if (!mandatoryPlugins.isEmpty()) {
if (mandatoryPlugins.iterator().hasNext()) {
checkIfMandatoryPluginsAreStarted(pluginsStarted, mandatoryPlugins);
}
else {
Expand All @@ -125,15 +125,15 @@ public void startBundles(final List<String> mandatoryPlugins) {

}

private void checkIfMandatoryPluginsAreStarted(List<String> pluginsStarted, List<String> mandatoryPlugins){
private void checkIfMandatoryPluginsAreStarted(final List<String> pluginsStarted, final Iterable<String> mandatoryPlugins){
boolean allMandatoryPluginsStarted = true;
for (String pluginName: mandatoryPlugins) {
if(!pluginsStarted.contains(pluginName)) {
log.error("Mandatory plugin {} not started",pluginName); //TODO_1911 - Exit here?
log.error("Mandatory plugin {} not started", pluginName); //TODO_1911 - Exit here?
allMandatoryPluginsStarted = false;
}
}
if(allMandatoryPluginsStarted) {
if (allMandatoryPluginsStarted) {
log.info("All mandatory plugins are started");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.inject.Inject;
import javax.inject.Named;
Expand Down Expand Up @@ -100,7 +101,7 @@ public void initialize() {
@LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.START_PLUGIN)
public void start() {
final String mandatoryPlugins = osgiConfig.getMandatoryPluginsList();
final List<String> mandatoryPluginsList = mandatoryPlugins != null && !mandatoryPlugins.isEmpty() ? List.of(mandatoryPlugins.split(",")) : Collections.emptyList();
final Set<String> mandatoryPluginsList = mandatoryPlugins != null && !mandatoryPlugins.isEmpty() ? Set.of(mandatoryPlugins.split("\\s*,\\s*")) : Collections.emptySet();
// This will call the start() method for the bundles
bundleRegistry.startBundles(mandatoryPluginsList);
// Tell the plugins all bundles have started
Expand Down

0 comments on commit 88861bc

Please sign in to comment.