Class RelixDriverLoader
The directory defaults to ~/.relix/drivers/ and can be overridden
with the RELIX_DRIVERS environment variable. Every *.jar in it
is loaded into a single URLClassLoader; Driver
implementations are discovered via ServiceLoader and registered with
DriverManager through a DriverShim (see that class for why the
shim is required). A JAR that contributes no driver service is silently
skipped, so unrelated JARs in the directory do no harm.
The loader is deliberately isolating: the URLClassLoader's parent is
the platform class loader, so ServiceLoader sees only drivers from the
directory's JARs (plus the JDK), never drivers already on the application class
path. The loaders are held for the JVM lifetime — closing them would make the
registered drivers unusable — so this is a one-shot, additive operation.
This replaces the previous approach of merging PostgreSQL/MySQL driver JARs into the jlink image. Drivers placed here work without rebuilding relix, and commercial drivers whose licences forbid redistribution can be supplied by the user.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringEnvironment variable overriding the default driver directory. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
DRIVERS_ENV
Environment variable overriding the default driver directory.- See Also:
-
-
Constructor Details
-
RelixDriverLoader
- Parameters:
directory- the directory to scan for driver JARs (need not exist)
-
-
Method Details
-
defaultDirectory
Resolves the default driver directory:$RELIX_DRIVERSif set and non-blank, otherwise~/.relix/drivers.- Returns:
- the resolved directory path (which may not exist yet)
-
load
Scans the directory, loads each JAR, and registers every discovered driver.A missing or non-directory path, or a directory with no driver JARs, yields an empty list. Each returned string describes one registered driver (its implementation class and originating JAR file name), suitable for a startup log line.
- Returns:
- descriptions of the drivers registered, in load order
-