Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2491 - in development/laboratory/components/dbcp: . impl/src/main/net/dpml/dbcp impl/src/main/net/dpml/dbcp/impl

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT hedhman.org
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2491 - in development/laboratory/components/dbcp: . impl/src/main/net/dpml/dbcp impl/src/main/net/dpml/dbcp/impl
  • Date: Tue, 10 May 2005 12:34:44 +0000

Author: niclas AT hedhman.org
Date: Tue May 10 12:34:43 2005
New Revision: 2491

Added:
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/

development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/DbcpConnectionManager.java
- copied, changed from r2473,
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/DbcpConnectionManager.java
development/laboratory/components/dbcp/index.xml (contents, props
changed)
development/laboratory/components/dbcp/module.xml (contents, props
changed)
Removed:

development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/DbcpConnectionManager.java
Log:
Starting the clean up of DBCP as well.

Copied:
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/DbcpConnectionManager.java
(from r2473,
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/DbcpConnectionManager.java)
==============================================================================
---
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/DbcpConnectionManager.java
(original)
+++
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/DbcpConnectionManager.java
Tue May 10 12:34:43 2005
@@ -1,16 +1,16 @@
-/*
+/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * You may obtain a copy of the License at
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
- *
+ *
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@@ -45,30 +45,30 @@
*
* @metro.component name="dbcp-manager" lifestyle="singleton"
* @metro.service type="net.dpml.dbcp.ConnectionManager"
- *
+ *
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.2 $ $Date: 2004/05/11 21:24:24 $
*/
public class DbcpConnectionManager
- implements
- Contextualizable,
- Configurable,
- Initializable,
+ implements
+ Contextualizable,
+ Configurable,
+ Initializable,
Disposable,
- ConnectionManager
+ ConnectionManager
{
- //---------------------------------------------------------
- // state
- //---------------------------------------------------------
-
- /**
- * The logging channel assigned by the container.
- */
- private Logger m_logger;
- /**
- * The working base directory.
- */
- private File m_basedir;
+ //---------------------------------------------------------
+ // state
+ //---------------------------------------------------------
+
+ /**
+ * The logging channel assigned by the container.
+ */
+ private Logger m_logger;
+ /**
+ * The working base directory.
+ */
+ private File m_basedir;
/**
* Connection pool configuration parameters.
*/
@@ -77,7 +77,7 @@
* Set of datasource configuration parameters.
*/
private Configuration[] m_datasources;
-
+
//---------------------------------------------------------
// constructor
//---------------------------------------------------------
@@ -111,22 +111,22 @@
m_basedir = getBaseDirectory( context );
}

- //---------------------------------------------------------
- // Configurable
- //---------------------------------------------------------
-
- /**
- * Configuration of the server by the container.
- *
- * @param config the supplied server configuration
- * @exception ConfigurationException if a configuration error occurs
- */
- public void configure( final Configuration config )
+ //---------------------------------------------------------
+ // Configurable
+ //---------------------------------------------------------
+
+ /**
+ * Configuration of the server by the container.
+ *
+ * @param config the supplied server configuration
+ * @exception ConfigurationException if a configuration error occurs
+ */
+ public void configure( final Configuration config )
throws ConfigurationException
{
// cache away the connection pool settings...
m_pool = config.getChild( "pool", false );
-
+
// cache away the datasources settings...
Configuration datasources = config.getChild( "datasources", false );
if ( datasources == null )
@@ -153,7 +153,7 @@
}
}
}
- }
+ }

//---------------------------------------------------------
// Initializable
@@ -161,17 +161,17 @@

/**
* Initialization of the component by the container.
- *
+ *
* @throws Exception if an error occurs while initializing
* the component
*/
- public void initialize() throws Exception {
+ public void initialize() throws Exception {
m_logger.debug( "Initializing..." );
-
+
// First, let's load the DBCP's pooling driver class
m_logger.debug( "Loading DBCP Pooling Driver class..." );
Class.forName("org.apache.commons.dbcp.PoolingDriver");
-
+
// loop through all the configured datasources...
for ( int i = 0; i < m_datasources.length; i++ )
{
@@ -181,48 +181,48 @@
boolean isDefault = datasource.getAttributeAsBoolean( "default",
false );
m_logger.debug( "Processing datasource [" + name + "]" +
" (default=" + isDefault + ")");
-
+
// create an object pool that will actually hold our connections
ObjectPool connectionPool = createObjectPool();
m_logger.debug( "Object pool created..." );
-
+
// load the underlying JDBC driver of the datasource
loadJDBCDriver( datasource );
m_logger.debug( "Underlying JDBC driver loaded..." );
-
+
// create a driver manager connection factory that will be
// used to actually create the database connection(s)
ConnectionFactory connectionFactory = createConnectionFactory(
datasource );
m_logger.debug( "Connection factory created..." );
-
+
// create a poolable connection factory wrapper
PoolableConnectionFactory poolableConnectionFactory =
createPoolableConnectionFactory( connectionFactory,
connectionPool,
datasource );
m_logger.debug( "Poolable connection factory created..." );
-
- // get an instance of the DBCP pooling driver...
+
+ // get an instance of the DBCP pooling driver...
PoolingDriver driver = (PoolingDriver)
DriverManager.getDriver("jdbc:apache:commons:dbcp:");
m_logger.debug( "Pooling driver instance obtained..." );
-
+
// register our pool with it...
driver.registerPool( name, connectionPool );
-
+
// is this the default datasource?
if ( isDefault )
{
driver.registerPool( "default", connectionPool );
}
}
- }
+ }

//---------------------------------------------------------
// Disposable
//---------------------------------------------------------

/**
- * Cleans up the component.
+ * Cleans up the component.
*/
public void dispose() {
try
@@ -241,31 +241,31 @@
m_logger.warn( e.getMessage() );
}
}
-
- /**
+
+ /**
* Returns a <code>java.sql.Connection</code> to the default data source.
- *
+ *
* @return a <code>java.sql.Connection</code> to the default data source
- */
- public Connection getConnection() throws SQLException {
- return
DriverManager.getConnection("jdbc:apache:commons:dbcp:default");
- }
+ */
+ public Connection getConnection() throws SQLException {
+ return
DriverManager.getConnection("jdbc:apache:commons:dbcp:default");
+ }

- /**
+ /**
* Returns a <code>java.sql.Connection</code> to the specified data
source.
- *
+ *
* @param datasource the name of the data source to obtain a connection
to
* @return a <code>java.sql.Connection</code> to the specified data
source
- */
- public Connection getConnection(String datasource) throws
SQLException {
+ */
+ public Connection getConnection(String datasource) throws SQLException {
return DriverManager.getConnection("jdbc:apache:commons:dbcp:" +
datasource);
- }
+ }

/**
* Returns an object pool configuration object populated with data
* retrieved from the component's configuration. Defaults correspond
* to the <code>GenericObjectPool</code> default values.
- *
+ *
* @return <code>GenericObjectPool.Config</code> instance containing
* the pool's configuration parameters
*/
@@ -298,17 +298,17 @@
}
return config;
}
-
+
/**
* Creates an <code>GenericObjectPool</code> instance that serves
* as a the actual pool of connections.
- *
+ *
* @return <code>GenericObjectPool</code> instance.
*/
private ObjectPool createObjectPool()
{
ObjectPool pool = null;
-
+
// We'll need a ObjectPool that serves as the actual pool
// of connections. We'll use a GenericObjectPool instance.
if ( m_pool == null )
@@ -321,10 +321,10 @@
}
return pool;
}
-
+
/**
* Loads the underlying JDBC driver defined for the datasource.
- *
+ *
* @param datasource the datasource
* @throws DriverNotFoundException if the datasource directive is missing
* the 'driver' directive in the configuration
@@ -347,11 +347,11 @@
String driver = datasource.getChild( "driver" ).getValue();
Class.forName( driver );
}
-
+
}
-
+
/**
- *
+ *
* @param datasource
* @return
* @throws DbUrlNotFoundException
@@ -363,7 +363,7 @@
{
ConnectionFactory connectionFactory = null;
String dbUrl = null;
-
+
if ( datasource.getChild( "db-url", false ) == null)
{
throw new DbUrlNotFoundException( "Database URL not defined " +
@@ -375,14 +375,14 @@
}
String uname = datasource.getChild( "username" ).getValue( "" );
String pword = datasource.getChild(" password" ).getValue( "" );
-
+
connectionFactory = new DriverManagerConnectionFactory( dbUrl,
uname, pword);
-
+
return connectionFactory;
}
-
+
/**
- *
+ *
* @param connFactory
* @param pool
* @param datasource
@@ -401,22 +401,22 @@
}
boolean readonly = datasource.getChild( "read-only"
).getValueAsBoolean( false );
boolean autocommit = datasource.getChild( "auto-commit"
).getValueAsBoolean( true );
-
+
factory = new PoolableConnectionFactory( connFactory, pool,
null, query, readonly, autocommit );
return factory;
}
-
+
/**
* Return the working base directory.
- *
+ *
* @param context the supplied server context
* @return a <code>File</code> object representing the working
* base directory
* @exception ContextException if a contextualization error occurs
*/
- private File getBaseDirectory( final Context context )
- throws ContextException
+ private File getBaseDirectory( final Context context )
+ throws ContextException
{
File home = (File) context.get( "urn:avalon:home" );
if ( !home.exists() )
@@ -434,7 +434,7 @@
}
return home;
}
-
+
/**
* Return the assigned logging channel.
* @return the logging channel

Added: development/laboratory/components/dbcp/index.xml
==============================================================================
--- (empty file)
+++ development/laboratory/components/dbcp/index.xml Tue May 10 12:34:43
2005
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Copyright 2005 Niclas Hedman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.dpml.net/central/about/legal/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<index>
+ <import uri="artifact:module:dpml/magic/dpml-magic#SNAPSHOT" />
+ <import uri="artifact:module:dpml/metro/dpml-metro#SNAPSHOT" />
+
+ <resource>
+ <info>
+ <group>commons-dbcp</group>
+ <name>commons-dbcp</name>
+ <name>1.2</name>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <project file="module.xml">
+ <info>
+ <group>dpml/planet/dbcp</group>
+ <name>dpml-dbcp</name>
+ <type>module</type>
+ </info>
+ </project>
+
+ <project basedir="api">
+ <info>
+ <group>dpml/planet/dbcp</group>
+ <name>dpml-dbcp-api</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="impl">
+ <info>
+ <group>dpml/planet/dbcp</group>
+ <name>dpml-dbcp-impl</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-dbcp-api"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-configuration-api"/>
+ <include key="dpml-context-api"/>
+ <include key="dpml-logging-api"/>
+ <include key="commons-dbcp"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+</index>

Added: development/laboratory/components/dbcp/module.xml
==============================================================================
--- (empty file)
+++ development/laboratory/components/dbcp/module.xml Tue May 10 12:34:43
2005
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2004 Stephen J McConnell
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="dpml-dbcp" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="build" depends="standard.build">
+ <x:module index="index.xml">
+ <header>
+ <svn href="http://scm.dpml.net/repos/dpml/development/laboratory"/>
+ <home href="http://planet.dpml.net/dpml/db"/>
+ </header>
+ </x:module>
+ </target>
+
+ <target name="install" depends="standard.install,checkstyle,junit-report">
+ <x:javadoc>
+ <link href="http://java.sun.com/j2se/1.4/docs/api"/>
+ <group title="Database Connection API">
+ <package name="net.dpml.dbcp"/>
+ </group>
+ <group title="Database Connection Implementation">
+ <package name="net.dpml.dbcp.impl"/>
+ </group>
+ </x:javadoc>
+ </target>
+
+ <target name="junit-report" depends="test">
+ <mkdir dir="target/reports/junit"/>
+ <junitreport todir="target/reports/junit">
+ <fileset dir=".">
+ <include name="**/target/test-reports/TEST-*.xml"/>
+ </fileset>
+ <report format="frames" todir="target/reports/junit"/>
+ </junitreport>
+ </target>
+
+</project>



  • svn commit: r2491 - in development/laboratory/components/dbcp: . impl/src/main/net/dpml/dbcp impl/src/main/net/dpml/dbcp/impl, niclas, 05/10/2005

Archive powered by MHonArc 2.6.24.

Top of Page