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
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
forgetSchema
(Connection connection) Clear any reference inSchemaDelegatingDataSource.getSchemaReferenceCache()
default int
getOrder()
default Connection
getRoot
(Connection connection) Recursively unwrap a connection until the original connection is returned.boolean
initialize
(Connection toInitialize, String schema) Initialize the connection, setting the current schema for the connection session.default void
rememberSchema
(String schema, Connection connection) Set a reference inSchemaDelegatingDataSource.getSchemaReferenceCache()
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.
-
Method Details
-
getOrder
default int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
initialize
Initialize the connection, setting the current schema for the connection session.- Parameters:
toInitialize
- The connection from the datasource to initializeschema
- 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
Clear any reference inSchemaDelegatingDataSource.getSchemaReferenceCache()
- Parameters:
connection
- A connection pool member associated with a particular schema
-
rememberSchema
Set a reference inSchemaDelegatingDataSource.getSchemaReferenceCache()
- Parameters:
schema
- The current established schema for the session of the connection in the connection poolconnection
- A connection pool member associated with a particular schema
-
requiresInit
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 sessionconnection
- A connection pool member associated with a particular schema- Returns:
- Whether connection initialization is required for the requested schema
-
getRoot
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
-