org.springbyexample.jdbc.datasource
Class InitializingBasicDataSource

java.lang.Object
  extended by org.apache.commons.dbcp.BasicDataSource
      extended by org.springbyexample.jdbc.datasource.InitializingBasicDataSource
All Implemented Interfaces:
DataSource, DisposableBean, InitializingBean

public class InitializingBasicDataSource
extends BasicDataSource
implements InitializingBean, DisposableBean

Initializing version of BasicDataSource. After the properties are set any database initialization scripts are run. This is very useful for unit testing.

Author:
David Winterfeldt
See Also:
BasicDataSource, SqlScriptProcessor

Field Summary
protected  SqlScriptProcessor sqlScriptProcessor
           
 
Fields inherited from class org.apache.commons.dbcp.BasicDataSource
connectionPool, connectionProperties, dataSource, defaultAutoCommit, defaultCatalog, defaultReadOnly, defaultTransactionIsolation, driverClassName, initialSize, logWriter, maxActive, maxIdle, maxOpenPreparedStatements, maxWait, minEvictableIdleTimeMillis, minIdle, numTestsPerEvictionRun, password, poolPreparedStatements, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, url, username, validationQuery
 
Constructor Summary
InitializingBasicDataSource()
           
 
Method Summary
 void afterPropertiesSet()
          Implementation of InitializingBean
 void destroy()
          Implementation of DisposableBean
 boolean isWrapperFor(Class<?> iface)
           
 void setSqlScriptProcessor(SqlScriptProcessor sqlScriptProcessor)
          Sets SQL script processor.
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class org.apache.commons.dbcp.BasicDataSource
addConnectionProperty, close, createDataSource, getConnection, getConnection, getConnectionPool, getDefaultAutoCommit, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getDriverClassName, getInitialSize, getLogAbandoned, getLoginTimeout, getLogWriter, getMaxActive, getMaxIdle, getMaxOpenPreparedStatements, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getPassword, getRemoveAbandoned, getRemoveAbandonedTimeout, getTestOnBorrow, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getUrl, getUsername, getValidationQuery, isAccessToUnderlyingConnectionAllowed, isPoolPreparedStatements, removeConnectionProperty, setAccessToUnderlyingConnectionAllowed, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDriverClassName, setInitialSize, setLogAbandoned, setLoginTimeout, setLogWriter, setMaxActive, setMaxIdle, setMaxOpenPreparedStatements, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setPassword, setPoolPreparedStatements, setRemoveAbandoned, setRemoveAbandonedTimeout, setTestOnBorrow, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setUrl, setUsername, setValidationQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sqlScriptProcessor

protected SqlScriptProcessor sqlScriptProcessor
Constructor Detail

InitializingBasicDataSource

public InitializingBasicDataSource()
Method Detail

setSqlScriptProcessor

public void setSqlScriptProcessor(SqlScriptProcessor sqlScriptProcessor)
Sets SQL script processor.


afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Implementation of InitializingBean

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception
Implementation of DisposableBean

Specified by:
destroy in interface DisposableBean
Throws:
Exception

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Throws:
SQLException


Copyright © 2008 Spring by Example. All Rights Reserved.