henning 2003/01/09 07:39:35
Modified: src/conf Torque.properties
src/conf/master Torque.master
src/java/org/apache/torque/dsfactory
AbstractDataSourceFactory.java
Jdbc2PoolDataSourceFactory.java
TorqueDataSourceFactory.java
src/test Torque.properties
Log:
Added the ability to supply "default" values for all data sources. This
is done by a "defaults" subsection in the Torque.properties. Put some
examples into the supplied Torque configuration files.
Revision Changes Path
1.8 +45 -1 jakarta-turbine-torque/src/conf/Torque.properties
Index: Torque.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/conf/Torque.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Torque.properties 11 Sep 2002 13:53:26 -0000 1.7
+++ Torque.properties 9 Jan 2003 15:39:34 -0000 1.8
@@ -32,6 +32,50 @@
# -------------------------------------------------------------------
#
+# D E F A U L T S
+#
+# -------------------------------------------------------------------
+#
+# These values kick in, if you don't explicitly override them in your
+# various database settings. At the moment they're only used if you
+# configure the TorqueDataSourceFactory of the Jdbc2PoolDataSourceFactory
+# as your data source provider. It does not work with JNDI.
+#
+# The example is shown for TorqueDataSource.
+#
+# -------------------------------------------------------------------
+
+# If > 0, then a monitoring thread is started for every pool to
+# display the number of created, available and checked out connections
+# The interval is in seconds.
+torque.defaults.pool.logInterval = 0
+
+# Time to wait for a connection to the databas in Seconds.
+torque.defaults.pool.connectionWaitTimeout = 10
+
+# Maximum number of connections cached in a database definition. Note
+# that, if you have multiple database definitions which access the
+# same database URL, they don't share the connections but you have
+# multiple pools and each has this maximum number. So if you have a
+# connection licensed database engine, you must multiply this number by
+# the number of times you use a specific database URL.
+torque.defaults.pool.defaultMaxConnections = 80
+
+# Lifetime of a connection in the pool. Defaults to one hour
+torque.defaults.pool.maxExpiryTime = 3600
+
+# Sets the driver for the data sources.
+torque.defaults.connection.driver = org.gjt.mm.mysql.Driver
+
+# Sets the URL for the datasources
+torque.defaults.connection.url = jdbc:mysql://localhost:3306/torque
+
+# Sets login and password for the data sources.
+torque.defaults.connection.username = user
+torque.defaults.connection.password = password
+
+# -------------------------------------------------------------------
+#
# T O R Q U E P R O P E R T I E S
#
# -------------------------------------------------------------------
1.6 +45 -1 jakarta-turbine-torque/src/conf/master/Torque.master
Index: Torque.master
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/conf/master/Torque.master,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Torque.master 28 Nov 2002 14:06:12 -0000 1.5
+++ Torque.master 9 Jan 2003 15:39:34 -0000 1.6
@@ -32,6 +32,50 @@
# -------------------------------------------------------------------
#
+# D E F A U L T S
+#
+# -------------------------------------------------------------------
+#
+# These values kick in, if you don't explicitly override them in your
+# various database settings. At the moment they're only used if you
+# configure the TorqueDataSourceFactory of the Jdbc2PoolDataSourceFactory
+# as your data source provider. It does not work with JNDI.
+#
+# The example is shown for TorqueDataSource.
+#
+# -------------------------------------------------------------------
+
+# If > 0, then a monitoring thread is started for every pool to
+# display the number of created, available and checked out connections
+# The interval is in seconds.
+torque.defaults.pool.logInterval = 0
+
+# Time to wait for a connection to the databas in Seconds.
+torque.defaults.pool.connectionWaitTimeout = 10
+
+# Maximum number of connections cached in a database definition. Note
+# that, if you have multiple database definitions which access the
+# same database URL, they don't share the connections but you have
+# multiple pools and each has this maximum number. So if you have a
+# connection licensed database engine, you must multiply this number by
+# the number of times you use a specific database URL.
+torque.defaults.pool.defaultMaxConnections = 80
+
+# Lifetime of a connection in the pool. Defaults to one hour
+torque.defaults.pool.maxExpiryTime = 3600
+
+# Sets the driver for the data sources.
+torque.defaults.connection.driver = @DATABASE_DRIVER@
+
+# Sets the URL for the datasources
+torque.defaults.connection.url = @DATABASE_URL@
+
+# Sets login and password for the data sources.
+torque.defaults.connection.username = @DATABASE_USER@
+torque.defaults.connection.password = @DATABASE_PASSWORD@
+
+# -------------------------------------------------------------------
+#
# T O R Q U E P R O P E R T I E S
#
# -------------------------------------------------------------------
1.7 +13 -1
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java
Index: AbstractDataSourceFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractDataSourceFactory.java 9 Jan 2003 15:25:08 -0000 1.6
+++ AbstractDataSourceFactory.java 9 Jan 2003 15:39:35 -0000 1.7
@@ -72,6 +72,18 @@
*/
public abstract class AbstractDataSourceFactory
{
+ /** "pool" Key for the configuration */
+ public static final String POOL_KEY = "pool";
+
+ /** "connection" Key for the configuration */
+ public static final String CONNECTION_KEY = "connection";
+
+ /** "default.pool" Key for the configuration */
+ public static final String DEFAULT_POOL_KEY = "defaults.pool";
+
+ /** "default.connection" Key for the configuration */
+ public static final String DEFAULT_CONNECTION_KEY = "defaults.connection";
+
/**
* The logging category.
*/
1.6 +11 -6
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java
Index: Jdbc2PoolDataSourceFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Jdbc2PoolDataSourceFactory.java 9 Jan 2003 15:25:08 -0000 1.5
+++ Jdbc2PoolDataSourceFactory.java 9 Jan 2003 15:39:35 -0000 1.6
@@ -63,12 +63,11 @@
import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
import org.apache.commons.dbcp.jdbc2pool.Jdbc2PoolDataSource;
import org.apache.log4j.Category;
+import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
/**
- * A factory that looks up the DataSource from JNDI. It is also able
- * to deploy the DataSource based on properties found in the
- * configuration.
+ * A factory that looks up the DataSource using the JDBC2 pool methods.
*
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
@@ -126,7 +125,10 @@
ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
Configuration c = null;
- c = configuration.subset("connection");
+ c = Torque.getConfiguration().subset(DEFAULT_CONNECTION_KEY);
+ applyConfiguration(c, cpds);
+
+ c = configuration.subset(CONNECTION_KEY);
applyConfiguration(c, cpds);
return cpds;
}
@@ -145,7 +147,10 @@
Jdbc2PoolDataSource ds = new Jdbc2PoolDataSource();
Configuration c = null;
- c = configuration.subset("pool");
+ c = Torque.getConfiguration().subset(DEFAULT_POOL_KEY);
+ applyConfiguration(c, ds);
+
+ c = configuration.subset(POOL_KEY);
applyConfiguration(c, ds);
return ds;
}
1.8 +10 -3
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java
Index: TorqueDataSourceFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TorqueDataSourceFactory.java 9 Jan 2003 15:25:08 -0000 1.7
+++ TorqueDataSourceFactory.java 9 Jan 2003 15:39:35 -0000 1.8
@@ -62,6 +62,7 @@
import org.apache.commons.configuration.Configuration;
import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
import org.apache.log4j.Category;
+import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.pool.TorqueClassicDataSource;
@@ -124,7 +125,10 @@
ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
Configuration c = null;
- c = configuration.subset("connection");
+ c = Torque.getConfiguration().subset(DEFAULT_CONNECTION_KEY);
+ applyConfiguration(c, cpds);
+
+ c = configuration.subset(CONNECTION_KEY);
applyConfiguration(c, cpds);
return cpds;
}
@@ -145,7 +149,10 @@
Configuration c = null;
- c = configuration.subset("pool");
+ c = Torque.getConfiguration().subset(DEFAULT_POOL_KEY);
+ applyConfiguration(c, ds);
+
+ c = configuration.subset(POOL_KEY);
applyConfiguration(c, ds);
return ds;
}
1.10 +45 -1 jakarta-turbine-torque/src/test/Torque.properties
Index: Torque.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/test/Torque.properties,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Torque.properties 8 Jan 2003 16:40:41 -0000 1.9
+++ Torque.properties 9 Jan 2003 15:39:35 -0000 1.10
@@ -50,6 +50,50 @@
# -------------------------------------------------------------------
#
+# D E F A U L T S
+#
+# -------------------------------------------------------------------
+#
+# These values kick in, if you don't explicitly override them in your
+# various database settings. At the moment they're only used if you
+# configure the TorqueDataSourceFactory of the Jdbc2PoolDataSourceFactory
+# as your data source provider. It does not work with JNDI.
+#
+# The example is shown for TorqueDataSource.
+#
+# -------------------------------------------------------------------
+
+# If > 0, then a monitoring thread is started for every pool to
+# display the number of created, available and checked out connections
+# The interval is in seconds.
+torque.defaults.pool.logInterval = 0
+
+# Time to wait for a connection to the databas in Seconds.
+torque.defaults.pool.connectionWaitTimeout = 10
+
+# Maximum number of connections cached in a database definition. Note
+# that, if you have multiple database definitions which access the
+# same database URL, they don't share the connections but you have
+# multiple pools and each has this maximum number. So if you have a
+# connection licensed database engine, you must multiply this number by
+# the number of times you use a specific database URL.
+torque.defaults.pool.defaultMaxConnections = 80
+
+# Lifetime of a connection in the pool. Defaults to one hour
+torque.defaults.pool.maxExpiryTime = 3600
+
+# Sets the driver for the data sources.
+torque.defaults.connection.driver = org.postgresql.Driver
+
+# Sets the URL for the datasources
+torque.defaults.connection.url = jdbc:postgresql://localhost:5432/bookstore
+
+# Sets login and password for the data sources.
+torque.defaults.connection.username =
+torque.defaults.connection.password =
+
+# -------------------------------------------------------------------
+#
# T O R Q U E P R O P E R T I E S
#
# -------------------------------------------------------------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>