db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1100618 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
Date Sat, 07 May 2011 20:33:20 GMT
Author: tfischer
Date: Sat May  7 20:33:19 2011
New Revision: 1100618

URL: http://svn.apache.org/viewvc?rev=1100618&view=rev
Log:
- Fixed Checkstyle issues
- used java 5 generics

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java?rev=1100618&r1=1100617&r2=1100618&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
Sat May  7 20:33:19 2011
@@ -34,12 +34,13 @@ import java.util.Map;
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-public class DBFactory
+public final class DBFactory
 {
     /**
      * JDBC driver to Torque Adapter map.
      */
-    private static Map adapters = new HashMap(40);
+    private static Map<String, Class<? extends DB>> adapters
+            = new HashMap<String, Class<? extends DB>>();
 
     /**
      * Initialize the JDBC driver to Torque Adapter map.
@@ -122,7 +123,7 @@ public class DBFactory
     public static DB create(String key)
         throws InstantiationException
     {
-        Class adapterClass = (Class) adapters.get(key);
+        Class<? extends DB> adapterClass = adapters.get(key);
 
         if (adapterClass == null)
         {
@@ -155,14 +156,15 @@ public class DBFactory
      * @throws InstantiationException throws if the adapter could not be
      *         instantiated
      */
+    @SuppressWarnings("unchecked")
     public static DB create(String key, String className)
         throws InstantiationException
     {
-        Class adapterClass;
+        Class<?> adapterClass;
 
         try
         {
-            adapterClass = (Class) Class.forName(className);
+            adapterClass = (Class<?>) Class.forName(className);
         }
         catch (ClassNotFoundException e)
         {
@@ -177,8 +179,7 @@ public class DBFactory
         try
         {
             DB adapter = (DB) adapterClass.newInstance();
-            adapters.put(key, adapterClass);
-            // adapter.setJDBCDriver(driver);
+            adapters.put(key, (Class<? extends DB>) adapterClass);
             return adapter;
         }
         catch (IllegalAccessException e)



---------------------------------------------------------------------
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