Class MarketplaceBundleInstaller

java.lang.Object
org.openhab.core.addon.marketplace.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 Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addBundleToCache(String addonId, URL sourceUrl)
    Downloads a bundle file from a remote source and puts it in the local cache with the add-on ID.
    protected void
    ensureCachedBundlesAreInstalled(org.osgi.framework.BundleContext bundleContext)
    Iterates over the local cache entries and re-installs bundles that are missing
    protected void
    installFromCache(org.osgi.framework.BundleContext bundleContext, String addonId)
    Installs a bundle from its ID by looking up in the local cache
    protected boolean
    isBundleInstalled(org.osgi.framework.BundleContext bundleContext, String addonId)
    Determines whether a bundle associated to the given add-on ID is installed
    protected void
    uninstallBundle(org.osgi.framework.BundleContext bundleContext, String addonId)
    Uninstalls a bundle associated to the given add-on ID.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MarketplaceBundleInstaller

      public MarketplaceBundleInstaller()
  • Method Details

    • 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