Class DataSourceWrapper
- java.lang.Object
-
- de.aristaflow.adept2.base.registry.dbconfiguration.DataSourceWrapper
-
- All Implemented Interfaces:
Wrapper
,CommonDataSource
,DataSource
public class DataSourceWrapper extends Object implements DataSource
A simple wrapper for aJDBCDataSource
which is required byDatabaseConfiguration
. Note that onlygetConnection()
is implemented. All other methods throw anUnsupportedOperationException
.
This implementation needs to be changed as soon asDatabaseConfiguration
uses more thangetConnection()
.- Author:
- Ulrich Kreher
-
-
Field Summary
Fields Modifier and Type Field Description protected JDBCDataSource
dataSource
The data source providing the connection.protected static String
unsupported
The message for theUnsupportedOperationException
s thrown by all methods exceptgetConnection()
.
-
Constructor Summary
Constructors Constructor Description DataSourceWrapper(JDBCDataSource dataSource)
Creates aDataSource
providing a connection from the designatedJDBCDataSource
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Connection
getConnection()
Connection
getConnection(String username, String password)
int
getLoginTimeout()
PrintWriter
getLogWriter()
Logger
getParentLogger()
boolean
isWrapperFor(Class<?> iface)
void
setLoginTimeout(int seconds)
void
setLogWriter(PrintWriter out)
<T> T
unwrap(Class<T> iface)
-
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
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
-
-
-
Field Detail
-
unsupported
protected static final String unsupported
The message for theUnsupportedOperationException
s thrown by all methods exceptgetConnection()
.- See Also:
- Constant Field Values
-
dataSource
protected final JDBCDataSource dataSource
The data source providing the connection.
-
-
Constructor Detail
-
DataSourceWrapper
public DataSourceWrapper(JDBCDataSource dataSource)
Creates aDataSource
providing a connection from the designatedJDBCDataSource
.- Parameters:
dataSource
- The data source providing the connection.
-
-
Method Detail
-
getConnection
public Connection getConnection() throws SQLException
- Specified by:
getConnection
in interfaceDataSource
- Throws:
SQLException
-
getConnection
public Connection getConnection(String username, String password)
- Specified by:
getConnection
in interfaceDataSource
-
getLoginTimeout
public int getLoginTimeout()
- Specified by:
getLoginTimeout
in interfaceCommonDataSource
- Specified by:
getLoginTimeout
in interfaceDataSource
-
getLogWriter
public PrintWriter getLogWriter()
- Specified by:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
-
setLoginTimeout
public void setLoginTimeout(int seconds)
- Specified by:
setLoginTimeout
in interfaceCommonDataSource
- Specified by:
setLoginTimeout
in interfaceDataSource
-
setLogWriter
public void setLogWriter(PrintWriter out)
- Specified by:
setLogWriter
in interfaceCommonDataSource
- Specified by:
setLogWriter
in interfaceDataSource
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfaceCommonDataSource
- Throws:
SQLFeatureNotSupportedException
-
-