Class ConnectorRegistry
- All Implemented Interfaces:
AutoCloseable
CompositeDataSourceConnector switch.
The registry indexes every available RelixConnector by the type
tokens it handles and resolves a connector for
a token via forType(String). Built-in connectors are discovered from
the module path with ServiceLoader; external connectors are loaded from
the connector directory by a ConnectorPluginLoader.
Token resolution is case-insensitive. When two connectors claim the same token, the first registered wins and a warning is logged — built-ins are registered before external plugins, so a plugin cannot silently shadow a built-in.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes every connector this registry discovered, suppressing individual failures.static ConnectorRegistrycreate()Builds a registry from the installed connector providers (module-path or classpathServiceLoader) plus external plugins from the default connector directory ($RELIX_CONNECTORS, default~/.relix/connectors/).static ConnectorRegistryBuilds a registry from the installed providers plus external plugins in the given directory, rather than the default one.static ConnectorRegistrycreateWith(List<RelixConnector> extra) Builds a registry over connectors the caller supplies directly, ahead of the discovered and plugin ones.static ConnectorRegistrycreateWith(List<RelixConnector> extra, Path pluginDirectory) Builds a registry over caller-supplied connectors plus the installed providers and the plugins in the given directory.Resolves the connector for a declaration's type token (case-insensitive).types()
-
Method Details
-
create
Builds a registry from the installed connector providers (module-path or classpathServiceLoader) plus external plugins from the default connector directory ($RELIX_CONNECTORS, default~/.relix/connectors/).The engine provides none of them itself: the standard CSV/JSON/HTTP/JDBC set is a discovered provider on exactly the footing an out-of-tree plugin has. A runtime with no provider installed yields an empty registry, and a source declaration then reports an unknown connector type.
- Returns:
- a registry over all discovered connectors
-
create
Builds a registry from the installed providers plus external plugins in the given directory, rather than the default one.- Parameters:
pluginDirectory- the connector-plugin directory to scan- Returns:
- a registry over all discovered connectors
-
createWith
Builds a registry over connectors the caller supplies directly, ahead of the discovered and plugin ones.For a program that holds a connector instance rather than a service declaration — an embedder wiring a backend of its own without a
META-INF/servicesentry, or a test standing one in. The SPI's argument is that anything a shipped connector can do a third party can do; needing a service declaration to exercise that inside one's own program would be a gap in the claim rather than a feature of it.Supplied connectors are indexed first, so one claiming a token a discovered connector also claims wins it — the caller named this instance explicitly, which is a stronger statement than a classpath scan.
- Parameters:
extra- the caller's connectors, in priority order; must not be null- Returns:
- a registry over the supplied, discovered and plugin connectors
-
createWith
Builds a registry over caller-supplied connectors plus the installed providers and the plugins in the given directory.- Parameters:
extra- the caller's connectors, in priority order; must not be nullpluginDirectory- the connector-plugin directory to scan- Returns:
- a registry over all three sources
-
forType
Resolves the connector for a declaration's type token (case-insensitive).- Parameters:
token- the type token (e.g."jdbc","csv","mongodb")- Returns:
- the handling connector, or empty when no connector handles the token
-
types
- Returns:
- the set of type tokens this registry can dispatch, lower-cased
-
close
public void close()Closes every connector this registry discovered, suppressing individual failures. A connector supplied by the caller is left open — seecreateWith(List).- Specified by:
closein interfaceAutoCloseable
-