summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-07-08 23:22:02 +0200
committergjoranv <gv@verizonmedia.com>2020-07-15 12:51:54 +0200
commit72eb7a8938f60b6c3c7a562673514414bcb1b106 (patch)
treed8ea219e9bf4d63179c213491afd5a8b7bac9f2b /container-core
parentf832e4330d5452e228659d7d2b55cf992e6550d0 (diff)
Separate installation for platform and application bundles.
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java12
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleInstaller.java47
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java3
3 files changed, 60 insertions, 2 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
index b983cbcfe37..1011e4ef719 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
@@ -102,11 +102,15 @@ public class HandlersConfigurerDi {
private final OsgiFramework osgiFramework;
private final BundleManager bundleManager;
+ private final PlatformBundleInstaller platformBundleInstaller;
public ContainerAndDiOsgi(OsgiFramework osgiFramework) {
super(osgiFramework);
this.osgiFramework = osgiFramework;
- bundleManager = new BundleManager(new OsgiImpl(osgiFramework));
+
+ OsgiImpl osgi = new OsgiImpl(osgiFramework);
+ bundleManager = new BundleManager(osgi);
+ platformBundleInstaller = new PlatformBundleInstaller(osgi);
}
@@ -131,6 +135,12 @@ public class HandlersConfigurerDi {
}
@Override
+ public void installPlatformBundles(Collection<FileReference> bundles) {
+ log.fine("Installing platform bundles.");
+ platformBundleInstaller.install(bundles);
+ }
+
+ @Override
public Set<Bundle> useBundles(Collection<FileReference> bundles) {
log.info("Installing bundles from the latest application");
return bundleManager.use(new ArrayList<>(bundles));
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleInstaller.java b/container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleInstaller.java
new file mode 100644
index 00000000000..848930932fd
--- /dev/null
+++ b/container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleInstaller.java
@@ -0,0 +1,47 @@
+package com.yahoo.container.core.config;
+
+import com.yahoo.config.FileReference;
+import com.yahoo.osgi.Osgi;
+import org.osgi.framework.Bundle;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+/**
+ * Installs all platform bundles, using the {@link DiskBundleInstaller}.
+ * All platform bundles reside on disk, and they are never uninstalled.
+ *
+ * @author gjoranv
+ */
+// TODO: rename to ...Loader or ...Manager
+public class PlatformBundleInstaller {
+ private static final Logger log = Logger.getLogger(PlatformBundleInstaller.class.getName());
+
+ private final Osgi osgi;
+ private final DiskBundleInstaller installer;
+
+ public PlatformBundleInstaller(Osgi osgi) {
+ this.osgi = osgi;
+ installer = new DiskBundleInstaller();
+ }
+
+ public void install(Collection<FileReference> bundlesToInstall) {
+ for (FileReference reference : bundlesToInstall) {
+ try {
+ installBundleFromDisk(reference);
+ }
+ catch(Exception e) {
+ throw new RuntimeException("Could not install bundle '" + reference + "'", e);
+ }
+ }
+ }
+
+ private void installBundleFromDisk(FileReference reference) {
+ log.info("Installing bundle from disk with reference '" + reference.value() + "'");
+ List<Bundle> bundles = installer.installBundles(reference, osgi);
+ log.fine("Installed " + bundles.size() + " bundles for file reference " + reference);
+ }
+
+}
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java b/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java
index 9f49b016b68..503bf2f2db1 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java
@@ -41,7 +41,8 @@ public class HandlersConfigurerTestWrapper {
private final static String testFiles[] = {
"components.cfg",
"handlers.cfg",
- "bundles.cfg",
+ "platform-bundles.cfg",
+ "application-bundles.cfg",
"string.cfg",
"int.cfg",
"renderers.cfg",