Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work for 1911 #147

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions osgi/src/main/java/org/killbill/billing/osgi/BundleRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ private void stopAndUninstallBundle(final Bundle bundle, final String pluginName
}

public void startBundles(final Iterable<String> mandatoryPlugins) throws Exception {
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 @@ -115,16 +114,17 @@ public void startBundles(final Iterable<String> mandatoryPlugins) throws Excepti

}

if (mandatoryPlugins.iterator().hasNext()) {
checkIfMandatoryPluginsAreStarted(pluginsStarted, mandatoryPlugins);
}
else {
log.info("Mandatory plugins not specified, skipping mandatory plugins check");
}

checkIfMandatoryPluginsAreStarted(pluginsStarted, mandatoryPlugins);
}

private void checkIfMandatoryPluginsAreStarted(final List<String> pluginsStarted, final Iterable<String> mandatoryPlugins) throws Exception {
log.info("List of mandatory plugins: {}", mandatoryPlugins);

if (mandatoryPlugins == null || !mandatoryPlugins.iterator().hasNext()) {
log.info("Mandatory plugins not specified, skipping mandatory plugins check");
return;
}

for (final String pluginName : mandatoryPlugins) {
if (!pluginsStarted.contains(pluginName)) {
log.warn("Mandatory plugin {} not started", pluginName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ public void initialize() {

@LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.START_PLUGIN)
public void start() throws Exception {
final String mandatoryPlugins = osgiConfig.getMandatoryPluginsList();
final Set<String> mandatoryPluginsList = mandatoryPlugins != null && !mandatoryPlugins.isEmpty() ? Set.of(mandatoryPlugins.split("\\s*,\\s*")) : Collections.emptySet();
final Set<String> mandatoryPlugins = osgiConfig.getMandatoryPlugins();
// This will call the start() method for the bundles
bundleRegistry.startBundles(mandatoryPluginsList);
bundleRegistry.startBundles(mandatoryPlugins);
// Tell the plugins all bundles have started
killbillActivator.sendEvent("org/killbill/billing/osgi/lifecycle/STARTED", new HashMap<String, String>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@

package org.killbill.billing.osgi.config;

import java.util.Set;

import org.killbill.billing.platform.api.KillbillPlatformConfig;
import org.skife.config.Config;
import org.skife.config.Default;
import org.skife.config.DefaultNull;
import org.skife.config.Description;

public interface OSGIConfig extends KillbillPlatformConfig {
Expand Down Expand Up @@ -268,8 +271,8 @@ public interface OSGIConfig extends KillbillPlatformConfig {
public String getSystemBundleExportPackagesExtra();

@Config("org.killbill.billing.plugin.mandatory.plugins")
@Description("List of mandatory plugins")
@Default("")
public String getMandatoryPluginsList();
@Description("Comma separated list of mandatory plugins")
@DefaultNull
public Set<String> getMandatoryPlugins();

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -211,7 +212,7 @@ public String getSystemBundleExportPackagesExtra() {
return null;
}
@Override
public String getMandatoryPluginsList() {
public Set<String> getMandatoryPlugins() {
return null;
}

Expand Down
Loading