jmcnally 2002/08/20 18:51:21
Modified: src/java/org/apache/torque/pool TorqueClassicDataSource.java
Log:
set the dataSourceName even if the backend is supplied through the cpds setter.
This is needed in the event multiple DataSources are initialized in this
manner.
Revision Changes Path
1.4 +30 -1
jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java
Index: TorqueClassicDataSource.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TorqueClassicDataSource.java 21 Aug 2002 01:48:22 -0000 1.3
+++ TorqueClassicDataSource.java 21 Aug 2002 01:51:21 -0000 1.4
@@ -87,6 +87,7 @@
{
/** Pools keyed by username. */
private static Map pools = new HashMap();
+ private static int cpdsCounter;
/** DataSource Name used to find the ConnectionPoolDataSource */
private String dataSourceName;
@@ -317,6 +318,13 @@
*/
public void setDataSourceName(String v)
{
+ if (getConnectionPoolDataSource() != null)
+ {
+ throw new IllegalStateException("connectionPoolDataSource property"
+ + " already has a value. Both dataSourceName and "
+ + "connectionPoolDataSource properties cannot be set.");
+ }
+
this.dataSourceName = v;
}
@@ -397,9 +405,24 @@
*
* @param v Value to assign to connectionPoolDataSource.
*/
- public void setConnectionPoolDataSource(ConnectionPoolDataSource v)
+ public void
+ setConnectionPoolDataSource(ConnectionPoolDataSource v)
{
+ if (v == null)
+ {
+ throw new IllegalArgumentException(
+ "Null argument value is not allowed.");
+ }
+ if (getDataSourceName() != null)
+ {
+ throw new IllegalStateException("dataSourceName property"
+ + " already has a value. Both dataSourceName and "
+ + "connectionPoolDataSource properties cannot be set.");
+ }
this.cpds = v;
+
+ // set the dataSourceName to a unique value
+ dataSourceName = v.hashCode() + " internal cpds name " + cpdsCounter++;
}
@@ -444,6 +467,12 @@
private String getKey(String suffix)
{
String key = getDataSourceName();
+ if (key == null)
+ {
+ throw new IllegalStateException("Attempted to use DataSource "
+ + "without a backend ConnectionPoolDataSource defined.");
+ }
+
if ( suffix != null )
{
key += suffix;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>