summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-07-18 16:01:12 +0200
committergjoranv <gv@verizonmedia.com>2020-07-18 16:21:36 +0200
commit5deab715167cc3ffbd9ab76726bb6cb7f50397ec (patch)
treed98a1237b7e33afdf0a9b5195a6ab7d529333758
parent71efbd84c9bee75d83b11478ec430c72d1c456ea (diff)
Remove the unnecessary BundleInstaller interface.
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java13
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/BundleInstaller.java21
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java3
-rw-r--r--container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java21
-rw-r--r--container-core/src/test/java/com/yahoo/container/core/config/TestBundleInstaller.java20
5 files changed, 28 insertions, 50 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java
index 3e8ef65ade6..69d7d44773e 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java
@@ -6,7 +6,6 @@ import com.yahoo.container.Container;
import com.yahoo.filedistribution.fileacquirer.FileAcquirer;
import com.yahoo.osgi.Osgi;
import org.osgi.framework.Bundle;
-import org.osgi.framework.wiring.BundleRevision;
import java.util.ArrayList;
import java.util.HashSet;
@@ -24,6 +23,7 @@ import java.util.stream.Collectors;
* @author Tony Vaagenes
*/
public class ApplicationBundleLoader {
+ private static final Logger log = Logger.getLogger(ApplicationBundleLoader.class.getName());
/* Map of file refs of active bundles (not scheduled for uninstall) to the installed bundle.
*
@@ -34,11 +34,11 @@ public class ApplicationBundleLoader {
*/
private final Map<FileReference, Bundle> reference2Bundle = new LinkedHashMap<>();
- private final Logger log = Logger.getLogger(ApplicationBundleLoader.class.getName());
private final Osgi osgi;
- // A custom bundle installer for non-disk bundles, to be used for testing
- private BundleInstaller customBundleInstaller = null;
+ // TODO: Take the bundle installer as a ctor argument instead. It's safe because the
+ // file acquirer in the Container singleton is set up before this is created.
+ private FileAcquirerBundleInstaller customBundleInstaller = null;
public ApplicationBundleLoader(Osgi osgi) {
this.osgi = osgi;
@@ -101,7 +101,8 @@ public class ApplicationBundleLoader {
}
}
- private void installWithFileDistribution(Set<FileReference> bundlesToInstall, BundleInstaller bundleInstaller) {
+ private void installWithFileDistribution(Set<FileReference> bundlesToInstall,
+ FileAcquirerBundleInstaller bundleInstaller) {
for (FileReference reference : bundlesToInstall) {
try {
log.info("Installing bundle with reference '" + reference.value() + "'");
@@ -133,7 +134,7 @@ public class ApplicationBundleLoader {
}
// Only for testing
- void useCustomBundleInstaller(BundleInstaller bundleInstaller) {
+ void useCustomBundleInstaller(FileAcquirerBundleInstaller bundleInstaller) {
customBundleInstaller = bundleInstaller;
}
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/BundleInstaller.java b/container-core/src/main/java/com/yahoo/container/core/config/BundleInstaller.java
deleted file mode 100644
index fc919571b6c..00000000000
--- a/container-core/src/main/java/com/yahoo/container/core/config/BundleInstaller.java
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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;
-
-import java.util.List;
-
-/**
- * @author gjoranv
- */
-public interface BundleInstaller {
-
- /**
- * Installs the bundle with the given file reference, plus all bundles in its X-JDisc-Preinstall-Bundle directive.
- * Returns all bundles installed to the given OSGi framework as a result of this call.
- */
- List<Bundle> installBundles(FileReference reference, Osgi osgi) throws InterruptedException;
-
-}
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java b/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
index 72951e67b4e..cbfb8538643 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
@@ -15,7 +15,7 @@ import java.util.logging.Logger;
/**
* @author gjoranv
*/
-public class FileAcquirerBundleInstaller implements BundleInstaller {
+public class FileAcquirerBundleInstaller {
private static Logger log = Logger.getLogger(FileAcquirerBundleInstaller.class.getName());
private final FileAcquirer fileAcquirer;
@@ -24,7 +24,6 @@ public class FileAcquirerBundleInstaller implements BundleInstaller {
this.fileAcquirer = fileAcquirer;
}
- @Override
public List<Bundle> installBundles(FileReference reference, Osgi osgi) throws InterruptedException {
File file = fileAcquirer.waitFor(reference, 7, TimeUnit.DAYS);
diff --git a/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java b/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java
index ee71e8a8f4c..6d6db045b73 100644
--- a/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java
+++ b/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java
@@ -2,13 +2,18 @@
package com.yahoo.container.core.config;
import com.yahoo.config.FileReference;
+import com.yahoo.filedistribution.fileacquirer.FileAcquirer;
+import com.yahoo.filedistribution.fileacquirer.MockFileAcquirer;
+import com.yahoo.osgi.Osgi;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
+import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -29,7 +34,8 @@ public class ApplicationBundleLoaderTest {
@Before
public void setup() {
osgi = new TestOsgi(testBundles());
- var bundleInstaller = new TestBundleInstaller();
+ var bundleInstaller = new TestBundleInstaller(MockFileAcquirer.returnFile(null));
+
bundleLoader = new ApplicationBundleLoader(osgi);
bundleLoader.useCustomBundleInstaller(bundleInstaller);
}
@@ -103,4 +109,17 @@ public class ApplicationBundleLoaderTest {
BUNDLE_2_REF.value(), BUNDLE_2);
}
+ static class TestBundleInstaller extends FileAcquirerBundleInstaller {
+
+ TestBundleInstaller(FileAcquirer fileAcquirer) {
+ super(fileAcquirer);
+ }
+
+ @Override
+ public List<Bundle> installBundles(FileReference reference, Osgi osgi) {
+ return osgi.install(reference.value());
+ }
+
+ }
+
}
diff --git a/container-core/src/test/java/com/yahoo/container/core/config/TestBundleInstaller.java b/container-core/src/test/java/com/yahoo/container/core/config/TestBundleInstaller.java
deleted file mode 100644
index 43a5268eabf..00000000000
--- a/container-core/src/test/java/com/yahoo/container/core/config/TestBundleInstaller.java
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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;
-
-import java.util.List;
-
-/**
- * @author gjoranv
- */
-class TestBundleInstaller implements BundleInstaller {
-
- @Override
- public List<Bundle> installBundles(FileReference reference, Osgi osgi) {
- return osgi.install(reference.value());
- }
-
-}