diff options
Diffstat (limited to 'container-core/src/main/java/com/yahoo/osgi')
4 files changed, 20 insertions, 70 deletions
diff --git a/container-core/src/main/java/com/yahoo/osgi/MockOsgi.java b/container-core/src/main/java/com/yahoo/osgi/MockOsgi.java index d809c493565..45ad02d2cef 100644 --- a/container-core/src/main/java/com/yahoo/osgi/MockOsgi.java +++ b/container-core/src/main/java/com/yahoo/osgi/MockOsgi.java @@ -16,28 +16,26 @@ import java.util.List; public class MockOsgi extends NonWorkingOsgiFramework implements Osgi { @Override - public List<Bundle> getInitialBundles() { - return Collections.emptyList(); + public Bundle[] getBundles() { + return new Bundle[0]; } @Override - public Bundle[] getBundles() { - return new Bundle[0]; + public Bundle getBundle(ComponentSpecification bundleId) { + return null; } @Override - public List<Bundle> getCurrentBundles() { + public List<Bundle> install(String absolutePath) { return Collections.emptyList(); } @Override - public Bundle getBundle(ComponentSpecification bundleId) { - return null; + public void uninstall(Bundle bundle) { } @Override - public List<Bundle> install(String absolutePath) { - return Collections.emptyList(); + public void refreshPackages() { } } diff --git a/container-core/src/main/java/com/yahoo/osgi/Osgi.java b/container-core/src/main/java/com/yahoo/osgi/Osgi.java index 8f0acf41f30..c94eaf43deb 100644 --- a/container-core/src/main/java/com/yahoo/osgi/Osgi.java +++ b/container-core/src/main/java/com/yahoo/osgi/Osgi.java @@ -4,7 +4,6 @@ package com.yahoo.osgi; import com.yahoo.component.ComponentSpecification; import org.osgi.framework.Bundle; -import java.util.Collection; import java.util.List; /** @@ -12,17 +11,14 @@ import java.util.List; */ public interface Osgi { - List<Bundle> getInitialBundles(); - Bundle[] getBundles(); - /** Returns all bundles that have not been scheduled for uninstall. */ - List<Bundle> getCurrentBundles(); - Bundle getBundle(ComponentSpecification bundleId); List<Bundle> install(String absolutePath); - void allowDuplicateBundles(Collection<Bundle> bundles); + void uninstall(Bundle bundle); + + void refreshPackages(); } diff --git a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java index ed93d15c975..8b2f20a1c13 100644 --- a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java +++ b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java @@ -7,43 +7,19 @@ import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.jdisc.application.OsgiFramework; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; -import org.osgi.framework.launch.Framework; -import java.util.Collection; import java.util.List; -import java.util.logging.Logger; /** * @author Tony Vaagenes * @author bratseth */ public class OsgiImpl implements Osgi { - private static final Logger log = Logger.getLogger(OsgiImpl.class.getName()); private final OsgiFramework jdiscOsgi; - // The initial bundles are never scheduled for uninstall - private final List<Bundle> initialBundles; - - // An initial bundle that is not the framework, and can hence be used to look up current bundles - private final Bundle alwaysCurrentBundle; - public OsgiImpl(OsgiFramework jdiscOsgi) { this.jdiscOsgi = jdiscOsgi; - - this.initialBundles = jdiscOsgi.bundles(); - if (initialBundles.isEmpty()) - throw new IllegalStateException("No initial bundles!"); - - alwaysCurrentBundle = firstNonFrameworkBundle(initialBundles); - if (alwaysCurrentBundle == null) - throw new IllegalStateException("The initial bundles only contained the framework bundle!"); - log.info("Using " + alwaysCurrentBundle + " to lookup current bundles."); - } - - @Override - public List<Bundle> getInitialBundles() { - return initialBundles; } @Override @@ -52,10 +28,6 @@ public class OsgiImpl implements Osgi { return bundles.toArray(new Bundle[bundles.size()]); } - @Override - public List<Bundle> getCurrentBundles() { - return jdiscOsgi.getBundles(alwaysCurrentBundle); - } public Class<Object> resolveClass(BundleInstantiationSpecification spec) { Bundle bundle = getBundle(spec.bundle); @@ -114,9 +86,8 @@ public class OsgiImpl implements Osgi { * @return the bundle match having the highest version, or null if there was no matches */ public Bundle getBundle(ComponentSpecification id) { - log.fine(() -> "Getting bundle for component " + id + ". Set of current bundles: " + getCurrentBundles()); Bundle highestMatch = null; - for (Bundle bundle : getCurrentBundles()) { + for (Bundle bundle : getBundles()) { assert bundle.getSymbolicName() != null : "ensureHasBundleSymbolicName not called during installation"; if ( ! bundle.getSymbolicName().equals(id.getName())) continue; @@ -151,16 +122,17 @@ public class OsgiImpl implements Osgi { } @Override - public void allowDuplicateBundles(Collection<Bundle> bundles) { - jdiscOsgi.allowDuplicateBundles(bundles); + public void uninstall(Bundle bundle) { + try { + bundle.uninstall(); + } catch (BundleException e) { + throw new RuntimeException(e); + } } - private static Bundle firstNonFrameworkBundle(List<Bundle> bundles) { - for (Bundle b : bundles) { - if (! (b instanceof Framework)) - return b; - } - return null; + @Override + public void refreshPackages() { + jdiscOsgi.refreshPackages(); } } diff --git a/container-core/src/main/java/com/yahoo/osgi/OsgiWrapper.java b/container-core/src/main/java/com/yahoo/osgi/OsgiWrapper.java deleted file mode 100644 index 58e19e52ee3..00000000000 --- a/container-core/src/main/java/com/yahoo/osgi/OsgiWrapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.yahoo.osgi; - -import com.yahoo.component.ComponentSpecification; -import org.osgi.framework.Bundle; - -/** - * @author gjoranv - */ -public interface OsgiWrapper extends Osgi, com.yahoo.container.di.Osgi { - - @Override - default Bundle getBundle(ComponentSpecification bundleId) { - return null; - } - -} |