diff options
author | gjoranv <gv@verizonmedia.com> | 2019-10-26 02:04:18 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2019-10-28 14:09:03 +0100 |
commit | 38ab0914bb97438ea8ddbe03089155192154580c (patch) | |
tree | 37036f4c68f44b2ccf0255c7a5818e56b7d16fcc /jdisc_core | |
parent | ea149387f4e94edefdd8a4677075a1531e2357d0 (diff) |
Support safe component deconstruction in jdisc container.
- Add allowDuplicates to all Osgi classes
- Uninstall bundles in Deconstructor
- We no longer refresh bundles because we uninstall old bundles at
a later point than the new bundles are installed. Hence, the
user must version app bundles that are dependencies used by
other app bundles.
Diffstat (limited to 'jdisc_core')
3 files changed, 26 insertions, 0 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java index f5346a21a4f..4dc59accee4 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java @@ -5,6 +5,7 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; +import java.util.Collection; import java.util.List; /** @@ -13,6 +14,7 @@ import java.util.List; * {@link BundleInstaller} since that provides common convenience methods. * * @author Simon Thoresen Hult + * @author gjoranv */ public interface OsgiFramework { @@ -81,6 +83,20 @@ public interface OsgiFramework { List<Bundle> bundles(); /** + * Returns all installed bundles that are visible to the requesting bundle. Bundle visibility + * is controlled via implementations of {@link org.osgi.framework.hooks.bundle.FindHook}; + */ + List<Bundle> getBundles(Bundle requestingBundle); + + /** + * Allows this framework to install duplicates of the given collection of bundles. Duplicate detection + * is handled by the {@link com.yahoo.jdisc.core.BundleCollisionHook}. + * + * @param bundles The bundles to allow duplicates of + */ + void allowDuplicateBundles(Collection<Bundle> bundles); + + /** * This method starts the framework instance. Before this method is called, any call to {@link * #installBundle(String)} or {@link #bundles()} will generate a {@link NullPointerException}. * diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java index 19a1707e97c..8b226a0fe3e 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java @@ -153,6 +153,7 @@ public class FelixFramework implements OsgiFramework { return Arrays.asList(felix.getBundleContext().getBundles()); } + @Override public List<Bundle> getBundles(Bundle requestingBundle) { return Arrays.asList(requestingBundle.getBundleContext().getBundles()); } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java b/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java index 6b129e82a45..0f927aa97d3 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java @@ -5,6 +5,7 @@ import com.yahoo.jdisc.application.OsgiFramework; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -39,6 +40,14 @@ public class NonWorkingOsgiFramework implements OsgiFramework { } @Override + public List<Bundle> getBundles(Bundle requestingBundle) { + return Collections.emptyList(); + } + + @Override + public void allowDuplicateBundles(Collection<Bundle> bundles) { } + + @Override public void start() { } |