java.lang.Object
com.darkcollective.relix.processor.connector.ConnectorProvisioner

public final class ConnectorProvisioner extends Object
Provisions a connector plugin on demand: when a connection names a connectorType for which no RelixConnector is registered, this looks the plugin up in the ConnectorCatalog, downloads its artifacts (the connector JAR + its driver/runtime JARs, each checksum-verified) into the connector directory, and reports the outcome — the caller then rebuilds its ConnectorRegistry to pick up the new plugin. It is the SPI-side analogue of DriverProvisioner.

The catalog is hosted and decoupled from the relix release: it is fetched from DEFAULT_CATALOG_URL (overridable via $RELIX_CONNECTOR_CATALOG, which may be an https:// URL or a local file path) so a connector plugin can be published — and the catalog updated — without rebuilding relix. It is served as an asset of the latest release, which is what keeps a pre-release's catalog out of everybody's hands. The catalog is loaded lazily and only when downloading is actually needed, so no network call happens at startup or when downloads are off.

Downloading is opt-in: a provisioner created with enabled == false never reaches the network and reports ConnectorProvisioner.Outcome.DISABLED.

  • Field Details

    • DEFAULT_CATALOG_URL

      public static final String DEFAULT_CATALOG_URL
      The hosted catalog, served as an asset of the engine repository's latest release.

      A release asset rather than a file on a branch, and the difference is what the URL means. /releases/latest/download/ resolves to the newest release that is not a pre-release — so a release candidate's catalog is published under its own tag and served to nobody, which is the property this needs: the file is fetched at run time by every user who asks to download a connector, and a candidate that is later dropped must never have been what they got. Reading a branch could only approximate that with a rule someone has to remember.

      It also means a release writes nothing back. The catalog committed in the repository is the base — which connectors exist — and each release publishes it merged with that build's own entry, so the per-release part (a version in a URL, a hash of the artifact just built) is never a commit at all.

      Overridable via $RELIX_CONNECTOR_CATALOG, an https:// URL or a local file path. A catalog that 404s is not a failure here: provisioning is opt-in, and a caller who has not asked to download never fetches it.

      See Also:
  • Constructor Details

    • ConnectorProvisioner

      public ConnectorProvisioner(ConnectorCatalog catalog, Path connectorDirectory, Fetcher fetcher, boolean enabled)
      Creates a provisioner with a fixed, already-loaded catalog.
      Parameters:
      catalog - the catalog of downloadable connector plugins
      connectorDirectory - the directory plugins are downloaded into and loaded from
      fetcher - the network seam
      enabled - whether downloading is permitted (user consent)
  • Method Details

    • create

      public static ConnectorProvisioner create(boolean enabled, Fetcher fetcher)
      Builds a provisioner that fetches the hosted catalog on demand (the location is $RELIX_CONNECTOR_CATALOG if set, else DEFAULT_CATALOG_URL) and downloads into the default connector directory.

      The Fetcher is a parameter rather than a default because this class lives in the engine and the engine owns no HTTP client: the caller that wants downloads supplies the thing that performs them. Front-ends pass the reporting fetcher that prints progress to the terminal.

      Parameters:
      enabled - whether downloading is permitted
      fetcher - the fetcher used for the catalog fetch and downloads
      Returns:
      a production provisioner
    • defaultDirectory

      public static Path defaultDirectory()
      Where connector plugins are installed and looked for: ~/.relix/connectors.
      Returns:
      the directory; it may not exist yet
      Since:
      1.0
    • installedTypes

      public static Set<String> installedTypes()
      The connector type tokens usable now: those shipped with the engine, and those of every plugin installed in defaultDirectory().
      Returns:
      the type tokens, such as csv or jdbc; never null
      Since:
      1.0
    • catalogTypes

      public SortedSet<String> catalogTypes()
      The connector type tokens available to download from the catalog (e.g. for a relix connectors list). Loads the catalog (which may fetch the hosted URL); returns an empty set if the catalog can't be loaded.
      Returns:
      the cataloged connector types, sorted
    • isEnabled

      public boolean isEnabled()
      Returns:
      whether this provisioner is permitted to download
    • provision

      public ConnectorProvisioner.Result provision(String connectorType)
      Downloads the plugin for a connector type, if cataloged and permitted. The catalog is fetched only here (lazily) and only when downloading is enabled.
      Parameters:
      connectorType - the connection's connector type token (e.g. "mongodb")
      Returns:
      the outcome of the attempt