Class MarketplaceBundleInstaller


  • @NonNullByDefault
    public abstract class MarketplaceBundleInstaller
    extends Object
    Handle the management of bundles related to marketplace add-ons that resists OSGi cache cleanups. These operations cache incoming bundle files locally in a structure under the user data folder, and can make sure the bundles are re-installed if they are present in the local cache but not installed in the OSGi framework. They can be used by marketplace handler implementations dealing with OSGi bundles.
    Author:
    Yannick Schaus - Initial contribution and API
    • Constructor Detail

      • MarketplaceBundleInstaller

        public MarketplaceBundleInstaller()
    • Method Detail

      • addBundleToCache

        protected void addBundleToCache​(String addonId,
                                        URL sourceUrl)
                                 throws MarketplaceHandlerException
        Downloads a bundle file from a remote source and puts it in the local cache with the add-on ID.
        Parameters:
        addonId - the add-on ID
        sourceUrl - the (online) source where the .jar file can be found
        Throws:
        MarketplaceHandlerException
      • installFromCache

        protected void installFromCache​(org.osgi.framework.BundleContext bundleContext,
                                        String addonId)
                                 throws MarketplaceHandlerException
        Installs a bundle from its ID by looking up in the local cache
        Parameters:
        bundleContext - the BundleContext to use to install the bundle
        addonId - the add-on ID
        Throws:
        MarketplaceHandlerException
      • isBundleInstalled

        protected boolean isBundleInstalled​(org.osgi.framework.BundleContext bundleContext,
                                            String addonId)
        Determines whether a bundle associated to the given add-on ID is installed
        Parameters:
        bundleContext - the BundleContext to use to look up the bundle
        addonId - the add-on ID
      • uninstallBundle

        protected void uninstallBundle​(org.osgi.framework.BundleContext bundleContext,
                                       String addonId)
                                throws MarketplaceHandlerException
        Uninstalls a bundle associated to the given add-on ID. Also removes it from the local cache.
        Parameters:
        bundleContext - the BundleContext to use to look up the bundle
        addonId - the add-on ID
        Throws:
        MarketplaceHandlerException
      • ensureCachedBundlesAreInstalled

        protected void ensureCachedBundlesAreInstalled​(org.osgi.framework.BundleContext bundleContext)
        Iterates over the local cache entries and re-installs bundles that are missing
        Parameters:
        bundleContext - the BundleContext to use to look up the bundles