Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2493 - development/laboratory/components/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: r2493 - development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl
  • Date: Tue, 10 May 2005 13:00:27 +0000

Author: niclas AT hedhman.org
Date: Tue May 10 13:00:27 2005
New Revision: 2493

Modified:

development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/DbcpConnectionManager.java
Log:
Taken Avalon out of the code and some reformatting.

Modified:
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/DbcpConnectionManager.java
==============================================================================
---
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/DbcpConnectionManager.java
(original)
+++
development/laboratory/components/dbcp/impl/src/main/net/dpml/dbcp/impl/DbcpConnectionManager.java
Tue May 10 13:00:27 2005
@@ -1,5 +1,7 @@
/*
* Copyright 2004 Apache Software Foundation
+ * Copyright 2005 Niclas Hedhman
+ *
* 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
@@ -46,16 +48,11 @@
* @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 $
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id$
*/
public class DbcpConnectionManager
- implements
- Contextualizable,
- Configurable,
- Initializable,
- Disposable,
- ConnectionManager
+ implements Initializable, Disposable, ConnectionManager
{
//---------------------------------------------------------
// state
@@ -86,44 +83,18 @@
* Creates a new instance of the HSQL database server with the
* logging channel supplied by the container.
*
+ * @metro.entry key="urn:metro:home" type="java.io.File"
+ *
* @param logger the container-supplied logging channel
- */
- public DbcpConnectionManager( final Logger logger )
- {
- m_logger = logger;
- }
-
- //---------------------------------------------------------
- // Contextualizable
- //---------------------------------------------------------
-
- /**
- * Contextualization of the server by the container.
- *
- * @param context the supplied server context
- * @exception ContextException if a contextualization error occurs
- * @metro.entry key="urn:avalon:home" type="java.io.File"
- */
- public void contextualize( final Context context )
- throws ContextException
- {
- // cache the working base directory
- m_basedir = getBaseDirectory( context );
- }
-
- //---------------------------------------------------------
- // Configurable
- //---------------------------------------------------------
-
- /**
- * Configuration of the server by the container.
*
- * @param config the supplied server configuration
+ * @exception ContextException if a contextualization error occurs
* @exception ConfigurationException if a configuration error occurs
*/
- public void configure( final Configuration config )
- throws ConfigurationException
+ public DbcpConnectionManager( Logger logger, Context context,
Configuration config)
+ throws ContextException, ConfigurationException
{
+ m_logger = logger;
+ m_basedir = getBaseDirectory( context );
// cache away the connection pool settings...
m_pool = config.getChild( "pool", false );

@@ -170,7 +141,7 @@

// 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");
+ Class.forName( "org.apache.commons.dbcp.PoolingDriver" );

// loop through all the configured datasources...
for ( int i = 0; i < m_datasources.length; i++ )
@@ -224,7 +195,8 @@
/**
* Cleans up the component.
*/
- public void dispose() {
+ public void dispose()
+ {
try
{
PoolingDriver driver = (PoolingDriver)
DriverManager.getDriver("jdbc:apache:commons:dbcp:");
@@ -247,7 +219,9 @@
*
* @return a <code>java.sql.Connection</code> to the default data source
*/
- public Connection getConnection() throws SQLException {
+ public Connection getConnection()
+ throws SQLException
+ {
return
DriverManager.getConnection("jdbc:apache:commons:dbcp:default");
}

@@ -257,7 +231,9 @@
* @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);
}

@@ -334,13 +310,13 @@
* cannot be loaded
*/
private void loadJDBCDriver( final Configuration datasource )
- throws DriverNotFoundException, ConfigurationException,
- ClassNotFoundException
+ throws DriverNotFoundException, ConfigurationException,
ClassNotFoundException
{
if ( datasource.getChild( "driver", false) == null)
{
- throw new DriverNotFoundException( "JDBC Driver not defined " +
- "for datasource " + datasource.getAttribute( "name" ) );
+ String name = datasource.getAttribute( "name" );
+ String message = "JDBC Driver not defined for datasource " +
name;
+ throw new DriverNotFoundException( message );
}
else
{
@@ -357,9 +333,8 @@
* @throws DbUrlNotFoundException
* @throws ConfigurationException
*/
- private ConnectionFactory createConnectionFactory(
- final Configuration datasource ) throws DbUrlNotFoundException,
- ConfigurationException
+ private ConnectionFactory createConnectionFactory( Configuration
datasource )
+ throws DbUrlNotFoundException, ConfigurationException
{
ConnectionFactory connectionFactory = null;
String dbUrl = null;
@@ -391,7 +366,8 @@
*/
private PoolableConnectionFactory createPoolableConnectionFactory(
ConnectionFactory connFactory, ObjectPool pool,
- Configuration datasource ) throws ConfigurationException
+ Configuration datasource )
+ throws ConfigurationException
{
PoolableConnectionFactory factory = null;
String query = null;
@@ -416,22 +392,19 @@
* @exception ContextException if a contextualization error occurs
*/
private File getBaseDirectory( final Context context )
- throws ContextException
+ throws ContextException
{
- File home = (File) context.get( "urn:avalon:home" );
+ File home = (File) context.get( "urn:metro:home" );
if ( !home.exists() )
{
boolean success = home.mkdirs();
if ( !success )
{
- throw new ContextException( "Unable to create component "
- + "home directory: " + home.getAbsolutePath() );
+ String message = "Unable to create component home directory:
" + home.getAbsolutePath();
+ throw new ContextException( message );
}
}
- if ( getLogger().isInfoEnabled() )
- {
- getLogger().info( "Setting home directory to: " + home );
- }
+ getLogger().info( "Setting home directory to: " + home );
return home;
}




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

Archive powered by MHonArc 2.6.24.

Top of Page