remm 2005/02/01 05:12:31 Modified: catalina/src/share/org/apache/catalina/startup LocalStrings.properties ExpandWar.java Log: - Use NIO for the raw copying operation, as it is faster (a little under 30%), which decreases a little the impact of antResourceLocking. Revision Changes Path 1.12 +1 -0 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- LocalStrings.properties 3 Jan 2005 16:10:19 -0000 1.11 +++ LocalStrings.properties 1 Feb 2005 13:12:31 -0000 1.12 @@ -37,6 +37,7 @@ engineConfig.cce=Lifecycle event data object {0} is not an Engine engineConfig.start=EngineConfig: Processing START engineConfig.stop=EngineConfig: Processing STOP +expandWar.copy=Error copying {0} to {1} hostConfig.appBase=Application base directory {0} does not exist hostConfig.canonicalizing=Error delete redeploy resources from context [{0}] hostConfig.cce=Lifecycle event data object {0} is not a Host 1.10 +17 -29 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ExpandWar.java Index: ExpandWar.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ExpandWar.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ExpandWar.java 27 Jul 2004 17:53:14 -0000 1.9 +++ ExpandWar.java 1 Feb 2005 13:12:31 -0000 1.10 @@ -25,12 +25,15 @@ import java.io.IOException; import java.net.JarURLConnection; import java.net.URL; +import java.nio.channels.FileChannel; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; import org.apache.catalina.Host; import org.apache.catalina.util.StringManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * Expand out a WAR in a Host's appBase. @@ -43,6 +46,7 @@ public class ExpandWar { + private static Log log = LogFactory.getLog(ExpandWar.class); /** * The string resources for this package. @@ -189,17 +193,6 @@ * @param dest File object representing the destination */ public static boolean copy(File src, File dest) { - return copyInternal(src, dest, new byte[4096]); - } - - - /** - * Copy the specified file or directory to the destination. - * - * @param src File object representing the source - * @param dest File object representing the destination - */ - public static boolean copyInternal(File src, File dest, byte[] buf) { boolean result = true; @@ -218,33 +211,28 @@ File fileSrc = new File(src, files[i]); File fileDest = new File(dest, files[i]); if (fileSrc.isDirectory()) { - result = copyInternal(fileSrc, fileDest, buf); + result = copy(fileSrc, fileDest); } else { - FileInputStream is = null; - FileOutputStream os = null; + FileChannel ic = null; + FileChannel oc = null; try { - is = new FileInputStream(fileSrc); - os = new FileOutputStream(fileDest); - int len = 0; - while (true) { - len = is.read(buf); - if (len == -1) - break; - os.write(buf, 0, len); - } + ic = (new FileInputStream(fileSrc)).getChannel(); + oc = (new FileOutputStream(fileDest)).getChannel(); + ic.transferTo(0, ic.size(), oc); } catch (IOException e) { - e.printStackTrace(); + log.error(sm.getString + ("expandWar.copy", fileSrc, fileDest), e); result = false; } finally { - if (is != null) { + if (ic != null) { try { - is.close(); + ic.close(); } catch (IOException e) { } } - if (os != null) { + if (oc != null) { try { - os.close(); + oc.close(); } catch (IOException e) { } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]