mcconnell 2003/01/16 22:20:05
Modified: . cornerstone.xml
src/java/org/apache/avalon/cornerstone/blocks/datasource
DefaultDataSourceSelector.java
src/java/org/apache/avalon/cornerstone/services/datasource
DataSourceSelector.java
Added: . datasources.properties datasources.xml
src/java/org/apache/avalon/cornerstone/blocks/datasources
DefaultDataSourceSelector-schema.xml
DefaultDataSourceSelector.java
src/java/org/apache/avalon/cornerstone/services/datasources
DataSourceSelector.java
Removed: . source.properties source.xml
src/java/org/apache/avalon/cornerstone/blocks/source
DefaultDataSourceSelector-schema.xml
DefaultDataSourceSelector.java
src/java/org/apache/avalon/cornerstone/services/source
DataSourceSelector.java
Log:
Repacked the revised datasource package under "datasources".
Revision Changes Path
1.2 +5 -5 jakarta-avalon-cornerstone/cornerstone.xml
Index: cornerstone.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/cornerstone.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cornerstone.xml 15 Jan 2003 12:27:31 -0000 1.1
+++ cornerstone.xml 17 Jan 2003 06:20:05 -0000 1.2
@@ -7,7 +7,7 @@
<property file="default.properties"/>
<!-- Main target -->
- <target name="main"
depends="threads,sockets,scheduler,source,masterstore,connection"/>
+ <target name="main"
depends="threads,sockets,scheduler,datasources,masterstore,connection"/>
<target name="context">
<uptodate property="threads-uptodate"
targetfile="${build.dir}/lib/conerstone-threads-1.0.jar">
@@ -31,9 +31,9 @@
<include name="**/store/**/*.*"/>
</srcfiles>
</uptodate>
- <uptodate property="source-uptodate"
targetfile="${build.dir}/lib/conerstone-source-1.0.jar">
+ <uptodate property="datasources-uptodate"
targetfile="${build.dir}/lib/conerstone-datasources-1.0.jar">
<srcfiles dir="${src.dir}/java">
- <include name="**/source/**/*.*"/>
+ <include name="**/datasources/**/*.*"/>
</srcfiles>
</uptodate>
<uptodate property="connection-uptodate"
targetfile="${build.dir}/lib/conerstone-connection-1.0.jar">
@@ -59,8 +59,8 @@
<ant antfile="masterstore.xml" inheritall="false"/>
</target>
- <target name="source" depends="context" unless="source-uptodate">
- <ant antfile="source.xml" inheritall="false"/>
+ <target name="datasources" depends="context" unless="datasources-uptodate">
+ <ant antfile="datasources.xml" inheritall="false"/>
</target>
<target name="connection" depends="context" unless="connection-uptodate">
1.1 jakarta-avalon-cornerstone/datasources.properties
Index: datasources.properties
===================================================================
# -------------------------------------------------------------------
# B U I L D P R O P E R T I E S
# -------------------------------------------------------------------
# Specifies default property values
# Overridden by ../default.properties and all ant.properties
# Not user-editable; use ant.properties files instead
name=cornerstone-datasources
Name=Cornerstone Datasource
version=1.0
package-version=1.0
year=2003
extension.name=org.apache.avalon.conerstone.datasources
# location of intermediate products
build.dir = ${build.root}/${ant.project.name}
build.testsrc = ${build.dir}/testsrc
build.testclasses = ${build.dir}/testclasses
build.conf = ${build.dir}/conf
build.classes = ${build.dir}/classes
build.gen = ${build.dir}/gen
build.tests = ${build.dir}/tests
build.reports = ${build.dir}/reports
build.docs = ${build.dir}/docs
build.javadocs = ${build.docs}/api
# --------------------------------------------------
# REQUIRED LIBRARIES
# --------------------------------------------------
# ----- Excalibur threadcontext, version 1.0 or later -----
excalibur-datasource.home=${excalibur.home}/datasource
excalibur-datasource.lib=${excalibur-datasource.home}/build/lib
excalibur-datasource.jar=${excalibur-datasource.lib}/excalibur-datasource-1.0.jar
# ----- Excalibur pool, version 1.0 or later -----
excalibur-pool.home=${excalibur.home}/pool
excalibur-pool.lib=${excalibur-pool.home}/build/lib
excalibur-pool.jar=${excalibur-pool.lib}/excalibur-pool-1.1.jar
1.1 jakarta-avalon-cornerstone/datasources.xml
Index: datasources.xml
===================================================================
<project name="datasources" default="main" basedir=".">
<property file="ant.properties"/>
<property file="${user.home}/.ant.properties"/>
<property file="default.properties"/>
<property file="${ant.project.name}.properties"/>
<path id="project.class.path">
<pathelement location="${junit.jar}"/>
<pathelement location="${xerces.jar}"/>
<pathelement location="${xalan.jar}"/>
<pathelement location="${xml-apis.jar}"/>
<pathelement location="${avalon-framework.jar}"/>
<pathelement location="${excalibur-datasource.jar}"/>
<pathelement location="${excalibur-pool.jar}"/>
<pathelement location="${metagenerate.jar}"/>
<pathelement location="${qdox.jar}"/>
<pathelement path="${java.class.path}" />
<pathelement path="${build.classes}" />
</path>
<!-- Main target -->
<target name="main" depends="jars" description="Create minimal distribution" />
<!-- Compile the project -->
<target name="compile">
<mkdir dir="${build.classes}"/>
<javac srcdir="${java.dir}"
destdir="${build.classes}"
debug="${build.debug}"
optimize="${build.optimize}"
deprecation="${build.deprecation}">
<classpath refid="project.class.path" />
<src path="${java.dir}"/>
<include name="**/${ant.project.name}/**.*"/>
</javac>
</target>
<target name="metagenerate" description="Generates the XML descriptors">
<taskdef name="generatemeta"
classname="org.apache.avalon.phoenix.tools.metagenerate.MetaGenerateTask">
<classpath refid="project.class.path" />
</taskdef>
<generatemeta dest="${build.gen}">
<fileset dir="${java.dir}">
<include name="**/${ant.project.name}/*.java"/>
</fileset>
</generatemeta>
</target>
<!-- Creates all the .jar file -->
<target name="jars" depends="compile,metagenerate">
<mkdir dir="${build.lib}"/>
<mkdir dir="${build.gen}"/>
<jar jarfile="${build.lib}/${name}-${package-version}.jar"
basedir="${build.classes}">
<manifest>
<attribute name="Extension-Name" value="${extension.name}"/>
<attribute name="Specification-Vendor" value="${vendor}"/>
<attribute name="Specification-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${package-version}"/>
<attribute name="Extension-List" value="framework datasource"/>
<attribute name="framework-Extension-Name"
value="${avalon-framework.extension.name}"/>
<attribute name="framework-Specification-Version"
value="${avalon-framework.extension.version}"/>
<attribute name="framework-Implementation-Version"
value="${avalon-framework.extension.implementation}"/>
</manifest>
<include name="org/apache/avalon/cornerstone/blocks/${ant.project.name}/**"/>
<include name="org/apache/avalon/cornerstone/services/${ant.project.name}/**"/>
<fileset dir="${build.gen}">
<include name="**/${ant.project.name}/**/*.xinfo"/>
<include name="**${ant.project.name}/**/*.mxinfo"/>
</fileset>
<fileset dir="${src.dir}/java">
<include name="**/${ant.project.name}/**/*-schema.xml"/>
<include name="**/${ant.project.name}/**/*.xconfig"/>
</fileset>
</jar>
</target>
</project>
1.28 +1 -1
jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasource/DefaultDataSourceSelector.java
Index: DefaultDataSourceSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasource/DefaultDataSourceSelector.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- DefaultDataSourceSelector.java 15 Jan 2003 11:58:46 -0000 1.27
+++ DefaultDataSourceSelector.java 17 Jan 2003 06:20:05 -0000 1.28
@@ -48,7 +48,7 @@
* @phoenix:service
name="org.apache.avalon.cornerstone.services.datasource.DataSourceSelector"
*
* @author <a href="mailto:[EMAIL PROTECTED]">Eung-ju Park</a>
- * @deprecated Use {@link
org.apache.avalon.cornerstone.blocks.source.DefaultDataSourceSelector} instead.
+ * @deprecated Use {@link
org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector} instead.
*/
public class DefaultDataSourceSelector
extends AbstractLogEnabled
1.1
jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasources/DefaultDataSourceSelector-schema.xml
Index: DefaultDataSourceSelector-schema.xml
===================================================================
<?xml version="1.0"?>
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
xmlns:a="http://jakarta.apache.org/phoenix/schema-annotations/1.0"
>
<start>
<element name="root">
<element name="data-sources">
<oneOrMore>
<ref name="datasource"/>
</oneOrMore>
</element>
<oneOrMore>
<ref name="datasource"/>
</oneOrMore>
</element>
</start>
<define name="datasource" combine="choice">
<a:description>JDBC Data Source</a:description>
<element name="data-source">
<attribute name="name"/>
<attribute
name="class"><value>org.apache.avalon.excalibur.datasource.JdbcDataSource</value></attribute>
<interleave>
<element name="pool-controller">
<attribute name="min">
<data type="integer">
<param name="minInclusive">1</param>
</data>
</attribute>
<attribute name="max">
<data type="integer">
<param name="minInclusive">1</param>
</data>
</attribute>
<optional>
<attribute name="connection-class"/>
<element name="keep-alive"><text/></element>
</optional>
</element>
<element name="auto-commit"><data type="boolean"/></element>
<element name="driver"><text/></element>
<element name="dburl"><text/></element>
<optional>
<element name="user"><text/></element>
<element name="password"><text/></element>
</optional>
</interleave>
</element>
</define>
</grammar>
1.1
jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasources/DefaultDataSourceSelector.java
Index: DefaultDataSourceSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.cornerstone.blocks.datasources;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.LogEnabled;
/**
* A default implementation for DataSourceSelector.
* The Configuration is like this:
*
* <pre>
* <myBlock>
* <data-source name="<i>default</i>"
* class="<i>org.apache.avalon.excalibur.datasource.JdbcDataSource</i>">
* <!-- configuration for JdbcDataSource -->
* <pool-controller min="<i>5</i>" max="<i>10</i>"
connection-class="<i>my.overrided.ConnectionClass</i>">
* <keep-alive>select 1</keep-alive>
* </pool-controller>
* <driver><i>com.database.jdbc.JdbcDriver</i></driver>
* <dburl><i>jdbc:driver://host/mydb</i></dburl>
* <user><i>username</i></user>
* <password><i>password</i></password>
* </data-source>
* </myBlock>
* </pre>
*
* @phoenix:block
* @phoenix:service
name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public class DefaultDataSourceSelector
extends AbstractLogEnabled
implements DataSourceSelector, Contextualizable, Configurable, Initializable,
Disposable
{
private Configuration m_configuration;
private Map m_dataSources;
private String m_blockName;
public void contextualize( final Context context )
throws ContextException
{
try
{
m_blockName = (String) context.get("block.name");
}
catch( Throwable e )
{
m_blockName = "DataSourceSelector/" + System.identityHashCode( this );
}
}
/**
* @phoenix:configuration-schema type="relax-ng"
*/
public void configure( final Configuration configuration )
{
m_configuration = configuration;
}
public void initialize()
throws Exception
{
m_dataSources = new HashMap();
Configuration[] dataSourceConfs = getDataSourceConfig();
for( int i = 0; i < dataSourceConfs.length; i++ )
{
final Configuration dataSourceConf = dataSourceConfs[ i ];
final String name = dataSourceConf.getAttribute( "name" );
final String clazz = dataSourceConf.getAttribute( "class" );
final String driver = dataSourceConf.getChild( "driver", true
).getValue( "" );
final ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
DataSourceComponent component = null;
if( null == classLoader )
{
if( !"".equals( driver ) )
{
Class.forName( driver, true,
Thread.currentThread().getContextClassLoader() );
}
component = (DataSourceComponent)Class.forName( clazz
).newInstance();
}
else
{
if( !"".equals( driver ) )
{
classLoader.loadClass( driver );
}
component = (DataSourceComponent)classLoader.loadClass( clazz
).newInstance();
}
if( component instanceof LogEnabled )
{
setupLogger( component, name );
}
component.configure( dataSourceConf );
m_dataSources.put( name, component );
if( getLogger().isInfoEnabled() )
{
getLogger().info( "DataSource " + name + " ready" );
}
}
}
private Configuration[] getDataSourceConfig()
{
final Configuration head =
m_configuration.getChild( "data-sources" );
if( 0 != head.getChildren().length )
{
final String message =
"WARNING: Child node <data-sources/> in " +
"configuration of component named " + m_blockName +
" has been deprecated. Please put <data-source/> elements" +
" in root configuration element";
getLogger().warn( message );
System.out.println( message );
return head.getChildren( "data-source" );
}
else
{
return m_configuration.getChildren( "data-source" );
}
}
public void dispose()
{
if( getLogger().isDebugEnabled() )
{
getLogger().debug( "disposal" );
}
final Iterator keys = m_dataSources.keySet().iterator();
while( keys.hasNext() )
{
final DataSourceComponent dsc =
(DataSourceComponent)m_dataSources.get( keys.next() );
if( dsc instanceof Disposable )
{
((Disposable)dsc).dispose();
}
}
}
public boolean isSelectable( final Object hint )
{
return m_dataSources.containsKey( hint );
}
public Object select( final Object hint )
throws ServiceException
{
final Object component = m_dataSources.get( hint );
if( null == component )
{
throw new ServiceException( "Unable to provide DataSourceComponent for "
+ hint );
}
return component;
}
public void release( final Object component )
{
//do nothing
}
}
1.11 +1 -1
jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/datasource/DataSourceSelector.java
Index: DataSourceSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/datasource/DataSourceSelector.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DataSourceSelector.java 15 Jan 2003 11:59:00 -0000 1.10
+++ DataSourceSelector.java 17 Jan 2003 06:20:05 -0000 1.11
@@ -13,7 +13,7 @@
* DataSourceSelector
*
* @author <a href="mailto:[EMAIL PROTECTED]">Eung-ju Park</a>
- * @deprecated Use {@link
org.apache.avalon.cornerstone.services.source.DataSourceSelector} instead.
+ * @deprecated Use {@link
org.apache.avalon.cornerstone.services.datasources.DataSourceSelector} instead.
*/
public interface DataSourceSelector
extends ComponentSelector
1.1
jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/datasources/DataSourceSelector.java
Index: DataSourceSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.cornerstone.services.datasources;
import org.apache.avalon.framework.service.ServiceSelector;
/**
* DataSourceSelector
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public interface DataSourceSelector
extends ServiceSelector
{
String ROLE = DataSourceSelector.class.getName();
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>