summaryrefslogtreecommitdiffstats
path: root/container-di/src/main/java/com/yahoo/container
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-di/src/main/java/com/yahoo/container
parentf832e4330d5452e228659d7d2b55cf992e6550d0 (diff)
Separate installation for platform and application bundles.
Diffstat (limited to 'container-di/src/main/java/com/yahoo/container')
-rw-r--r--container-di/src/main/java/com/yahoo/container/di/Container.java20
-rw-r--r--container-di/src/main/java/com/yahoo/container/di/Osgi.java4
2 files changed, 18 insertions, 6 deletions
diff --git a/container-di/src/main/java/com/yahoo/container/di/Container.java b/container-di/src/main/java/com/yahoo/container/di/Container.java
index ef7813ce368..bb3634983a9 100644
--- a/container-di/src/main/java/com/yahoo/container/di/Container.java
+++ b/container-di/src/main/java/com/yahoo/container/di/Container.java
@@ -40,7 +40,8 @@ public class Container {
private static final Logger log = Logger.getLogger(Container.class.getName());
private final SubscriberFactory subscriberFactory;
- private ConfigKey<BundlesConfig> bundlesConfigKey;
+ private ConfigKey<ApplicationBundlesConfig> applicationBundlesConfigKey;
+ private ConfigKey<PlatformBundlesConfig> platformBundlesConfigKey;
private ConfigKey<ComponentsConfig> componentsConfigKey;
private final ComponentDeconstructor componentDeconstructor;
private final Osgi osgi;
@@ -54,9 +55,10 @@ public class Container {
this.componentDeconstructor = componentDeconstructor;
this.osgi = osgi;
- bundlesConfigKey = new ConfigKey<>(BundlesConfig.class, configId);
+ applicationBundlesConfigKey = new ConfigKey<>(ApplicationBundlesConfig.class, configId);
+ platformBundlesConfigKey = new ConfigKey<>(PlatformBundlesConfig.class, configId);
componentsConfigKey = new ConfigKey<>(ComponentsConfig.class, configId);
- var bootstrapKeys = Set.of(bundlesConfigKey, componentsConfigKey);
+ var bootstrapKeys = Set.of(applicationBundlesConfigKey, platformBundlesConfigKey, componentsConfigKey);
this.configurer = new ConfigRetriever(bootstrapKeys, subscriberFactory::getSubscriber);
}
@@ -74,7 +76,6 @@ public class Container {
deconstructObsoleteComponents(oldGraph, newGraph, obsoleteBundles);
return newGraph;
} catch (Throwable t) {
- // TODO: Wrap ComponentConstructorException in an Error when generation==0 (+ unit test that Error is thrown)
invalidateGeneration(oldGraph.generation(), t);
throw t;
}
@@ -104,6 +105,9 @@ public class Container {
+ "previous generation: %d\n",
getBootstrapGeneration(), getComponentsGeneration(), previousConfigGeneration));
+ if (graph.generation() == 0) {
+ installPlatformBundles(getConfig(platformBundlesConfigKey, snapshot.configs()));
+ }
Collection<Bundle> bundlesToRemove = installBundles(snapshot.configs());
obsoleteBundles.addAll(bundlesToRemove);
@@ -151,9 +155,13 @@ public class Container {
componentDeconstructor.deconstruct(oldComponents.keySet(), obsoleteBundles);
}
+ private void installPlatformBundles(PlatformBundlesConfig platformBundlesConfig) {
+ osgi.installPlatformBundles(platformBundlesConfig.bundles());
+ }
+
private Set<Bundle> installBundles(Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configsIncludingBootstrapConfigs) {
- BundlesConfig bundlesConfig = getConfig(bundlesConfigKey, configsIncludingBootstrapConfigs);
- return osgi.useBundles(bundlesConfig.bundle());
+ ApplicationBundlesConfig applicationBundlesConfig = getConfig(applicationBundlesConfigKey, configsIncludingBootstrapConfigs);
+ return osgi.useBundles(applicationBundlesConfig.bundles());
}
private ComponentGraph createComponentsGraph(Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configsIncludingBootstrapConfigs,
diff --git a/container-di/src/main/java/com/yahoo/container/di/Osgi.java b/container-di/src/main/java/com/yahoo/container/di/Osgi.java
index ab7da7665b6..563efd5f65e 100644
--- a/container-di/src/main/java/com/yahoo/container/di/Osgi.java
+++ b/container-di/src/main/java/com/yahoo/container/di/Osgi.java
@@ -25,6 +25,10 @@ public interface Osgi {
return new BundleClasses(new MockBundle(), Collections.emptySet());
}
+ default void installPlatformBundles(Collection<FileReference> bundles) {
+ System.out.println("installPlatformBundles " + bundles.stream().map(Object::toString).collect(Collectors.joining(", ")));
+ }
+
/**
* Returns the set of bundles that is not used by the current application generation,
* and therefore should be scheduled for uninstalling.