Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 1536 invoked from network); 20 Aug 2006 18:53:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Aug 2006 18:53:58 -0000 Received: (qmail 8572 invoked by uid 500); 20 Aug 2006 18:53:57 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 8561 invoked by uid 500); 20 Aug 2006 18:53:57 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 8550 invoked by uid 500); 20 Aug 2006 18:53:57 -0000 Received: (qmail 8547 invoked by uid 99); 20 Aug 2006 18:53:57 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Aug 2006 11:53:57 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 098341A981D; Sun, 20 Aug 2006 11:53:07 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r433010 - /db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java Date: Sun, 20 Aug 2006 18:53:06 -0000 To: torque-commits@db.apache.org From: tfischer@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060820185307.098341A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: tfischer Date: Sun Aug 20 11:53:06 2006 New Revision: 433010 URL: http://svn.apache.org/viewvc?rev=433010&view=rev Log: - Do not use exception in the control flow if a custom adapter is used. - Updated argument name and javadoc to reflect that usually short-hand keys are used as key to locate an adapter Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java?rev=433010&r1=433009&r2=433010&view=diff ============================================================================== --- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java (original) +++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java Sun Aug 20 11:53:06 2006 @@ -100,39 +100,35 @@ * Creates a new instance of the Torque database adapter associated * with the specified JDBC driver or adapter key. * - * @param driver The fully-qualified name of the JDBC driver to - * create a new adapter instance for or a shorter form adapter key. - * @return An instance of a Torque database adapter. - * @throws InstantiationException throws if the JDBC driver could not be - * instantiated + * @param key The fully-qualified name of the JDBC driver + * or a shorter form adapter key. + * @return An instance of a Torque database adapter, or null if + * no adapter exists for the given key. + * @throws InstantiationException throws if the adapter could not be + * instantiated */ - public static DB create(String driver) + public static DB create(String key) throws InstantiationException { - Class adapterClass = (Class) adapters.get(driver); + Class adapterClass = (Class) adapters.get(key); - if (adapterClass != null) + if (adapterClass == null) { - try - { - DB adapter = (DB) adapterClass.newInstance(); - // adapter.setJDBCDriver(driver); - return adapter; - } - catch (IllegalAccessException e) - { - throw new InstantiationException( - "Could not instantiate adapter for JDBC driver: " - + driver - + ": Assure that adapter bytecodes are in your classpath"); - } + return null; } - else + + try + { + DB adapter = (DB) adapterClass.newInstance(); + // adapter.setJDBCDriver(driver); + return adapter; + } + catch (IllegalAccessException e) { throw new InstantiationException( - "Unknown JDBC driver: " - + driver - + ": Check your configuration file"); + "Could not instantiate adapter for key : " + + key + + ": Assure that adapter classes are in your classpath"); } } @@ -140,14 +136,14 @@ * Creates a new instance of the Torque database adapter associated * with the specified JDBC driver or adapter key and the class defined. * - * @param driver The fully-qualified name of the JDBC driver to - * create a new adapter instance for or a shorter form adapter key. + * @param key The fully-qualified name of the JDBC driver + * or a shorter form adapter key. * @param className The fully qualified name of the adapter class * @return An instance of a Torque database adapter. - * @throws InstantiationException throws if the JDBC driver could not be - * instantiated + * @throws InstantiationException throws if the adapter could not be + * instantiated */ - public static DB create(String driver, String className) + public static DB create(String key, String className) throws InstantiationException { Class adapterClass; @@ -161,24 +157,24 @@ throw new InstantiationException( "Could not find adapter " + className - + " for driver " - + driver + + " for key " + + key + ": Check your configuration file"); } try { DB adapter = (DB) adapterClass.newInstance(); - adapters.put(driver, adapterClass); + adapters.put(key, adapterClass); // adapter.setJDBCDriver(driver); return adapter; } catch (IllegalAccessException e) { throw new InstantiationException( - "Could not instantiate adapter for JDBC driver: " - + driver - + ": Assure that adapter bytecodes are in your classpath"); + "Could not instantiate adapter for key: " + + key + + ": Assure that adapter classes are in your classpath"); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org