henning 2004/12/29 02:32:14
Modified: . Tag: TORQUE_3_1_BRANCH project-base.xml
src/java/org/apache/torque/dsfactory Tag: TORQUE_3_1_BRANCH
JndiDataSourceFactory.java
xdocs Tag: TORQUE_3_1_BRANCH changes.xml
Log:
Make sure that JNDI datasources are only bound if they are also
configured. Patch suggested by M. Sean Gilligan and Roger A. Caron.
Revision Changes Path
No revision
No revision
1.9.2.16 +8 -0 db-torque/project-base.xml
Index: project-base.xml
===================================================================
RCS file: /home/cvs/db-torque/project-base.xml,v
retrieving revision 1.9.2.15
retrieving revision 1.9.2.16
diff -u -r1.9.2.15 -r1.9.2.16
--- project-base.xml 1 Dec 2004 16:28:05 -0000 1.9.2.15
+++ project-base.xml 29 Dec 2004 10:32:05 -0000 1.9.2.16
@@ -237,8 +237,16 @@
<email>[EMAIL PROTECTED]</email>
</contributor>
<contributor>
+ <name>Roger A. Caron</name>
+ <email>[EMAIL PROTECTED]</email>
+ </contributor>
+ <contributor>
<name>Martin Goulet</name>
<email>[EMAIL PROTECTED]</email>
+ </contributor>
+ <contributor>
+ <name>M. Sean Gilligan</name>
+ <email>[EMAIL PROTECTED]</email>
</contributor>
<contributor>
<name>James Hillyerd</name>
No revision
No revision
1.6.2.6 +45 -29
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.6.2.5
retrieving revision 1.6.2.6
diff -u -r1.6.2.5 -r1.6.2.6
--- JndiDataSourceFactory.java 13 Dec 2004 17:08:27 -0000 1.6.2.5
+++ JndiDataSourceFactory.java 29 Dec 2004 10:32:06 -0000 1.6.2.6
@@ -111,49 +111,49 @@
private void initJNDI(Configuration configuration) throws TorqueException
{
log.debug("Starting initJNDI");
- Hashtable env = null;
+
Configuration c = configuration.subset("jndi");
- if (c == null)
+ if (c == null || c.isEmpty())
{
throw new TorqueException(
"JndiDataSourceFactory requires a jndi "
+ "path property to lookup the DataSource in JNDI.");
}
+
try
{
- Iterator i = c.getKeys();
- while (i.hasNext())
+ Hashtable env = new Hashtable();
+ for (Iterator i = c.getKeys(); i.hasNext(); )
{
String key = (String) i.next();
if (key.equals("path"))
{
path = c.getString(key);
- log.debug("JNDI path: " + path);
+ if (log.isDebugEnabled())
+ {
+ log.debug("JNDI path: " + path);
+ }
}
else if (key.equals("ttl"))
{
ttl = c.getLong(key, ttl);
- log.debug("Time between context lookups: " + ttl);
+ if (log.isDebugEnabled())
+ {
+ log.debug("Time between context lookups: " + ttl);
+ }
}
else
{
- if (env == null)
- {
- env = new Hashtable();
- }
String value = c.getString(key);
env.put(key, value);
- log.debug("Set jndi property: " + key + "=" + value);
+ if (log.isDebugEnabled())
+ {
+ log.debug("Set jndi property: " + key + "=" + value);
+ }
}
}
- if (env == null)
- {
- ctx = new InitialContext();
- }
- else
- {
- ctx = new InitialContext(env);
- }
+
+ ctx = new InitialContext(env);
log.debug("Created new InitialContext");
debugCtx(ctx);
}
@@ -173,32 +173,48 @@
private void initDataSource(Configuration configuration)
throws TorqueException
{
- log.debug("Starting initDataSources");
- Configuration c = configuration.subset("datasource");
+ log.debug("Starting initDataSource");
try
{
+ Object ds = null;
+
+ Configuration c = configuration.subset("datasource");
if (c != null)
{
- Object ds = null;
- Iterator i = c.getKeys();
- while (i.hasNext())
+ for (Iterator i = c.getKeys(); i.hasNext(); )
{
String key = (String) i.next();
if (key.equals("classname"))
{
String classname = c.getString(key);
- log.debug("Datasource class: " + classname);
-
+ if (log.isDebugEnabled())
+ {
+ log.debug("Datasource class: " + classname);
+ }
+
Class dsClass = Class.forName(classname);
ds = dsClass.newInstance();
}
else
{
- log.debug("Setting datasource property: " + key);
- setProperty(key, c, ds);
+ if (ds != null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Setting datasource property: " +
key);
+ }
+ setProperty(key, c, ds);
+ }
+ else
+ {
+ log.error("Tried to set property " + key + "
without Datasource definition!");
+ }
}
}
+ }
+ if (ds != null)
+ {
bindDStoJndi(ctx, path, ds);
}
}
No revision
No revision
1.140.2.27 +4 -0 db-torque/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/db-torque/xdocs/changes.xml,v
retrieving revision 1.140.2.26
retrieving revision 1.140.2.27
diff -u -r1.140.2.26 -r1.140.2.27
--- changes.xml 13 Dec 2004 17:08:28 -0000 1.140.2.26
+++ changes.xml 29 Dec 2004 10:32:07 -0000 1.140.2.27
@@ -27,6 +27,10 @@
<body>
<release version="3.1.2-dev" date="in CVS">
<action type="add" dev="henning">
+ Make sure that JNDI datasources are only bound if they are also
+ configured. Patch suggested by M. Sean Gilligan and Roger A. Caron.
+ </action>
+ <action type="add" dev="henning">
Add rudimentary schema support (see <a href="schema-howto.html">Schema
Support Howto</a>).
</action>
<action type="add" dev="henning">
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]