public class DelegatingDataSource extends Object implements DataSource, InitializingBean
DataSource implementation that delegates all calls
to a given target DataSource.
This class is meant to be subclassed, with subclasses overriding only
those methods (such as getConnection()) that should not simply
delegate to the target DataSource.
getConnection()| Constructor and Description |
|---|
DelegatingDataSource()
Create a new DelegatingDataSource.
|
DelegatingDataSource(DataSource targetDataSource)
Create a new DelegatingDataSource.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc. |
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
DataSource |
getTargetDataSource()
Return the target DataSource that this DataSource should delegate to.
|
boolean |
isWrapperFor(Class<?> iface) |
protected DataSource |
obtainTargetDataSource()
Obtain the target
DataSource for actual use (never null). |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
void |
setTargetDataSource(DataSource targetDataSource)
Set the target DataSource that this DataSource should delegate to.
|
<T> T |
unwrap(Class<T> iface) |
public DelegatingDataSource()
public DelegatingDataSource(DataSource targetDataSource)
targetDataSource - the target DataSourcepublic void setTargetDataSource(@Nullable DataSource targetDataSource)
@Nullable public DataSource getTargetDataSource()
protected DataSource obtainTargetDataSource()
DataSource for actual use (never null).public void afterPropertiesSet()
InitializingBeanBeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet in interface InitializingBeanpublic Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic Connection getConnection(String username, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter out) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int seconds)
throws SQLException
setLoginTimeout in interface CommonDataSourceSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic Logger getParentLogger()
getParentLogger in interface CommonDataSource