org.springframework.jdbc.datasource
Class DelegatingDataSource

java.lang.Object
  extended byorg.springframework.jdbc.datasource.DelegatingDataSource
All Implemented Interfaces:
javax.sql.DataSource, InitializingBean
Direct Known Subclasses:
TransactionAwareDataSourceProxy, UserCredentialsDataSourceAdapter

public abstract class DelegatingDataSource
extends java.lang.Object
implements javax.sql.DataSource, InitializingBean

DataSource implementation that delegates all calls to a given target DataSource. Abstract because it is meant to be to be subclasses, overriding specific methods that should not simply delegate to the target.

Since:
19.07.2004
Author:
Juergen Hoeller

Constructor Summary
DelegatingDataSource()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
           
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 javax.sql.DataSource getTargetDataSource()
          Return the target DataSource that this DataSource should delegate to.
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter out)
           
 void setTargetDataSource(javax.sql.DataSource targetDataSource)
          Set the target DataSource that this DataSource should delegate to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingDataSource

public DelegatingDataSource()
Method Detail

setTargetDataSource

public void setTargetDataSource(javax.sql.DataSource targetDataSource)
Set the target DataSource that this DataSource should delegate to.


getTargetDataSource

public javax.sql.DataSource getTargetDataSource()
Return the target DataSource that this DataSource should delegate to.


afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
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
Throws:
java.sql.SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Specified by:
getLoginTimeout in interface javax.sql.DataSource
Throws:
java.sql.SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException
Specified by:
setLoginTimeout in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Specified by:
getLogWriter in interface javax.sql.DataSource
Throws:
java.sql.SQLException

setLogWriter

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


Copyright (C) 2003-2004 The Spring Framework Project.