diff options
author | gjoranv <gv@verizonmedia.com> | 2020-07-18 13:33:55 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2020-07-18 14:03:23 +0200 |
commit | 71efbd84c9bee75d83b11478ec430c72d1c456ea (patch) | |
tree | 98ed4062dda286a0372dd580a9566133f40404a4 /container-core | |
parent | 7fca48252b72672a1505c9519193ae376eb562eb (diff) |
Use plain strings for platform bundles, instead of file references
Diffstat (limited to 'container-core')
4 files changed, 25 insertions, 34 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/DiskBundleInstaller.java b/container-core/src/main/java/com/yahoo/container/core/config/DiskBundleInstaller.java index 87c3d3048c5..a4cce2e38db 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/DiskBundleInstaller.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/DiskBundleInstaller.java @@ -1,7 +1,6 @@ // Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.container.core.config; -import com.yahoo.config.FileReference; import com.yahoo.osgi.Osgi; import org.osgi.framework.Bundle; @@ -11,18 +10,12 @@ import java.util.List; /** * @author gjoranv */ -public class DiskBundleInstaller implements BundleInstaller { +public class DiskBundleInstaller { - @Override - public List<Bundle> installBundles(FileReference reference, Osgi osgi) { - // TODO: remove when the last model producing 'file:' has rolled out of hosted - String referenceFileName = reference.value().startsWith("file:") - ? reference.value().substring("file:".length()) - : reference.value(); - - File file = new File(referenceFileName); + public List<Bundle> installBundles(String bundlePath, Osgi osgi) { + File file = new File(bundlePath); if ( ! file.exists()) { - throw new IllegalArgumentException("Reference '" + reference.value() + "' not found on disk."); + throw new IllegalArgumentException("Bundle file '" + bundlePath + "' not found on disk."); } return osgi.install(file.getAbsolutePath()); 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 80c39bef2cb..a58dff13f09 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 @@ -135,9 +135,9 @@ public class HandlersConfigurerDi { } @Override - public void installPlatformBundles(Collection<FileReference> bundles) { + public void installPlatformBundles(Collection<String> bundlePaths) { log.fine("Installing platform bundles."); - platformBundleLoader.useBundles(new ArrayList<>(bundles)); + platformBundleLoader.useBundles(new ArrayList<>(bundlePaths)); } @Override diff --git a/container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleLoader.java index 1f788823753..0ab89e223f6 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleLoader.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/PlatformBundleLoader.java @@ -1,6 +1,5 @@ package com.yahoo.container.core.config; -import com.yahoo.config.FileReference; import com.yahoo.osgi.Osgi; import org.osgi.framework.Bundle; @@ -38,35 +37,35 @@ public class PlatformBundleLoader { this.installer = installer; } - public void useBundles(List<FileReference> fileReferences) { + public void useBundles(List<String> bundlePaths) { if (hasLoadedBundles) { log.fine(() -> "Platform bundles have already been installed." + "\nInstalled bundles: " + installedBundles + - "\nGiven files: " + fileReferences); + "\nGiven files: " + bundlePaths); return; } - installedBundles = install(fileReferences); + installedBundles = install(bundlePaths); BundleStarter.startBundles(installedBundles); hasLoadedBundles = true; } - private Set<Bundle> install(List<FileReference> bundlesToInstall) { + private Set<Bundle> install(List<String> bundlesToInstall) { var allInstalled = new LinkedHashSet<Bundle>(); - for (FileReference reference : bundlesToInstall) { + for (String bundlePath : bundlesToInstall) { try { - allInstalled.addAll(installBundleFromDisk(reference)); + allInstalled.addAll(installBundleFromDisk(bundlePath)); } catch(Exception e) { - throw new RuntimeException("Could not install bundle '" + reference + "'", e); + throw new RuntimeException("Could not install bundle '" + bundlePath + "'", e); } } return allInstalled; } - private List<Bundle> 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); + private List<Bundle> installBundleFromDisk(String bundlePath) { + log.info("Installing bundle from disk: " + bundlePath); + List<Bundle> bundles = installer.installBundles(bundlePath, osgi); + log.fine("Installed " + bundles.size() + " bundles for file " + bundlePath); return bundles; } diff --git a/container-core/src/test/java/com/yahoo/container/core/config/PlatformBundleLoaderTest.java b/container-core/src/test/java/com/yahoo/container/core/config/PlatformBundleLoaderTest.java index 338577c6f4c..931b0c547fd 100644 --- a/container-core/src/test/java/com/yahoo/container/core/config/PlatformBundleLoaderTest.java +++ b/container-core/src/test/java/com/yahoo/container/core/config/PlatformBundleLoaderTest.java @@ -1,6 +1,5 @@ package com.yahoo.container.core.config; -import com.yahoo.config.FileReference; import com.yahoo.osgi.Osgi; import org.junit.Before; import org.junit.Test; @@ -17,10 +16,10 @@ import static org.junit.Assert.assertTrue; */ public class PlatformBundleLoaderTest { - private static final FileReference BUNDLE_1_REF = new FileReference("bundle-1"); - private static final Bundle BUNDLE_1 = new TestBundle(BUNDLE_1_REF.value()); - private static final FileReference BUNDLE_2_REF = new FileReference("bundle-2"); - private static final Bundle BUNDLE_2 = new TestBundle(BUNDLE_2_REF.value()); + private static final String BUNDLE_1_REF = "bundle-1"; + private static final Bundle BUNDLE_1 = new TestBundle(BUNDLE_1_REF); + private static final String BUNDLE_2_REF = "bundle-2"; + private static final Bundle BUNDLE_2 = new TestBundle(BUNDLE_2_REF); private PlatformBundleLoader bundleLoader; private TestOsgi osgi; @@ -52,14 +51,14 @@ public class PlatformBundleLoaderTest { } private static Map<String, Bundle> testBundles() { - return Map.of(BUNDLE_1_REF.value(), BUNDLE_1, - BUNDLE_2_REF.value(), BUNDLE_2); + return Map.of(BUNDLE_1_REF, BUNDLE_1, + BUNDLE_2_REF, BUNDLE_2); } static class TestBundleInstaller extends DiskBundleInstaller { @Override - public List<Bundle> installBundles(FileReference reference, Osgi osgi) { - return osgi.install(reference.value()); + public List<Bundle> installBundles(String bundlePath, Osgi osgi) { + return osgi.install(bundlePath); } } } |