Interface IDriverService
public interface IDriverService
Service for managing JDBC drivers, including registering, unregistering, and retrieving driver information.
- Since:
- 8.5.0
- Author:
- Norman Lorenz
-
Method Summary
Modifier and TypeMethodDescriptionvoidexportDriverData(String runtimeId, OutputStream os, PersistenceUser user) Exports the driver data associated with the specified runtime ID to the provided output stream.getDriverByJdbcUrl(String jdbcUrl, PersistenceUser user) Retrieves the JDBC driver instance that accepts the given JDBC URL.getDriverInfo(String runtimeId, PersistenceUser user) Retrieves the driver information for the specified runtime ID.@NotNull FileGets the directory where driver JAR files are stored.static IDriverServiceRetrieves the singleton instance of theIDriverServiceusing CDI.@NotNull List<IDriverInfo> Retrieves a list of all registered driver information.booleanisDriverRegisteredForJdbcUrl(String jdbcUrl) Checks if there is a registered JDBC driver that accepts the given JDBC URL.@NotNull IDriverInforegisterDriver(InputStream driverStream, String fileName, PersistenceUser user) Registers a new JDBC driver from the provided input stream.voidunregisterDriver(String runtimeId, PersistenceUser user) Unregisters the JDBC driver associated with the specified runtime ID.voidunregisterDriverByFingerprint(String fingerprint, PersistenceUser system) Unregisters the JDBC driver associated with the specified SHA-256 fingerprint.
-
Method Details
-
getInstance
Retrieves the singleton instance of theIDriverServiceusing CDI.- Returns:
- the singleton instance of the
IDriverService
-
exportDriverData
void exportDriverData(String runtimeId, OutputStream os, PersistenceUser user) throws FcDriverException Exports the driver data associated with the specified runtime ID to the provided output stream.- Parameters:
runtimeId- the ID of the driver runtime to export. Must not be blank.os- the output stream to write the driver data to. Must not be null.user- the user performing the export- Throws:
IllegalArgumentException- if the runtime ID is blank or if the output stream is null.FcDriverException- if there was an error during export or if no driver with the given runtime ID exists.
-
getDriverByJdbcUrl
Retrieves the JDBC driver instance that accepts the given JDBC URL. If multiple drivers accept the URL, the one with latest version is returned.- Parameters:
jdbcUrl- the JDBC URL to find the driver foruser- the user requesting the driver- Returns:
- the JDBC driver instance that accepts the given JDBC URL, or null if no such driver is found.
- Throws:
IllegalArgumentException- if the JDBC URL is blankFcDriverException
-
getDriverInfo
Retrieves the driver information for the specified runtime ID.- Parameters:
runtimeId- the ID of the driver runtimeuser- the user requesting the driver information- Returns:
- the driver information associated with the given runtime ID
- Throws:
IllegalArgumentException- if the runtime ID is blankFcDriverException
-
getDriverStorageDirectory
Gets the directory where driver JAR files are stored.- Parameters:
user- the user requesting the directory- Returns:
- the directory where driver JAR files are stored
- Throws:
FcDriverException
-
getRegisteredDrivers
@NotNull @NotNull List<IDriverInfo> getRegisteredDrivers(PersistenceUser user) throws FcDriverException Retrieves a list of all registered driver information.- Parameters:
user- the user requesting the list of registered drivers- Returns:
- a list of all registered driver information
- Throws:
FcDriverException- if there was an error retrieving the list of registered drivers
-
isDriverRegisteredForJdbcUrl
Checks if there is a registered JDBC driver that accepts the given JDBC URL.- Parameters:
jdbcUrl- the JDBC URL to check- Returns:
- true if a registered driver accepts the given JDBC URL, false otherwise
- Throws:
IllegalArgumentException- if the JDBC URL is blank
-
registerDriver
@NotNull @NotNull IDriverInfo registerDriver(InputStream driverStream, String fileName, PersistenceUser user) throws FcDriverException Registers a new JDBC driver from the provided input stream. The input stream is expected to contain a valid JDBC driver JAR file. The file name is used to store the driver JAR file on the filesystem. If a file with the same name already exists, a unique name will be generated.- Parameters:
driverStream- Input stream containing the JDBC driver JAR file. Must not be null.fileName- The name of the driver file. Must not be blank.user- the user performing the registration- Throws:
IllegalArgumentException- if driverStream is null or fileName is blank.FcDriverException- if there was an error writing the driver data to a file, loading the driver or if the driver is already registered.
-
unregisterDriver
Unregisters the JDBC driver associated with the specified runtime ID. This will also remove the driver JAR file from the filesystem.- Parameters:
runtimeId- the ID of the driver runtime to unregister. Must not be blank.user- the user performing the unregistration- Throws:
IllegalArgumentException- if the runtime ID is blank.FcDriverException- if there was an error during unregistration or if no driver with the given runtime ID exists.
-
unregisterDriverByFingerprint
void unregisterDriverByFingerprint(String fingerprint, PersistenceUser system) throws FcDriverException Unregisters the JDBC driver associated with the specified SHA-256 fingerprint. This will also remove the driver JAR file from the filesystem.- Parameters:
fingerprint- the SHA-256 fingerprint of the driver to unregister. Must not be blank.system- the system user performing the unregistration- Throws:
IllegalArgumentException- if the fingerprint is blank.FcDriverException- if there was an error during unregistration or if no driver with the given fingerprint exists.
-