org.apache.openjpa.slice.jdbc
Class DistributedDataSource

java.lang.Object
  extended by org.apache.openjpa.lib.jdbc.DelegatingDataSource
      extended by org.apache.openjpa.lib.jdbc.DecoratingDataSource
          extended by org.apache.openjpa.slice.jdbc.DistributedDataSource
All Implemented Interfaces:
java.lang.Iterable<javax.sql.DataSource>, java.sql.Wrapper, javax.sql.CommonDataSource, javax.sql.DataSource, Closeable

public class DistributedDataSource
extends DecoratingDataSource
implements java.lang.Iterable<javax.sql.DataSource>

A virtual datasource that contains many physical datasources.

Author:
Pinaki Poddar

Constructor Summary
DistributedDataSource(java.util.List<javax.sql.DataSource> dataSources)
           
 
Method Summary
 void addDataSource(javax.sql.DataSource ds)
           
protected  void enforceAbstract()
          Marker to enforce that subclasses of this class are abstract.
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
           
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 java.util.logging.Logger getParentLogger()
           
 java.util.Iterator<javax.sql.DataSource> iterator()
           
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter out)
           
 
Methods inherited from class org.apache.openjpa.lib.jdbc.DecoratingDataSource
addDecorator, addDecorators, clearDecorators, getDecorators, newDecoratingDataSource, removeDecorator
 
Methods inherited from class org.apache.openjpa.lib.jdbc.DelegatingDataSource
appendInfo, close, equals, getDelegate, getInnermostDelegate, hashCode, isWrapperFor, newInstance, toString, unwrap
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistributedDataSource

public DistributedDataSource(java.util.List<javax.sql.DataSource> dataSources)
Method Detail

addDataSource

public void addDataSource(javax.sql.DataSource ds)

iterator

public java.util.Iterator<javax.sql.DataSource> iterator()
Specified by:
iterator in interface java.lang.Iterable<javax.sql.DataSource>

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Overrides:
getConnection in class DecoratingDataSource
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Overrides:
getConnection in class DecoratingDataSource
Throws:
java.sql.SQLException

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Specified by:
getLogWriter in interface javax.sql.CommonDataSource
Overrides:
getLogWriter in class DelegatingDataSource
Throws:
java.sql.SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Specified by:
getLoginTimeout in interface javax.sql.CommonDataSource
Overrides:
getLoginTimeout in class DelegatingDataSource
Throws:
java.sql.SQLException

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws java.sql.SQLException
Specified by:
setLogWriter in interface javax.sql.CommonDataSource
Overrides:
setLogWriter in class DelegatingDataSource
Throws:
java.sql.SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException
Specified by:
setLoginTimeout in interface javax.sql.CommonDataSource
Overrides:
setLoginTimeout in class DelegatingDataSource
Throws:
java.sql.SQLException

enforceAbstract

protected void enforceAbstract()
Description copied from class: DelegatingDataSource
Marker to enforce that subclasses of this class are abstract.

Specified by:
enforceAbstract in class DelegatingDataSource

getParentLogger

public java.util.logging.Logger getParentLogger()
                                         throws java.sql.SQLFeatureNotSupportedException
Throws:
java.sql.SQLFeatureNotSupportedException