Interface SQLFactory


public interface SQLFactory
The base class every external factory must implement. This framework allows multiple factories.

Each factory should apply a class that implements the SQLFactory interface. The FactoryManager will try to load as many drivers as it can find and then will be queried by the Redis class in order to retrieve the right factory for creating the SQLService instance.

It is strongly recommended that each SQLFactory class should be small and standalone so that the SQLFactory class can be loaded and queried without bringing in vast quantities of supporting code.

When a Factory class is loaded, it should create an instance of itself and register it with the FactoryManager. This means that a user can load and register a factory by following the next instructions:

  • Class.forName("com.abc.Factory")
  • Creating a file named META-INF/services/org.proto4j.redis.sql.SQLFactory with the path to the own implementation of the SQLFactory. For example,
         com.example.impl.MyFactory # own implementation declared in that file
     
    For basic implementations visit the repository on the proto4j-redis repository on github.
Since:
1.0
See Also:
FactoryManager, Redis
  • Method Details

    • engineGetSource

      SQLSource engineGetSource​(SQLConfiguration conf) throws java.sql.SQLDataException, java.sql.SQLWarning
      Attempts to create a new SQLSource instance with the given configuration. Database connections are loaded and instantiated lazily, so this method call will cause no connection to a database.
      Parameters:
      conf - the given configuration instance
      Returns:
      a source object which will delegate the connecting process
      Throws:
      java.sql.SQLDataException - if the configuration was incorrect
      java.sql.SQLWarning - if any deprecation warning should be displayed
    • engineGetService

      SQLService engineGetService​(SQLSource source) throws java.sql.SQLException
      Retrieves a new SQLService instance for the registered factory. By using this method, the source already should have created a connection to the used database.
      Parameters:
      source - the data source
      Returns:
      a service wrapper for executing sql queries.
      Throws:
      java.sql.SQLException - if an error occurs while creating the instance.
    • engineDriverType

      java.lang.String engineDriverType()
      Gets the corresponding driver type that is registered to the DriverManager.
      Returns:
      the sql driver type
    • getMinorVersion

      int getMinorVersion()
      Gets the factory's minor version number. Initially this should be 0.
      Returns:
      this factory's minor version number
    • getMajorVersion

      int getMajorVersion()
      Retrieves the factory's major version number. Initially this should be 1.
      Returns:
      this factory's major version number