Package scriptella.core
Class DriverFactory
java.lang.Object
scriptella.core.DriverFactory
Factory for Scriptella Service Providers and JDBC drivers.
- Version:
- 1.0
- Author:
- Fyodor Kupolov
-
Method Summary
Modifier and TypeMethodDescriptionstatic ScriptellaDriverCreates a Scriptella Driver using specified class.static ScriptellaDrivergetDriver(String driverName, ClassLoader loader) Loads a driver specified by a full or a short name.static Class<?>getDriverClass(String driverName, ClassLoader loader) Finds a driver class without initializing or instantiating it.static voidvalidateDriver(String driverName, ClassLoader loader) Checks that a named driver class is compatible with Scriptella without initializing or instantiating it.
-
Method Details
-
getDriver
public static ScriptellaDriver getDriver(String driverName, ClassLoader loader) throws ClassNotFoundException Loads a driver specified by a full or a short name. This method tries to lookup a driver class specified by a name.The looking up procedure is the following:
- Class with name
driverNameis looked up. - If class not found, a class with the following name is checked: scriptella.driver.<driverName>.Driver
- If no classes found - an exception is raised.
- Parameters:
driverName- driver class short or full name.loader- class loader to use when loading driver classes.- Returns:
- found driver class.
- Throws:
ClassNotFoundException- if no drivers satisfy specified name.
- Class with name
-
getDriverClass
public static Class<?> getDriverClass(String driverName, ClassLoader loader) throws ClassNotFoundException Finds a driver class without initializing or instantiating it.- Parameters:
driverName- driver class short or full name.loader- class loader to use when loading driver classes.- Returns:
- found driver class.
- Throws:
ClassNotFoundException- if no drivers satisfy specified name.
-
validateDriver
public static void validateDriver(String driverName, ClassLoader loader) throws ClassNotFoundException Checks that a named driver class is compatible with Scriptella without initializing or instantiating it.- Parameters:
driverName- driver class short or full name.loader- class loader to use when loading driver classes.- Throws:
ClassNotFoundException- if no drivers satisfy specified name.IllegalArgumentException- if the class is not a JDBC or Scriptella driver.
-
getDriver
Creates a Scriptella Driver using specified class.If class is a
DriverJDBC Bridgeis used.To be successfully instantiated the driver class must implement
ScriptellaDriverclass and has no-arg public constructor.- Parameters:
drvClass- driver class.- Returns:
- Scriptella Driver
-