Class AbstractRemoteAddonService

java.lang.Object
org.openhab.core.addon.marketplace.AbstractRemoteAddonService
All Implemented Interfaces:
AddonService

@NonNullByDefault public abstract class AbstractRemoteAddonService extends Object implements AddonService
The AbstractRemoteAddonService implements basic functionality of a remote add-on-service
Author:
Jan N. Klug - Initial contribution
  • Field Details

    • coreVersion

      protected final BundleVersion coreVersion
    • gson

      protected final com.google.gson.Gson gson
    • addonHandlers

      protected final Set<MarketplaceAddonHandler> addonHandlers
    • installedAddonStorage

      protected final Storage<String> installedAddonStorage
    • eventPublisher

      protected final EventPublisher eventPublisher
    • configurationAdmin

      protected final org.osgi.service.cm.ConfigurationAdmin configurationAdmin
    • cachedRemoteAddons

      protected final ExpiringCache<List<Addon>> cachedRemoteAddons
    • addonInfoRegistry

      protected final AddonInfoRegistry addonInfoRegistry
    • cachedAddons

      protected List<Addon> cachedAddons
    • installedAddonIds

      protected List<String> installedAddonIds
  • Constructor Details

  • Method Details

    • getCoreVersion

      protected BundleVersion getCoreVersion()
    • refreshSource

      public void refreshSource()
      Description copied from interface: AddonService
      Refreshes the source used for providing the add-ons. This can be called before getAddons to ensure the add-on information is up-to-date; otherwise they might be retrieved from a cache.
      Specified by:
      refreshSource in interface AddonService
    • addAddonHandler

      protected abstract void addAddonHandler(MarketplaceAddonHandler handler)
      Add a MarketplaceAddonHandler to this service This needs to be implemented by the addon-services because the handlers are references to OSGi services and the @Reference annotation is not inherited. It is added here to make sure that implementations comply with that.
      Parameters:
      handler - the handler that shall be added
    • removeAddonHandler

      protected abstract void removeAddonHandler(MarketplaceAddonHandler handler)
      Remove a MarketplaceAddonHandler from this service This needs to be implemented by the addon-services because the handlers are references to OSGi services and unbind methods can't be inherited. It is added here to make sure that implementations comply with that.
      Parameters:
      handler - the handler that shall be removed
    • getRemoteAddons

      protected abstract List<Addon> getRemoteAddons()
      get all addons from remote
      Returns:
      a list of Addon that are available on the remote side
    • getAddons

      public List<Addon> getAddons(@Nullable Locale locale)
      Description copied from interface: AddonService
      Retrieves all add-ons. It is expected that this method is rather cheap to call and will return quickly, i.e. some caching should be implemented if required.
      Specified by:
      getAddons in interface AddonService
      Parameters:
      locale - the locale to use for the result
      Returns:
      the localized add-ons
    • getTypes

      public List<AddonType> getTypes(@Nullable Locale locale)
      Description copied from interface: AddonService
      Retrieves all possible types of add-ons.
      Specified by:
      getTypes in interface AddonService
      Parameters:
      locale - the locale to use for the result
      Returns:
      the localized types
    • install

      public void install(String id)
      Description copied from interface: AddonService
      Installs the given add-on. This can be a long running process. The framework makes sure that this is called within a separate thread and add-on events will be sent upon its completion.
      Specified by:
      install in interface AddonService
      Parameters:
      id - the id of the add-on to install
    • uninstall

      public void uninstall(String id)
      Description copied from interface: AddonService
      Uninstalls the given add-on. This can be a long running process. The framework makes sure that this is called within a separate thread and add-on events will be sent upon its completion.
      Specified by:
      uninstall in interface AddonService
      Parameters:
      id - the id of the add-on to uninstall
    • remoteEnabled

      protected boolean remoteEnabled()
      check if remote services are enabled
      Returns:
      true if network access is allowed
    • includeIncompatible

      protected boolean includeIncompatible()