db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r360038 - /db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
Date Fri, 30 Dec 2005 08:45:09 GMT
Author: tfischer
Date: Fri Dec 30 00:44:42 2005
New Revision: 360038

URL: http://svn.apache.org/viewcvs?rev=360038&view=rev
Log:
Externalized some String properties

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java?rev=360038&r1=360037&r2=360038&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
Fri Dec 30 00:44:42 2005
@@ -49,6 +49,33 @@
 public class JndiDataSourceFactory
     extends AbstractDataSourceFactory
 {
+    /**
+     * Key for the configuration which contains jndi properties.
+     */
+    public static final String JNDI_KEY = "jndi";
+
+    /**
+     *  Key for the configuration property which contains the jndi path.
+     */
+    public static final String PATH_KEY = "path";
+
+    /**
+     *  Key for the configuration property which contains the 
+     *  time between two jndi lookups.
+     */
+    public static final String TIME_BETWEEN_LOOKUPS_KEY = "ttl";
+
+    /**
+     * Key for the configuration which contains properties for a DataSource
+     * which should be bound into jndi.
+     */
+    public static final String DATASOURCE_KEY = "datasource";
+    
+    /**
+     *  Key for the configuration property which contains the class name
+     *  of the datasource to be bound into jndi.
+     */
+    public static final String CLASSNAME_KEY = "classname";
 
     /** The log. */
     private static Log log = LogFactory.getLog(JndiDataSourceFactory.class);
@@ -111,7 +138,7 @@
     {
         log.debug("Starting initJNDI");
 
-        Configuration c = configuration.subset("jndi");
+        Configuration c = configuration.subset(JNDI_KEY);
         if (c == null || c.isEmpty())
         {
             throw new TorqueException(
@@ -125,7 +152,7 @@
             for (Iterator i = c.getKeys(); i.hasNext(); )
             {
                 String key = (String) i.next();
-                if (key.equals("path"))
+                if (key.equals(PATH_KEY))
                 {
                     path = c.getString(key);
                     if (log.isDebugEnabled())
@@ -133,7 +160,7 @@
                         log.debug("JNDI path: " + path);
                     }
                 }
-                else if (key.equals("ttl"))
+                else if (key.equals(TIME_BETWEEN_LOOKUPS_KEY))
                 {
                     ttl = c.getLong(key, ttl);
                     if (log.isDebugEnabled())
@@ -177,13 +204,13 @@
         {
             Object ds = null;
 
-            Configuration c = configuration.subset("datasource");
+            Configuration c = configuration.subset(DATASOURCE_KEY);
             if (c != null)
             {
                 for (Iterator i = c.getKeys(); i.hasNext(); )
                 {
                     String key = (String) i.next();
-                    if (key.equals("classname"))
+                    if (key.equals(CLASSNAME_KEY))
                     {
                         String classname = c.getString(key);
                         if (log.isDebugEnabled())
@@ -206,7 +233,8 @@
                         }
                         else
                         {
-                            log.error("Tried to set property " + key + " without Datasource
definition!");
+                            log.error("Tried to set property " + key 
+                                    + " without Datasource definition!");
                         }
                     }
                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message