Class MarketplaceBundleInstaller
java.lang.Object
org.openhab.core.addon.marketplace.MarketplaceBundleInstaller
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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 missingprotected void
installFromCache
(org.osgi.framework.BundleContext bundleContext, String addonId) Installs a bundle from its ID by looking up in the local cacheprotected boolean
isBundleInstalled
(org.osgi.framework.BundleContext bundleContext, String addonId) Determines whether a bundle associated to the given add-on ID is installedprotected void
uninstallBundle
(org.osgi.framework.BundleContext bundleContext, String addonId) Uninstalls a bundle associated to the given add-on ID.
-
Constructor Details
-
MarketplaceBundleInstaller
public MarketplaceBundleInstaller()
-
-
Method Details
-
addBundleToCache
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 IDsourceUrl
- 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
- theBundleContext
to use to install the bundleaddonId
- the add-on ID- Throws:
MarketplaceHandlerException
-
isBundleInstalled
Determines whether a bundle associated to the given add-on ID is installed- Parameters:
bundleContext
- theBundleContext
to use to look up the bundleaddonId
- 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
- theBundleContext
to use to look up the bundleaddonId
- 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
- theBundleContext
to use to look up the bundles
-