java.lang.Object
com.darkcollective.relix.connectors.std.internal.RelixDriverLoader

public final class RelixDriverLoader extends Object
Loads JDBC drivers from JAR files in an external driver directory, rather than bundling them into the executable at build time.

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 Details

    • DRIVERS_ENV

      public static final String DRIVERS_ENV
      Environment variable overriding the default driver directory.
      See Also:
  • Constructor Details

    • RelixDriverLoader

      public RelixDriverLoader(Path directory)
      Parameters:
      directory - the directory to scan for driver JARs (need not exist)
  • Method Details

    • defaultDirectory

      public static Path defaultDirectory()
      Resolves the default driver directory: $RELIX_DRIVERS if set and non-blank, otherwise ~/.relix/drivers.
      Returns:
      the resolved directory path (which may not exist yet)
    • load

      public List<String> 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