You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by mp...@apache.org on 2003/05/14 21:38:06 UTC
cvs commit: db-torque/src/java/org/apache/torque/pool ConnectionPool.java
mpoeschl 2003/05/14 12:38:06
Modified: src/java/org/apache/torque/util Transaction.java
LargeSelect.java Criteria.java BasePeer.java
src/java/org/apache/torque/om BaseObject.java
src/java/org/apache/torque/dsfactory
Jdbc2PoolDataSourceFactory.java
TorqueDataSourceFactory.java
AbstractDataSourceFactory.java
JndiDataSourceFactory.java
src/java/org/apache/torque/oid SequenceIdGenerator.java
IDBroker.java
. project.xml
src/java/org/apache/torque/manager AbstractBaseManager.java
MethodResultCache.java
src/java/org/apache/torque Torque.java
src/java/org/apache/torque/pool ConnectionPool.java
Log:
use commons-logging
Revision Changes Path
1.7 +14 -12 db-torque/src/java/org/apache/torque/util/Transaction.java
Index: Transaction.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/Transaction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Transaction.java 9 Jan 2003 17:46:21 -0000 1.6
+++ Transaction.java 14 May 2003 19:38:02 -0000 1.7
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,7 +57,9 @@
import java.sql.Connection;
import java.sql.SQLException;
-import org.apache.log4j.Logger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
@@ -81,7 +83,7 @@
{
/** The log. */
- private static Logger logger = Logger.getLogger(Transaction.class);
+ private static Log log = LogFactory.getLog(Transaction.class);
/**
* Begin a transaction. This method will fallback gracefully to
@@ -176,10 +178,10 @@
{
if (con == null)
{
- logger.error("Connection object was null. "
- + "This could be due to a misconfiguration of the "
- + "DataSourceFactory. Check the logs and Torque.properties "
- + "to better determine the cause.");
+ log.error("Connection object was null. "
+ + "This could be due to a misconfiguration of the "
+ + "DataSourceFactory. Check the logs and Torque.properties "
+ + "to better determine the cause.");
}
else
{
@@ -194,9 +196,9 @@
}
catch (SQLException e)
{
- logger.error("An attempt was made to rollback a transaction "
- + "but the database did not allow the operation to be "
- + "rolled back.", e);
+ log.error("An attempt was made to rollback a transaction "
+ + "but the database did not allow the operation to be "
+ + "rolled back.", e);
throw new TorqueException(e);
}
finally
@@ -220,7 +222,7 @@
}
catch (TorqueException e)
{
- logger.error("An error occured during rollback.", e);
+ log.error("An error occured during rollback.", e);
}
}
}
1.11 +5 -5 db-torque/src/java/org/apache/torque/util/LargeSelect.java
Index: LargeSelect.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/LargeSelect.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- LargeSelect.java 28 Jan 2003 00:59:11 -0000 1.10
+++ LargeSelect.java 14 May 2003 19:38:02 -0000 1.11
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -62,7 +62,8 @@
import java.util.Hashtable;
import java.lang.reflect.Method;
-import org.apache.log4j.Logger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
@@ -256,8 +257,7 @@
private Hashtable params = null;
/** Logging */
- private static Logger log =
- Logger.getLogger(LargeSelect.class);
+ private static Log log = LogFactory.getLog(LargeSelect.class);
/**
* Creates a LargeSelect whose results are returned as a <code>List</code>
1.41 +7 -7 db-torque/src/java/org/apache/torque/util/Criteria.java
Index: Criteria.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/Criteria.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- Criteria.java 24 Mar 2003 21:53:42 -0000 1.40
+++ Criteria.java 14 May 2003 19:38:03 -0000 1.41
@@ -68,7 +68,8 @@
import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.torque.Torque;
import org.apache.torque.adapter.DB;
@@ -194,9 +195,8 @@
private boolean useTransaction = false;
- /** Log4j logger used for logging. */
- private static Logger logger
- = Logger.getLogger(Criteria.class);
+ /** the log. */
+ private static Log log = LogFactory.getLog(Criteria.class);
/**
* Creates a new instance with the default capacity.
@@ -3182,8 +3182,8 @@
{
// we are only doing this to allow easier debugging, so
// no need to throw up the exception, just make note of it.
- logger.error(
- "Could not get a DB adapter, so sql may be wrong");
+ log.error(
+ "Could not get a DB adapter, so sql may be wrong");
}
}
else
1.66 +14 -14 db-torque/src/java/org/apache/torque/util/BasePeer.java
Index: BasePeer.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/BasePeer.java,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- BasePeer.java 13 May 2003 16:42:17 -0000 1.65
+++ BasePeer.java 14 May 2003 19:38:03 -0000 1.66
@@ -73,7 +73,8 @@
import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
@@ -133,7 +134,7 @@
private static Hashtable mapBuilders = new Hashtable(5);
/** the log */
- protected static Logger category = Logger.getLogger(BasePeer.class);
+ protected static Log log = LogFactory.getLog(BasePeer.class);
/**
* Converts a hashtable to a byte array for storage/serialization.
@@ -252,7 +253,7 @@
}
catch (Exception e)
{
- category.error(e);
+ log.error(e);
throw new Error("Error in BasePeer.initTableSchema("
+ tableName
+ "): "
@@ -285,7 +286,7 @@
}
catch (Exception e)
{
- category.error(e);
+ log.error(e);
throw new Error(
"Error in BasePeer.initTableColumns(): " + e.getMessage());
}
@@ -546,7 +547,7 @@
tds = new TableDataSet(con, tab, kd);
String sqlSnippet = StringUtils.join(whereClause.iterator(), " AND ");
- category.debug("BasePeer.doDelete: whereClause=" + sqlSnippet);
+ log.debug("BasePeer.doDelete: whereClause=" + sqlSnippet);
tds.where(sqlSnippet);
tds.fetchRecords();
@@ -979,7 +980,7 @@
}
sql = query.toString();
}
- category.debug(sql);
+ log.debug(sql);
return sql;
}
@@ -1500,9 +1501,8 @@
// execute the query
long startTime = System.currentTimeMillis();
qds = new QueryDataSet(con, queryString);
- category.debug("Elapsed time="
- + (System.currentTimeMillis() - startTime)
- + " ms");
+ log.debug("Elapsed time="
+ + (System.currentTimeMillis() - startTime) + " ms");
results = getSelectResults(
qds, start, numberOfResults, singleRecord);
}
@@ -1885,7 +1885,7 @@
// Get affected records.
tds = new TableDataSet(con, tab, kd);
String sqlSnippet = StringUtils.join(whereClause.iterator(), " AND ");
- category.debug("BasePeer.doUpdate: whereClause=" + sqlSnippet);
+ log.debug("BasePeer.doUpdate: whereClause=" + sqlSnippet);
tds.where(sqlSnippet);
tds.fetchRecords();
@@ -2100,14 +2100,14 @@
// return null.
String message =
"BasePeer.MapBuilder failed trying to instantiate: " + name;
- if (category == null)
+ if (log == null)
{
System.out.println(message);
e.printStackTrace();
}
else
{
- category.error(message, e);
+ log.error(message, e);
}
}
return null;
@@ -2562,7 +2562,7 @@
sql = query.toString();
}
- category.debug(sql);
+ log.debug(sql);
queryString.append(sql);
}
1.18 +22 -40 db-torque/src/java/org/apache/torque/om/BaseObject.java
Index: BaseObject.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/om/BaseObject.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- BaseObject.java 28 Jan 2003 16:43:27 -0000 1.17
+++ BaseObject.java 14 May 2003 19:38:04 -0000 1.18
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,12 +55,13 @@
*/
import java.io.Serializable;
-import org.apache.log4j.Category;
-import org.apache.log4j.Logger;
-import org.apache.torque.TorqueException;
-
import java.sql.Connection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.torque.TorqueException;
+
/**
* This class contains attributes and methods that are used by all
* business objects within the system.
@@ -71,9 +72,7 @@
*/
public abstract class BaseObject implements Persistent, Serializable
{
- /**
- * The constant denoting an unset numeric database identifier.
- */
+ /** The constant denoting an unset numeric database identifier. */
public static final int NEW_ID = -1;
/**
@@ -83,14 +82,10 @@
private static final String NOT_IMPLEMENTED
= "Not implemented: Method must be overridden if called";
- /**
- * attribute to determine if this object has previously been saved.
- */
+ /** attribute to determine if this object has previously been saved. */
private boolean isNew = true;
- /**
- * The unique id for the object which can be used for persistence.
- */
+ /** The unique id for the object which can be used for persistence. */
private ObjectKey primaryKey = null;
/**
@@ -102,16 +97,8 @@
*/
private boolean modified = true;
- /**
- * Cache the logger to avoid looking it up every time its needed.
- */
- private transient Category log = null;
-
-
- /**
- * Cache the logger to avoid looking it up every time its needed.
- */
- private transient Logger logger = null;
+ /** Cache the log to avoid looking it up every time its needed. */
+ private transient Log log = null;
/**
* getter for the object primaryKey.
@@ -162,7 +149,6 @@
* @param primaryKey The new PrimaryKey for the object.
* @exception TorqueException This method will not throw any exceptions
* but this allows for children to override the method more easily
- *
*/
public void setPrimaryKey(String primaryKey) throws TorqueException
{
@@ -314,32 +300,28 @@
}
/**
- * gets a log4j Category based on class name.
+ * gets a commons-logging Log based on class name.
*
- * @return a <code>Category</code> to write log to.
+ * @return a <code>Log</code> to write log to.
* @deprecated Use getLog()
*/
- protected Category log()
+ protected Log log()
{
- if (log == null)
- {
- log = Category.getInstance(getClass().getName());
- }
- return log;
+ return getLog();
}
/**
- * gets a log4j Logger based on class name.
+ * gets a commons-logging Log based on class name.
*
- * @return a <code>Logger</code> to write log to.
+ * @return a <code>Log</code> to write log to.
*/
- protected Logger getLog()
+ protected Log getLog()
{
- if (logger == null)
+ if (log == null)
{
- logger = Logger.getLogger(getClass());
+ log = LogFactory.getLog(getClass().getName());
}
- return logger;
+ return log;
}
/**
1.9 +11 -7 db-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java
Index: Jdbc2PoolDataSourceFactory.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Jdbc2PoolDataSourceFactory.java 10 Jan 2003 10:19:44 -0000 1.8
+++ Jdbc2PoolDataSourceFactory.java 14 May 2003 19:38:04 -0000 1.9
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,9 +58,13 @@
import javax.sql.DataSource;
import org.apache.commons.configuration.Configuration;
+
import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
import org.apache.commons.dbcp.jdbc2pool.Jdbc2PoolDataSource;
-import org.apache.log4j.Logger;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
@@ -77,8 +81,8 @@
{
/** The log. */
- private static Logger logger =
- Logger.getLogger(Jdbc2PoolDataSourceFactory.class);
+ private static Log log
+ = LogFactory.getLog(Jdbc2PoolDataSourceFactory.class);
/** The wrapped <code>DataSource</code>. */
private DataSource ds;
@@ -119,7 +123,7 @@
private ConnectionPoolDataSource initCPDS(Configuration configuration)
throws TorqueException
{
- logger.debug("Starting initCPDS");
+ log.debug("Starting initCPDS");
ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
Configuration c = null;
@@ -141,7 +145,7 @@
private Jdbc2PoolDataSource initJdbc2Pool(Configuration configuration)
throws TorqueException
{
- logger.debug("Starting initJdbc2Pool");
+ log.debug("Starting initJdbc2Pool");
Jdbc2PoolDataSource ds = new Jdbc2PoolDataSource();
Configuration c = null;
1.11 +10 -7 db-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java
Index: TorqueDataSourceFactory.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TorqueDataSourceFactory.java 10 Jan 2003 10:19:44 -0000 1.10
+++ TorqueDataSourceFactory.java 14 May 2003 19:38:04 -0000 1.11
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,8 +58,12 @@
import javax.sql.DataSource;
import org.apache.commons.configuration.Configuration;
+
import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
-import org.apache.log4j.Logger;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.pool.TorqueClassicDataSource;
@@ -77,8 +81,7 @@
{
/** The log. */
- private static Logger logger =
- Logger.getLogger(TorqueDataSourceFactory.class);
+ private static Log log = LogFactory.getLog(TorqueDataSourceFactory.class);
/** The wrapped <code>DataSource</code>. */
private DataSource ds;
@@ -119,7 +122,7 @@
protected ConnectionPoolDataSource initCPDS(Configuration configuration)
throws TorqueException
{
- logger.debug("Starting initCPDS");
+ log.debug("Starting initCPDS");
ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
Configuration c = null;
@@ -142,7 +145,7 @@
Configuration configuration)
throws TorqueException
{
- logger.debug("Starting initTorqueClassic");
+ log.debug("Starting initTorqueClassic");
TorqueClassicDataSource ds = new TorqueClassicDataSource();
Configuration c = null;
1.10 +18 -14 db-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java
Index: AbstractDataSourceFactory.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractDataSourceFactory.java 10 Jan 2003 10:19:44 -0000 1.9
+++ AbstractDataSourceFactory.java 14 May 2003 19:38:04 -0000 1.10
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,11 +55,16 @@
*/
import java.util.Iterator;
-import org.apache.log4j.Logger;
-import org.apache.commons.configuration.Configuration;
+
import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.beanutils.MappedPropertyDescriptor;
+import org.apache.commons.beanutils.PropertyUtils;
+
+import org.apache.commons.configuration.Configuration;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.torque.TorqueException;
/**
@@ -87,8 +92,7 @@
/**
* The logging logger.
*/
- private static Logger logger =
- Logger.getLogger(AbstractDataSourceFactory.class);
+ private static Log log = LogFactory.getLog(AbstractDataSourceFactory.class);
/**
* Encapsulates setting configuration properties on
@@ -125,9 +129,9 @@
PropertyUtils
.setMappedProperty(ds, property, subProp, value);
- if (logger.isDebugEnabled())
+ if (log.isDebugEnabled())
{
- logger.debug("setMappedProperty("
+ log.debug("setMappedProperty("
+ ds + ", "
+ property + ", "
+ subProp + ", "
@@ -144,9 +148,9 @@
ConvertUtils.convert(c.getString(property), propertyType);
PropertyUtils.setSimpleProperty(ds, property, value);
- if (logger.isDebugEnabled())
+ if (log.isDebugEnabled())
{
- logger.debug("setSimpleProperty("
+ log.debug("setSimpleProperty("
+ ds + ", "
+ property + ", "
+ value
@@ -156,7 +160,7 @@
}
catch (Exception e)
{
- logger.error(
+ log.error(
"Property: "
+ property
+ " value: "
@@ -179,7 +183,7 @@
protected void applyConfiguration(Configuration c, Object o)
throws TorqueException
{
- logger.debug("applyConfiguration(" + c + ", " + o + ")");
+ log.debug("applyConfiguration(" + c + ", " + o + ")");
if (c != null)
{
@@ -193,7 +197,7 @@
}
catch (Exception e)
{
- logger.error(e);
+ log.error(e);
throw new TorqueException(e);
}
}
1.6 +21 -19 db-torque/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
Index: JndiDataSourceFactory.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JndiDataSourceFactory.java 9 Jan 2003 17:46:20 -0000 1.5
+++ JndiDataSourceFactory.java 14 May 2003 19:38:04 -0000 1.6
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,7 +66,10 @@
import javax.sql.DataSource;
import org.apache.commons.configuration.Configuration;
-import org.apache.log4j.Logger;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.torque.TorqueException;
/**
@@ -83,8 +86,7 @@
{
/** The log. */
- private static Logger logger =
- Logger.getLogger(JndiDataSourceFactory.class);
+ private static Log log = LogFactory.getLog(JndiDataSourceFactory.class);
/** The path to get the resource from. */
private String path;
@@ -132,7 +134,7 @@
*/
private void initJNDI(Configuration configuration) throws TorqueException
{
- logger.debug("Starting initJNDI");
+ log.debug("Starting initJNDI");
Hashtable env = null;
Configuration c = configuration.subset("jndi");
if (c == null)
@@ -150,7 +152,7 @@
if (key.equals("path"))
{
path = c.getString(key);
- logger.debug("JNDI path: " + path);
+ log.debug("JNDI path: " + path);
}
else
{
@@ -160,7 +162,7 @@
}
String value = c.getString(key);
env.put(key, value);
- logger.debug("Set jndi property: " + key + "=" + value);
+ log.debug("Set jndi property: " + key + "=" + value);
}
}
if (env == null)
@@ -171,12 +173,12 @@
{
ctx = new InitialContext(env);
}
- logger.debug("Created new InitialContext");
+ log.debug("Created new InitialContext");
debugCtx(ctx);
}
catch (Exception e)
{
- logger.error("", e);
+ log.error("", e);
throw new TorqueException(e);
}
}
@@ -190,7 +192,7 @@
private void initDataSource(Configuration configuration)
throws TorqueException
{
- logger.debug("Starting initDataSources");
+ log.debug("Starting initDataSources");
Configuration c = configuration.subset("datasource");
try
{
@@ -204,14 +206,14 @@
if (key.equals("classname"))
{
String classname = c.getString(key);
- logger.debug("Datasource class: " + classname);
+ log.debug("Datasource class: " + classname);
Class dsClass = Class.forName(classname);
ds = dsClass.newInstance();
}
else
{
- logger.debug("Setting datasource property: " + key);
+ log.debug("Setting datasource property: " + key);
setProperty(key, c, ds);
}
}
@@ -221,7 +223,7 @@
}
catch (Exception e)
{
- logger.error("", e);
+ log.error("", e);
throw new TorqueException(e);
}
}
@@ -233,16 +235,16 @@
*/
private void debugCtx(Context ctx) throws NamingException
{
- logger.debug("InitialContext -------------------------------");
+ log.debug("InitialContext -------------------------------");
Map env = ctx.getEnvironment();
Iterator qw = env.keySet().iterator();
- logger.debug("Environment properties:" + env.size());
+ log.debug("Environment properties:" + env.size());
while (qw.hasNext())
{
Object prop = qw.next();
- logger.debug(" " + prop + ": " + env.get(prop));
+ log.debug(" " + prop + ": " + env.get(prop));
}
- logger.debug("----------------------------------------------");
+ log.debug("----------------------------------------------");
}
/**
@@ -272,7 +274,7 @@
try
{
ctx.createSubcontext(subctx);
- logger.debug("Added sub context: " + subctx);
+ log.debug("Added sub context: " + subctx);
}
catch (NameAlreadyBoundException nabe)
{
1.9 +7 -6 db-torque/src/java/org/apache/torque/oid/SequenceIdGenerator.java
Index: SequenceIdGenerator.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/oid/SequenceIdGenerator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SequenceIdGenerator.java 9 Jan 2003 17:46:20 -0000 1.8
+++ SequenceIdGenerator.java 14 May 2003 19:38:04 -0000 1.9
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,7 +57,9 @@
import java.math.BigDecimal;
import java.sql.Connection;
-import org.apache.log4j.Logger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.torque.adapter.DB;
import com.workingdogs.village.QueryDataSet;
@@ -74,8 +76,7 @@
public class SequenceIdGenerator implements IdGenerator
{
/** The log. */
- private static Logger logger = Logger.getLogger(
- SequenceIdGenerator.class);
+ private static Log log = LogFactory.getLog(SequenceIdGenerator.class);
/** the adapter that knows the correct sql syntax */
private DB dbAdapter;
@@ -189,7 +190,7 @@
throws Exception
{
String idSql = dbAdapter.getIDMethodSQL(keyInfo);
- logger.debug(idSql);
+ log.debug(idSql);
// Execute the query.
QueryDataSet qds = new QueryDataSet(connection, idSql);
1.25 +21 -21 db-torque/src/java/org/apache/torque/oid/IDBroker.java
Index: IDBroker.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/oid/IDBroker.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- IDBroker.java 20 Jan 2003 22:01:16 -0000 1.24
+++ IDBroker.java 14 May 2003 19:38:05 -0000 1.25
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,10 @@
import java.util.List;
import org.apache.commons.configuration.Configuration;
-import org.apache.log4j.Logger;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.map.DatabaseMap;
@@ -205,10 +208,8 @@
private static final String DB_IDBROKER_USENEWCONNECTION =
"idbroker.usenewconnection";
- /**
- * Logger used for logging.
- */
- private Logger logger = Logger.getLogger(IDBroker.class);
+ /** the log */
+ private Log log = LogFactory.getLog(IDBroker.class);
/**
* Creates an IDBroker for the ID table.
@@ -259,7 +260,7 @@
}
if (!transactionsSupported)
{
- logger.warn("IDBroker is being used with db '" + dbName
+ log.warn("IDBroker is being used with db '" + dbName
+ "', which does not support transactions. IDBroker "
+ "attempts to use transactions to limit the possibility "
+ "of duplicate key generation. Without transactions, "
@@ -438,11 +439,11 @@
{
if (availableIds == null)
{
- logger.debug("Forced id retrieval - no available list");
+ log.debug("Forced id retrieval - no available list");
}
else
{
- logger.debug("Forced id retrieval - " + availableIds.size());
+ log.debug("Forced id retrieval - " + availableIds.size());
}
storeIDs(tableName, true, connection);
availableIds = (List) ids.get(tableName);
@@ -508,7 +509,7 @@
}
catch (Exception e)
{
- logger.error("Release of connection failed.", e);
+ log.error("Release of connection failed.", e);
}
}
return exists;
@@ -521,7 +522,7 @@
*/
public void run()
{
- logger.debug("IDBroker thread was started.");
+ log.debug("IDBroker thread was started.");
Thread thisThread = Thread.currentThread();
while (houseKeeperThread == thisThread)
@@ -540,7 +541,7 @@
while (it.hasNext())
{
String tableName = (String) it.next();
- logger.debug("IDBroker thread checking for more keys "
+ log.debug("IDBroker thread checking for more keys "
+ "on table: " + tableName);
List availableIds = (List) ids.get(tableName);
int quantity = getQuantity(tableName, null).intValue();
@@ -552,18 +553,17 @@
// want the quantity to be adjusted for thread
// calls.
storeIDs(tableName, false, null);
- logger.debug("Retrieved more ids for table: "
- + tableName);
+ log.debug("Retrieved more ids for table: " + tableName);
}
catch (Exception exc)
{
- logger.error("There was a problem getting new IDs "
+ log.error("There was a problem getting new IDs "
+ "for table: " + tableName, exc);
}
}
}
}
- logger.debug("IDBroker thread finished.");
+ log.debug("IDBroker thread finished.");
}
/**
@@ -608,7 +608,7 @@
int timeLapse = (int) (nowLong - thenLong);
if (timeLapse < SLEEP_PERIOD && timeLapse > 0)
{
- logger.debug("Unscheduled retrieval of more ids for table: "
+ log.debug("Unscheduled retrieval of more ids for table: "
+ tableName);
// Increase quantity, so that hopefully this does not
// happen again.
@@ -762,7 +762,7 @@
}
catch (Exception e)
{
- logger.error("Release of connection failed.", e);
+ log.error("Release of connection failed.", e);
}
}
}
@@ -846,7 +846,7 @@
Statement statement = null;
- logger.debug("updateNextId: " + stmt.toString());
+ log.debug("updateNextId: " + stmt.toString());
try
{
@@ -886,7 +886,7 @@
Statement statement = null;
- logger.debug("updateQuantity: " + stmt.toString());
+ log.debug("updateQuantity: " + stmt.toString());
try
{
1.86 +4 -0 db-torque/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/db-torque/project.xml,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- project.xml 11 May 2003 16:21:31 -0000 1.85
+++ project.xml 14 May 2003 19:38:05 -0000 1.86
@@ -188,11 +188,13 @@
</contributors>
<dependencies>
+<!--
<dependency>
<id>avalon-framework</id>
<version>4.1.4</version>
<url>http://jakarta.apache.org/avalon/</url>
</dependency>
+-->
<dependency>
<id>commons-beanutils</id>
<version>1.6.1</version>
@@ -243,11 +245,13 @@
<version>1.2.1</version>
<url>http://java.sun.com/products/jndi/</url>
</dependency>
+<!--
<dependency>
<id>log4j</id>
<version>1.2.7</version>
<url>http://jakarta.apache.org/log4j/</url>
</dependency>
+-->
<dependency>
<id>stratum</id>
<version>1.0-b3</version>
1.13 +10 -8 db-torque/src/java/org/apache/torque/manager/AbstractBaseManager.java
Index: AbstractBaseManager.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/manager/AbstractBaseManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- AbstractBaseManager.java 9 Jan 2003 17:46:20 -0000 1.12
+++ AbstractBaseManager.java 14 May 2003 19:38:05 -0000 1.13
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -73,7 +73,9 @@
import org.apache.torque.TorqueException;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.Persistent;
-import org.apache.log4j.Logger;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class contains common functionality of a Manager for
@@ -86,8 +88,8 @@
implements Serializable
{
/** the log */
- protected static final Logger logger =
- Logger.getLogger(AbstractBaseManager.class);
+ protected static final Log log
+ = LogFactory.getLog(AbstractBaseManager.class);
/** used to cache the om objects. cache is set by the region property */
protected transient GroupCacheAccess cache;
@@ -466,7 +468,7 @@
}
if (cache == null)
{
- logger.info("Cache could not be initialized for region: " + v);
+ log.info("Cache could not be initialized for region: " + v);
}
}
@@ -611,8 +613,8 @@
}
catch (Exception e)
{
- logger.error("Cache could not be initialized for region: "
- + region + "after deserialization");
+ log.error("Cache could not be initialized for region: "
+ + region + "after deserialization");
}
}
}
1.16 +4 -4 db-torque/src/java/org/apache/torque/manager/MethodResultCache.java
Index: MethodResultCache.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/manager/MethodResultCache.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- MethodResultCache.java 21 Mar 2003 17:31:09 -0000 1.15
+++ MethodResultCache.java 14 May 2003 19:38:05 -0000 1.16
@@ -64,7 +64,8 @@
import org.apache.jcs.access.GroupCacheAccess;
import org.apache.jcs.access.exception.CacheException;
-import org.apache.log4j.Logger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.torque.TorqueException;
@@ -83,8 +84,7 @@
private Map groups;
/** Logging */
- private static Logger log =
- Logger.getLogger(MethodResultCache.class);
+ private static Log log = LogFactory.getLog(MethodResultCache.class);
public MethodResultCache(GroupCacheAccess cache)
throws TorqueException
1.82 +18 -131 db-torque/src/java/org/apache/torque/Torque.java
Index: Torque.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/Torque.java,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- Torque.java 11 May 2003 12:59:07 -0000 1.81
+++ Torque.java 14 May 2003 19:38:05 -0000 1.82
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -54,26 +54,21 @@
* <http://www.apache.org/>.
*/
-import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.helpers.NullEnumeration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.stratum.lifecycle.Configurable;
import org.apache.stratum.lifecycle.Disposable;
@@ -161,8 +156,7 @@
/**
* The logging logger.
*/
- private static Logger logger
- = Logger.getLogger(Torque.class);
+ private static Log log = LogFactory.getLog(Torque.class);
/**
* Torque-specific configuration.
@@ -200,10 +194,6 @@
+ "for further details.");
}
- // Setup log4j, I suppose we might want to deal with
- // systems other than log4j ...
- configureLogging();
-
// Now that we have dealt with processing the log4j properties
// that may be contained in the configuration we will make the
// configuration consist only of the remain torque specific
@@ -260,7 +250,7 @@
private static final void initAdapters(Configuration configuration)
throws TorqueException
{
- logger.debug("Starting initAdapters");
+ log.debug("Starting initAdapters");
adapterMap = new HashMap();
Configuration c = configuration.subset("database");
if (c != null)
@@ -283,13 +273,13 @@
}
catch (Exception e)
{
- logger.error("", e);
+ log.error("", e);
throw new TorqueException(e);
}
}
else
{
- logger.warn("There were no adapters in the configuration.");
+ log.warn("There were no adapters in the configuration.");
}
}
@@ -302,7 +292,7 @@
private static void initDataSourceFactories(Configuration configuration)
throws TorqueException
{
- logger.debug("Starting initDSF");
+ log.debug("Starting initDSF");
dsFactoryMap = new HashMap();
Configuration c = configuration.subset("dsfactory");
if (c != null)
@@ -317,7 +307,7 @@
{
String classname = c.getString(key);
String handle = key.substring(0, key.indexOf('.'));
- logger.debug("handle: " + handle
+ log.debug("handle: " + handle
+ " DataSourceFactory: " + classname);
Class dsfClass = Class.forName(classname);
DataSourceFactory dsf =
@@ -329,7 +319,7 @@
}
catch (Exception e)
{
- logger.error("", e);
+ log.error("", e);
throw new TorqueException(e);
}
}
@@ -352,7 +342,7 @@
if (dsFactoryMap.get(DEFAULT_NAME) == null
&& !defaultDB.equals(DEFAULT_NAME))
{
- logger.debug("Adding a dummy entry for "
+ log.debug("Adding a dummy entry for "
+ DEFAULT_NAME + ", mapped onto " + defaultDB);
dsFactoryMap.put(DEFAULT_NAME, dsFactoryMap.get(defaultDB));
}
@@ -451,7 +441,7 @@
if (!managers.containsKey(managedClassKey))
{
String managerClass = configuration.getString(key);
- logger.info("Added Manager for Class: " + managedClassKey
+ log.info("Added Manager for Class: " + managedClassKey
+ " -> " + managerClass);
try
{
@@ -462,7 +452,7 @@
// the exception thrown here seems to disappear.
// At least when initialized by Turbine, should find
// out why, but for now make sure it is noticed.
- logger.error("", e);
+ log.error("", e);
e.printStackTrace();
throw e;
}
@@ -535,109 +525,6 @@
}
/**
- * Configure the logging for this subsystem.
- */
- protected static void configureLogging()
- {
- if (isLoggingConfigured() == false)
- {
- // Get the applicationRoot for use in the log4j
- // properties.
- String applicationRoot =
- getConfiguration().getString("torque.applicationRoot", ".");
-
- //!! Need a configurable log directory.
- File logsDir = new File(applicationRoot, "logs");
-
- if (logsDir.exists() == false)
- {
- if (logsDir.mkdirs() == false)
- {
- System.err.println("Cannot create logs directory!");
- }
- }
-
- // Extract the log4j values out of the configuration and
- // place them in a Properties object so that we can
- // use the log4j PropertyConfigurator.
- Properties p = new Properties();
- p.put("torque.applicationRoot", applicationRoot);
-
- Iterator i = getConfiguration().getKeys();
- while (i.hasNext())
- {
- String key = (String) i.next();
-
- // We only want log4j properties.
- if (key.startsWith("log4j") == false)
- {
- continue;
- }
-
- // We have to deal with Configuration way
- // of dealing with "," in properties which is to
- // make them separate values. Log4j logger
- // properties contain commas so we must stick them
- // back together for log4j.
- String[] values = getConfiguration().getStringArray(key);
-
- String value;
- if (values.length == 1)
- {
- value = values[0];
- }
- else
- {
- value = values[0] + "," + values[1];
- }
-
- p.put(key, value);
- }
-
- PropertyConfigurator.configure(p);
- logger.info("Logging has been configured by Torque.");
- }
- }
-
- /**
- * Determine whether log4j has already been configured.
- *
- * @return boolean Whether log4j is configured.
- */
- protected static boolean isLoggingConfigured()
- {
- // This is a note from Ceki, taken from a message on the log4j
- // user list:
- //
- // Having defined categories does not necessarily mean
- // configuration. Remember that most categories are created
- // outside the configuration file. What you want to check for
- // is the existence of appenders. The correct procedure is to
- // first check for appenders in the root logger and if that
- // returns no appenders to check in other categories.
-
- Enumeration enum = Logger.getRoot().getAllAppenders();
-
- if (!(enum instanceof NullEnumeration))
- {
- return true;
- }
- else
- {
- Enumeration cats = LogManager.getCurrentLoggers();
- while (cats.hasMoreElements())
- {
- Logger c = (Logger) cats.nextElement();
- if (!(c.getAllAppenders() instanceof NullEnumeration))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
* This method returns a Manager for the given name.
*
* @param name name of the manager
@@ -648,7 +535,7 @@
AbstractBaseManager m = (AbstractBaseManager) managers.get(name);
if (m == null)
{
- logger.error("No configured manager for key " + name + ".");
+ log.error("No configured manager for key " + name + ".");
}
return m;
}
@@ -667,7 +554,7 @@
AbstractBaseManager m = (AbstractBaseManager) managers.get(name);
if (m == null)
{
- logger.debug("Added late Manager mapping for Class: "
+ log.debug("Added late Manager mapping for Class: "
+ name + " -> " + defaultClassName);
try
@@ -676,7 +563,7 @@
}
catch (TorqueException e)
{
- logger.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
// Try again now that the default manager should be in the map
@@ -995,7 +882,7 @@
}
catch (SQLException e)
{
- logger.error("Error occured while closing connection.", e);
+ log.error("Error occured while closing connection.", e);
}
}
}
1.25 +18 -33 db-torque/src/java/org/apache/torque/pool/ConnectionPool.java
Index: ConnectionPool.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/pool/ConnectionPool.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ConnectionPool.java 20 Jan 2003 21:51:05 -0000 1.24
+++ ConnectionPool.java 14 May 2003 19:38:05 -0000 1.25
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,11 +58,14 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
+
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;
-import org.apache.log4j.Logger;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class implements a simple connection pooling scheme. Multiple
@@ -92,39 +95,25 @@
/** Default Connect Wait Timeout: 10 Seconds */
public static final int DEFAULT_CONNECTION_WAIT_TIMEOUT = 10 * 1000;
- /**
- * Pool containing database connections.
- */
+ /** Pool containing database connections. */
private Stack pool;
- /**
- * The url for this pool.
- */
+ /** The url for this pool. */
private String url;
- /**
- * The user name for this pool.
- */
+ /** The user name for this pool. */
private String username;
- /**
- * The password for this pool.
- */
+ /** The password for this pool. */
private String password;
- /**
- * The current number of database connections that have been created.
- */
+ /** The current number of database connections that have been created. */
private int totalConnections;
- /**
- * The maximum number of database connections that can be created.
- */
+ /** The maximum number of database connections that can be created. */
private int maxConnections = DEFAULT_MAX_CONNECTIONS;
- /**
- * The amount of time in milliseconds that a connection will be pooled.
- */
+ /** The amount of time in milliseconds that a connection will be pooled. */
private long expiryTime = DEFAULT_EXPIRY_TIME;
/**
@@ -133,11 +122,8 @@
*/
private int waitCount = 0;
- /**
- * The logging logger.
- */
- private static Logger logger
- = Logger.getLogger(ConnectionPool.class);
+ /** The logging logger. */
+ private static Log log = LogFactory.getLog(ConnectionPool.class);
/** Interval (in seconds) that the monitor thread reports the pool state */
private int logInterval = 0;
@@ -199,7 +185,7 @@
if (logInterval > 0)
{
- logger.debug("Starting Pool Monitor Thread with Log Interval "
+ log.debug("Starting Pool Monitor Thread with Log Interval "
+ logInterval + " Milliseconds");
// Create monitor thread
@@ -603,8 +589,7 @@
}
catch (Exception e)
{
- logger.error("Error occurred trying to close a "
- + "PooledConnection.", e);
+ log.error("Error occurred trying to close a PooledConnection.", e);
}
finally
{
@@ -645,7 +630,7 @@
buf.append(" avail: ").append(getNbrAvailable());
buf.append(" in use: ").append(getNbrCheckedOut());
buf.append(" total: ").append(getTotalCount());
- logger.info(buf.toString());
+ log.info(buf.toString());
// Wait for a bit.
try