Interface ConnectionSchemaInitializer

All Superinterfaces:
org.springframework.core.Ordered
All Known Implementing Classes:
MariaDBConnectionSchemaInitializer, MySqlConnectionSchemaInitializer, OracleConnectionSchemaInitializer, PostgresConnectionSchemaInitializer, YugabytedbConnectionSchemaInitializer

public interface ConnectionSchemaInitializer extends org.springframework.core.Ordered
Initialize a connection pulled from a common datasource and establish the schema used during the connection session. This functionality is primarily used during connection retrieval from SchemaDelegatingDataSource.

Customization for this component is generally achieved by declaring a custom instance of ConnectionSchemaInitializer as a Bean with a higher precedence order. That custom bean will be used preferably over already existing initializer beans in Broadleaf.
Author:
Jeff Fischer
  • Method Details

    • getOrder

      default int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • initialize

      boolean initialize(Connection toInitialize, String schema)
      Initialize the connection, setting the current schema for the connection session.
      Parameters:
      toInitialize - The connection from the datasource to initialize
      schema - The schema to set as the default for the connection session
      Returns:
      whether or not the initializer was qualified to operate on the connection and did indeed perform the initialization
    • forgetSchema

      default void forgetSchema(Connection connection)
      Parameters:
      connection - A connection pool member associated with a particular schema
    • rememberSchema

      default void rememberSchema(String schema, Connection connection)
      Parameters:
      schema - The current established schema for the session of the connection in the connection pool
      connection - A connection pool member associated with a particular schema
    • requiresInit

      default boolean requiresInit(String schema, Connection connection)
      Determine if the schema currently established for the session on the connection (if any) is the same as the requested schema. If not, the connection requires initialization for the requested schema.
      Parameters:
      schema - The schema requested to establish for the connection session
      connection - A connection pool member associated with a particular schema
      Returns:
      Whether connection initialization is required for the requested schema
    • getRoot

      default Connection getRoot(Connection connection)
      Recursively unwrap a connection until the original connection is returned.
      Parameters:
      connection - The connection instance from the pool that is possibly a proxy
      Returns:
      The original connection