org.skife.jdbi.spring
Class DBIBean

java.lang.Object
  extended by org.skife.jdbi.spring.DBIBean

public class DBIBean
extends java.lang.Object

Used to provide an IDBI instance to a Spring bean factory

Configuration might look like:


 <beans>
  <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="location">
          <value>WEB-INF/jdbc.properties</value>
      </property>
  </bean>

  <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource">
          <ref local="dataSource"/>
      </property>
  </bean>

  <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName">
          <value>${jdbc.driver}</value>
      </property>
      <property name="url">
          <value>${jdbc.url}</value>
      </property>
  </bean>

  <bean id="dbi" class="org.skife.jdbi.spring.DBIBean">
      <property name="dataSource"><ref bean="dataSource" /></property>
  </bean>
 </beans>
 
The only configuration needed for the IDBI instance is the last bean entry, dbi, but the rest sets up a typical local datasource.


Constructor Summary
DBIBean()
           
 
Method Summary
 void afterPropertiesSet()
          Ensures that a datasource has been set
 javax.sql.DataSource getDataSource()
           
 java.lang.Object getObject()
           
 java.lang.Class getObjectType()
           
 boolean isSingleton()
           
 void setDataSource(javax.sql.DataSource dataSource)
          Specify the datasource to be used to draw connections from.
 void setHandleDecoratorBuilder(HandleDecorator builder)
          Specify a decorator builder to decorate all handles created by this DBI instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBIBean

public DBIBean()
Method Detail

getDataSource

public javax.sql.DataSource getDataSource()

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Specify the datasource to be used to draw connections from. Any transaction manager managing the datasource will also provide transaction demarcation for the IDBI built.

Parameters:
dataSource -

setHandleDecoratorBuilder

public void setHandleDecoratorBuilder(HandleDecorator builder)
Specify a decorator builder to decorate all handles created by this DBI instance


getObject

public java.lang.Object getObject()
                           throws java.lang.Exception
Throws:
java.lang.Exception

getObjectType

public java.lang.Class getObjectType()

isSingleton

public boolean isSingleton()
Returns:
true

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Ensures that a datasource has been set

Throws:
java.lang.IllegalStateException - if no datasource has been set
java.lang.Exception