Package org.apache.openjpa.slice.jdbc
Class DistributedDataSource
- java.lang.Object
-
- org.apache.openjpa.lib.jdbc.DelegatingDataSource
-
- org.apache.openjpa.lib.jdbc.DecoratingDataSource
-
- org.apache.openjpa.slice.jdbc.DistributedDataSource
-
- All Implemented Interfaces:
Iterable<DataSource>
,Wrapper
,CommonDataSource
,DataSource
,Closeable
public class DistributedDataSource extends DecoratingDataSource implements Iterable<DataSource>
A virtual datasource that contains many physical datasources.- Author:
- Pinaki Poddar
-
-
Constructor Summary
Constructors Constructor Description DistributedDataSource(List<DataSource> dataSources)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDataSource(DataSource ds)
Connection
getConnection()
Connection
getConnection(String username, String password)
int
getLoginTimeout()
PrintWriter
getLogWriter()
Logger
getParentLogger()
Iterator<DataSource>
iterator()
void
setLoginTimeout(int seconds)
void
setLogWriter(PrintWriter out)
-
Methods inherited from class org.apache.openjpa.lib.jdbc.DecoratingDataSource
addDecorator, addDecorators, clearDecorators, getDecorators, removeDecorator
-
Methods inherited from class org.apache.openjpa.lib.jdbc.DelegatingDataSource
appendInfo, close, equals, getDelegate, getInnermostDelegate, hashCode, isWrapperFor, toString, unwrap
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
DistributedDataSource
public DistributedDataSource(List<DataSource> dataSources)
-
-
Method Detail
-
addDataSource
public void addDataSource(DataSource ds)
-
iterator
public Iterator<DataSource> iterator()
- Specified by:
iterator
in interfaceIterable<DataSource>
-
getConnection
public Connection getConnection() throws SQLException
- Specified by:
getConnection
in interfaceDataSource
- Overrides:
getConnection
in classDecoratingDataSource
- Throws:
SQLException
-
getConnection
public Connection getConnection(String username, String password) throws SQLException
- Specified by:
getConnection
in interfaceDataSource
- Overrides:
getConnection
in classDecoratingDataSource
- Throws:
SQLException
-
getLogWriter
public PrintWriter getLogWriter() throws SQLException
- Specified by:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
- Overrides:
getLogWriter
in classDelegatingDataSource
- Throws:
SQLException
-
getLoginTimeout
public int getLoginTimeout() throws SQLException
- Specified by:
getLoginTimeout
in interfaceCommonDataSource
- Specified by:
getLoginTimeout
in interfaceDataSource
- Overrides:
getLoginTimeout
in classDelegatingDataSource
- Throws:
SQLException
-
setLogWriter
public void setLogWriter(PrintWriter out) throws SQLException
- Specified by:
setLogWriter
in interfaceCommonDataSource
- Specified by:
setLogWriter
in interfaceDataSource
- Overrides:
setLogWriter
in classDelegatingDataSource
- Throws:
SQLException
-
setLoginTimeout
public void setLoginTimeout(int seconds) throws SQLException
- Specified by:
setLoginTimeout
in interfaceCommonDataSource
- Specified by:
setLoginTimeout
in interfaceDataSource
- Overrides:
setLoginTimeout
in classDelegatingDataSource
- Throws:
SQLException
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfaceCommonDataSource
- Overrides:
getParentLogger
in classDelegatingDataSource
- Throws:
SQLFeatureNotSupportedException
-
-