Class SchemaDelegatingDataSource
- java.lang.Object
-
- org.springframework.jdbc.datasource.AbstractDataSource
-
- com.broadleafcommerce.common.jpa.data.SchemaDelegatingDataSource
-
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
public class SchemaDelegatingDataSource extends org.springframework.jdbc.datasource.AbstractDataSource implements DataSource
DataSource capable of delegating connection acquisition to another datasource, but performing connection initialization on retrieved connections before passing to the caller. The initialization specifically focuses on setting the default schema for the connection session. The assumption is that this datasource is backed by a common pool that generically targets a JDBC url without specifying schema information. This common pool can then be leveraged by multiple SchemaDelegatingDataSource instances, each targeting a different schema. This is primarily useful for uber installations that leverage multiple services in the same JVM using a higher levelRoutableDataSource. SeeJpaDataRoutefor more information.- Author:
- Jeff Fischer
-
-
Constructor Summary
Constructors Constructor Description SchemaDelegatingDataSource(DataSource delegate, String schema, List<ConnectionSchemaInitializer> initializers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectiongetConnection()ConnectiongetConnection(String username, String password)booleanisWrapperFor(Class<?> iface)<T> Tunwrap(Class<T> iface)-
Methods inherited from class org.springframework.jdbc.datasource.AbstractDataSource
getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLogger
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
-
-
-
-
Constructor Detail
-
SchemaDelegatingDataSource
public SchemaDelegatingDataSource(DataSource delegate, String schema, List<ConnectionSchemaInitializer> initializers)
-
-
Method Detail
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Overrides:
unwrapin classorg.springframework.jdbc.datasource.AbstractDataSource- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Overrides:
isWrapperForin classorg.springframework.jdbc.datasource.AbstractDataSource- Throws:
SQLException
-
getConnection
public Connection getConnection() throws SQLException
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
public Connection getConnection(String username, String password) throws SQLException
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
-