cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r673159 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java
Date Tue, 01 Jul 2008 18:16:28 GMT
Author: aadamchik
Date: Tue Jul  1 11:16:28 2008
New Revision: 673159

URL: http://svn.apache.org/viewvc?rev=673159&view=rev
Log:
a more paranoid implementation of class loading..

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java?rev=673159&r1=673158&r2=673159&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java
Tue Jul  1 11:16:28 2008
@@ -21,6 +21,7 @@
 
 import java.io.Serializable;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.conf.PasswordEncoding;
 import org.apache.cayenne.conf.PlainTextPasswordEncoder;
 import org.apache.cayenne.util.Util;
@@ -37,8 +38,9 @@
  * @author Andrus Adamchik
  */
 public class DataSourceInfo implements Cloneable, Serializable {
+
     private static Log logger = LogFactory.getLog(DataSourceInfo.class);
-    
+
     protected String userName;
     protected String password;
     protected String jdbcDriver;
@@ -204,22 +206,19 @@
     }
 
     public PasswordEncoding getPasswordEncoder() {
-        PasswordEncoding encoder = null;
+        String encoderClassName = getPasswordEncoderClass();
+        if (encoderClassName == null) {
+            encoderClassName = PasswordEncoding.standardEncoders[0];
+        }
 
         try {
-            encoder = (PasswordEncoding) Thread
-                    .currentThread()
-                    .getContextClassLoader()
-                    .loadClass(getPasswordEncoderClass())
+            return (PasswordEncoding) Util
+                    .getJavaClass(getPasswordEncoderClass())
                     .newInstance();
-            // encoder = (PasswordEncoding)
-            // Class.forName(getPasswordEncoderClass()).newInstance();
         }
-        catch (Exception exception) {
-            logger.warn(exception);
+        catch (Exception e) {
+            throw new CayenneRuntimeException("Error loading encoder", e);
         }
-
-        return encoder;
     }
 
     /**



Mime
View raw message