ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r808350 [1/3] - in /ant/core/trunk: ./ src/main/org/apache/tools/ant/taskdefs/optional/junit/ src/main/org/apache/tools/ant/taskdefs/optional/net/ src/main/org/apache/tools/ant/util/
Date Thu, 27 Aug 2009 10:14:08 GMT
Author: bodewig
Date: Thu Aug 27 10:14:07 2009
New Revision: 808350

URL: http://svn.apache.org/viewvc?rev=808350&view=rev
Log:
refactored <ftp> so commons-net may be loaded via a separate classloader.  Based on
patch by Greg Roodt in PR 45860.  Not really tested, yet, therefore I haven't changed defaults.properties
so far

Added:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java   (contents,
props changed)
      - copied, changed from r808299, ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskConfig.java
  (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirror.java
  (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  (contents, props changed)
      - copied, changed from r808299, ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/SplitClassLoader.java   (with props)
Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=808350&r1=808349&r2=808350&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=808350&r1=808349&r2=808350&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Thu Aug 27 10:14:07 2009
@@ -484,6 +484,10 @@
   </name>
   <name>
     <first>Greg</first>
+    <last>Roodt</last>
+  </name>
+  <name>
+    <first>Greg</first>
     <last>Schueler</last>
   </name>
   <name>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=808350&r1=808349&r2=808350&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Thu
Aug 27 10:14:07 2009
@@ -59,6 +59,7 @@
 import org.apache.tools.ant.types.PropertySet;
 import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.util.LoaderUtils;
+import org.apache.tools.ant.util.SplitClassLoader;
 
 /**
  * Runs JUnit tests.
@@ -708,57 +709,6 @@
         }
     }
 
-    private final class SplitLoader extends AntClassLoader {
-
-        public SplitLoader(ClassLoader parent, Path path) {
-            super(parent, getProject(), path, true);
-        }
-
-        // forceLoadClass is not convenient here since it would not
-        // properly deal with inner classes of these classes.
-        protected synchronized Class loadClass(String classname, boolean resolve)
-        throws ClassNotFoundException {
-            Class theClass = findLoadedClass(classname);
-            if (theClass != null) {
-                return theClass;
-            }
-            if (isSplit(classname)) {
-                theClass = findClass(classname);
-                if (resolve) {
-                    resolveClass(theClass);
-                }
-                return theClass;
-            } else {
-                return super.loadClass(classname, resolve);
-            }
-        }
-
-        private final String[] splitClasses = {
-            "BriefJUnitResultFormatter",
-            "JUnitResultFormatter",
-            "JUnitTaskMirrorImpl",
-            "JUnitTestRunner",
-            "JUnitVersionHelper",
-            "OutErrSummaryJUnitResultFormatter",
-            "PlainJUnitResultFormatter",
-            "SummaryJUnitResultFormatter",
-            "TearDownOnVmCrash",
-            "XMLJUnitResultFormatter",
-        };
-
-        private boolean isSplit(String classname) {
-            String simplename = classname.substring(classname.lastIndexOf('.') + 1);
-            for (int i = 0; i < splitClasses.length; i++) {
-                if (simplename.equals(splitClasses[i])
-                        || simplename.startsWith(splitClasses[i] + '$')) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-    }
-
     /**
      * Sets up the delegate that will actually run the tests.
      *
@@ -775,7 +725,20 @@
             if (extra != null) {
                 path.add(extra);
             }
-            mirrorLoader = new SplitLoader(myLoader, path);
+            mirrorLoader =
+                new SplitClassLoader(myLoader, path, getProject(),
+                                     new String[] {
+                                         "BriefJUnitResultFormatter",
+                                         "JUnitResultFormatter",
+                                         "JUnitTaskMirrorImpl",
+                                         "JUnitTestRunner",
+                                         "JUnitVersionHelper",
+                                         "OutErrSummaryJUnitResultFormatter",
+                                         "PlainJUnitResultFormatter",
+                                         "SummaryJUnitResultFormatter",
+                                         "TearDownOnVmCrash",
+                                         "XMLJUnitResultFormatter",
+                                     });
         } else {
             mirrorLoader = myLoader;
         }
@@ -1667,8 +1630,8 @@
             classLoader.cleanup();
             classLoader = null;
         }
-        if (mirrorLoader instanceof SplitLoader) {
-            ((SplitLoader) mirrorLoader).cleanup();
+        if (mirrorLoader instanceof SplitClassLoader) {
+            ((SplitClassLoader) mirrorLoader).cleanup();
         }
         mirrorLoader = null;
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java?rev=808350&r1=808349&r2=808350&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java Thu Aug 27
10:14:07 2009
@@ -76,8 +76,7 @@
  *
  * @since Ant 1.3
  */
-public class FTP
-    extends Task {
+public class FTP extends Task implements FTPTaskConfig {
     protected static final int SEND_FILES = 0;
     protected static final int GET_FILES = 1;
     protected static final int DEL_FILES = 2;
@@ -1558,37 +1557,37 @@
     /**
      * @return Returns the systemTypeKey.
      */
-    String getSystemTypeKey() {
+    public String getSystemTypeKey() {
         return systemTypeKey.getValue();
     }
     /**
      * @return Returns the defaultDateFormatConfig.
      */
-    String getDefaultDateFormatConfig() {
+    public String getDefaultDateFormatConfig() {
         return defaultDateFormatConfig;
     }
     /**
      * @return Returns the recentDateFormatConfig.
      */
-    String getRecentDateFormatConfig() {
+    public String getRecentDateFormatConfig() {
         return recentDateFormatConfig;
     }
     /**
      * @return Returns the serverLanguageCodeConfig.
      */
-    String getServerLanguageCodeConfig() {
+    public String getServerLanguageCodeConfig() {
         return serverLanguageCodeConfig.getValue();
     }
     /**
      * @return Returns the serverTimeZoneConfig.
      */
-    String getServerTimeZoneConfig() {
+    public String getServerTimeZoneConfig() {
         return serverTimeZoneConfig;
     }
     /**
      * @return Returns the shortMonthNamesConfig.
      */
-    String getShortMonthNamesConfig() {
+    public String getShortMonthNamesConfig() {
         return shortMonthNamesConfig;
     }
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java?rev=808350&r1=808349&r2=808350&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
Thu Aug 27 10:14:07 2009
@@ -18,6 +18,7 @@
 package org.apache.tools.ant.taskdefs.optional.net;
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPClientConfig;
+import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 
 /**
@@ -38,7 +39,7 @@
      * configure the client
      * @return the client as configured.
      */
-    static FTPClient configure(FTPClient client, FTP task) {
+    static FTPClient configure(FTPClient client, FTPTaskConfig task) {
         task.log("custom configuration", Project.MSG_VERBOSE);
         FTPClientConfig config;
         String systemTypeKey = task.getSystemTypeKey();
@@ -68,6 +69,12 @@
 
         String serverLanguageCodeConfig = task.getServerLanguageCodeConfig();
         if (serverLanguageCodeConfig != null) {
+            if (!"".equals(serverLanguageCodeConfig)
+                && !FTPClientConfig.getSupportedLanguageCodes()
+                .contains(serverLanguageCodeConfig)) {
+                throw new BuildException("unsupported language code" +
+                                         serverLanguageCodeConfig);
+            }
             config.setServerLanguageCode(serverLanguageCodeConfig);
             task.log("custom config: server language code = "
                     + serverLanguageCodeConfig, Project.MSG_VERBOSE);



Mime
View raw message