Interface DataSourceSupplier


public interface DataSourceSupplier
Supply the DataSource to the transaction manager.

Implementations can support multi-tenancy via DB or SCHEMA.

  • Method Summary

    Modifier and Type
    Method
    Description
    connection(Object tenantId)
    Return a connection from the DataSource taking into account a tenantId for multi-tenant lazy loading.
    Obtain the current TenantId *IF* it is required for the DataSource.
    Return the DataSource to use for the current request.
    readOnlyConnection(Object tenantId, boolean useMaster)
    Return a connection from the read only DataSource taking into account a tenantId for multi-tenant lazy loading.
    Return the read only DataSource to use for the current request.
    void
    shutdown(boolean deregisterDriver)
    Shutdown the datasource de-registering the JDBC driver if requested.
  • Method Details

    • dataSource

      DataSource dataSource()
      Return the DataSource to use for the current request.

      This should take into account multi-tenancy and the current tenantId.

    • readOnlyDataSource

      DataSource readOnlyDataSource()
      Return the read only DataSource to use for the current request.

      This can return null meaning that no read only DataSource (with autoCommit) is available for use so normal transactions with explicit commit should be used.

    • currentTenantId

      Object currentTenantId()
      Obtain the current TenantId *IF* it is required for the DataSource.
    • connection

      Connection connection(Object tenantId) throws SQLException
      Return a connection from the DataSource taking into account a tenantId for multi-tenant lazy loading.
      Parameters:
      tenantId - Most often null but well supplied indicates a multi-tenant lazy loading query
      Returns:
      the connection to use
      Throws:
      SQLException
    • readOnlyConnection

      Connection readOnlyConnection(Object tenantId, boolean useMaster) throws SQLException
      Return a connection from the read only DataSource taking into account a tenantId for multi-tenant lazy loading.
      Parameters:
      tenantId - Most often null but well supplied indicates a multi-tenant lazy loading query
      useMaster - When true use the master data source
      Returns:
      the connection to use
      Throws:
      SQLException
    • shutdown

      void shutdown(boolean deregisterDriver)
      Shutdown the datasource de-registering the JDBC driver if requested.