Interface MarketplaceAddonHandler


@NonNullByDefault public interface MarketplaceAddonHandler
This interface can be implemented by services that want to register as handlers for specific marketplace add-on content types and content types. In a system there should always only be exactly one handler responsible for a given type+contentType combination. If multiple handers support it, it is undefined which one will be called. This mechanism allows solutions to add support for specific formats (e.g. Karaf features) that are not supported by openHAB out of the box. It also allows to decide which add-on types are made available at all.
Author:
Kai Kreuzer - Initial contribution and API, Yannick Schaus - refactoring
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    install(Addon addon)
    Installs a given add-on.
    boolean
    Tells whether a given add-on is currently installed.
    default boolean
    Add-on handler can implement this method if they are nor ready to accept requests after instantiation.
    boolean
    supports(String type, String contentType)
    Tells whether this handler supports a given add-on.
    void
    Uninstalls a given add-on.
  • Method Details

    • supports

      boolean supports(String type, String contentType)
      Tells whether this handler supports a given add-on.
      Parameters:
      type - the type of the add-on in question
      contentType - the content type of the add-on on question
      Returns:
      true, if the addon type and contentType are supported, false otherwise
    • isInstalled

      boolean isInstalled(String id)
      Tells whether a given add-on is currently installed. Note: This method is only called, if the hander claimed support for the add-on before.
      Parameters:
      id - the id of the add-on in question
      Returns:
      true, if the add-on is installed, false otherwise
    • install

      void install(Addon addon) throws MarketplaceHandlerException
      Installs a given add-on. Note: This method is only called, if the hander claimed support for the add-on before.
      Parameters:
      addon - the add-on to install
      Throws:
      MarketplaceHandlerException - if the installation failed for some reason
    • uninstall

      void uninstall(Addon addon) throws MarketplaceHandlerException
      Uninstalls a given add-on. Note: This method is only called, if the handler claimed support for the add-on before.
      Parameters:
      addon - the add-on to uninstall
      Throws:
      MarketplaceHandlerException - if the uninstallation failed for some reason
    • isReady

      default boolean isReady()
      Add-on handler can implement this method if they are nor ready to accept requests after instantiation. This may be needed if completing the initialization takes some time (e.g. for installing cached addons). This cannot be done in the constructor because the OSGi framework does not wait for the constructor to finish before the service is injected in other services, leading to ServiceExceptions..
      Returns:
      true if the initialization finished