java.lang.Object
org.proto4j.redis.FactoryManager
public class FactoryManager
extends java.lang.Object
The basic service for managing a set of SQLFactories.
As part of its initialization, the FactoryManager
class will
attempt to load available SQLFactory
classes by using:
- Service providers of the
java.sql.Driver
class, that are loaded via theServiceLoader.load(Class)
mechanism.
- Since:
- 1.0
- See Also:
SQLFactory
-
Method Summary
Modifier and Type Method Description static void
deregisterFactory(SQLFactory factory)
Removes the specified driver from theFactoryManager
's list of registered factories.static java.util.stream.Stream<SQLFactory>
factories()
Retrieves a Stream with all the currently loaded factories to which the current caller has access.static java.util.Enumeration<SQLFactory>
getFactories()
Retrieves an Enumeration with all the currently loaded factories to which the current caller has access.static SQLFactory
getFactory(java.lang.String driverType)
Attempts to locate a factory that is bound to the given driver type.static void
registerFactory(SQLFactory factory)
Registers the given factory with theFactoryManager
.
-
Method Details
-
registerFactory
Registers the given factory with theFactoryManager
. A newly-loaded driver class should call the methodregisterDriver
to make itself known to theFactoryManager
. If the driver is currently registered, no action is taken.- Parameters:
factory
- the newSQLFactory
that is to be registered with theFactoryManager
- Throws:
java.lang.NullPointerException
- iffactory
is null
-
deregisterFactory
Removes the specified driver from theFactoryManager
's list of registered factories.If a
null
value is specified for the driver to be removed, then no action is taken.If the specified factory is not found in the list of registered factories, then no action is taken. If the factory was found, it will be removed from the list of registered factories.
- Parameters:
factory
- theSQLFactory
to remove
-
getFactory
Attempts to locate a factory that is bound to the given driver type.- Parameters:
driverType
- a string representation of the driver type- Returns:
- a
SQLFactory
object that can createSQLService
andSQLSource
instances.
-
getFactories
Retrieves an Enumeration with all the currently loaded factories to which the current caller has access.Note: The classname of a driver can be found using
d.getClass().getName()
- Returns:
- the list of
SQLFactory
loaded by the caller's class loader - See Also:
factories()
-
factories
Retrieves a Stream with all the currently loaded factories to which the current caller has access.- Returns:
- the stream of
SQLFactory
loaded by the caller's class loader - Since:
- Java 9
-