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
    • installedAddons

      protected List<String> installedAddons
  • 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 {@link 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 {@link 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
    • getAddon

      public abstract @Nullable Addon getAddon(String id, @Nullable Locale locale)
      Description copied from interface: AddonService
      Retrieves the add-on for the given id.
      Specified by:
      getAddon in interface AddonService
      Parameters:
      id - the id of the add-on
      locale - the locale to use for the result
      Returns:
      the localized add-on or null, if no add-on exists with this id
    • 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
    • getAddonId

      public abstract @Nullable String getAddonId(URI addonURI)
      Description copied from interface: AddonService
      Parses the given URI and extracts an add-on Id. This must not be a long running process but return immediately.
      Specified by:
      getAddonId in interface AddonService
      Parameters:
      addonURI - the URI from which to parse the add-on Id.
      Returns:
      the add-on Id if the URI can be parsed, otherwise null
    • remoteEnabled

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

      protected boolean includeIncompatible()