Author: cbegin
Date: Sun Dec  6 03:26:02 2009
New Revision: 887631

URL: http://svn.apache.org/viewvc?rev=887631&view=rev
Log:
ibatis-685 Custome driver path for ibatis migration tool - with patch attached.

Modified:
    
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java

Modified: 
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
URL: 
http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java?rev=887631&r1=887630&r2=887631&view=diff
==============================================================================
--- 
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
 (original)
+++ 
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
 Sun Dec  6 03:26:02 2009
@@ -211,7 +211,7 @@
   }
 
   protected File driverFile(String fileName) {
-    return new File(driverPath.getAbsolutePath() + File.separator + fileName);
+    return new File(getCustomDriverPath().getAbsolutePath() + File.separator + 
fileName);
   }
 
   protected File environmentFile() {
@@ -228,9 +228,10 @@
 
   private void lazyInitializeDrivers() {
     try {
-      if (driverClassLoader == null && driverPath.exists()) {
+      File localDriverPath = getCustomDriverPath();
+      if (driverClassLoader == null && localDriverPath.exists()) {
         List<URL> urlList = new ArrayList<URL>();
-        for (File file : driverPath.listFiles()) {
+        for (File file : localDriverPath.listFiles()) {
           String filename = file.getCanonicalPath();
           if (!filename.startsWith("/")) {
             filename = "/" + filename;
@@ -273,6 +274,15 @@
     return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new 
java.sql.Date(System.currentTimeMillis()));
   }
 
+  private File getCustomDriverPath() {
+    String customDriverPath = 
environmentProperties().getProperty("driver_path");
+    if (customDriverPath != null && customDriverPath.length() > 0) {
+      return new File(customDriverPath);
+    } else {
+      return driverPath;
+    }
+  }
+
   private File subdirectory(File base, String sub) {
     return new File(base.getAbsoluteFile() + File.separator + sub);
   }


Reply via email to