org.apache.avalon.cornerstone.blocks.datasources
Class DefaultDataSourceSelector

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector
All Implemented Interfaces:
org.apache.avalon.cornerstone.services.datasources.DataSourceSelector, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.ServiceSelector

public class DefaultDataSourceSelector
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.cornerstone.services.datasources.DataSourceSelector, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.activity.Disposable

A default implementation for DataSourceSelector. The Configuration is like this:

 <myBlock>
   <data-source name="default"
     class="org.apache.avalon.excalibur.datasource.JdbcDataSource">
     <!-- configuration for JdbcDataSource -->
     <pool-controller min="5" max="10" connection-class="my.overrided.ConnectionClass">
       <keep-alive>select 1</keep-alive>
     </pool-controller>
     <driver>com.database.jdbc.JdbcDriver</driver>
     <dburl>jdbc:driver://host/mydb</dburl>
     <user>username</user>
     <password>password</password>
   </data-source>
 </myBlock>
 

Author:
Avalon Development Team

Field Summary
private  java.lang.String m_blockName
           
private  org.apache.avalon.framework.configuration.Configuration m_configuration
           
private  java.util.Map m_dataSources
           
 
Fields inherited from interface org.apache.avalon.cornerstone.services.datasources.DataSourceSelector
ROLE
 
Constructor Summary
DefaultDataSourceSelector()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void contextualize(org.apache.avalon.framework.context.Context context)
          Contextualization of the component by the container.
 void dispose()
           
private  org.apache.avalon.framework.configuration.Configuration[] getDataSourceConfig()
           
 void initialize()
           
 boolean isSelectable(java.lang.Object hint)
           
 void release(java.lang.Object component)
           
 java.lang.Object select(java.lang.Object hint)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_configuration

private org.apache.avalon.framework.configuration.Configuration m_configuration

m_dataSources

private java.util.Map m_dataSources

m_blockName

private java.lang.String m_blockName
Constructor Detail

DefaultDataSourceSelector

public DefaultDataSourceSelector()
Method Detail

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Contextualization of the component by the container.

Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable
Parameters:
context - the supplied context object
Throws:
org.apache.avalon.framework.context.ContextException

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception

getDataSourceConfig

private org.apache.avalon.framework.configuration.Configuration[] getDataSourceConfig()

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

isSelectable

public boolean isSelectable(java.lang.Object hint)
Specified by:
isSelectable in interface org.apache.avalon.framework.service.ServiceSelector

select

public java.lang.Object select(java.lang.Object hint)
                        throws org.apache.avalon.framework.service.ServiceException
Specified by:
select in interface org.apache.avalon.framework.service.ServiceSelector
Throws:
org.apache.avalon.framework.service.ServiceException

release

public void release(java.lang.Object component)
Specified by:
release in interface org.apache.avalon.framework.service.ServiceSelector