ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/loader AntClassLoader2.java
Date Mon, 19 Jan 2004 16:48:44 GMT
peterreilly    2004/01/19 08:48:44

  Modified:    src/main/org/apache/tools/ant/loader Tag: ANT_16_BRANCH
                        AntClassLoader2.java
  Log:
  sync with HEAD
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.1   +41 -26    ant/src/main/org/apache/tools/ant/loader/AntClassLoader2.java
  
  Index: AntClassLoader2.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/loader/AntClassLoader2.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- AntClassLoader2.java	17 Jul 2003 10:36:27 -0000	1.7
  +++ AntClassLoader2.java	19 Jan 2004 16:48:44 -0000	1.7.2.1
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -68,6 +68,9 @@
   import java.net.URL;
   import java.net.MalformedURLException;
   import java.util.zip.ZipEntry;
  +import java.util.Collections;
  +import java.util.HashMap;
  +import java.util.Map;
   import java.util.StringTokenizer;
   import org.apache.tools.ant.util.FileUtils;
   
  @@ -81,6 +84,9 @@
       /** Instance of a utility class to use for file operations. */
       private FileUtils fileUtils;
   
  +    /** Static map of jar file/time to manifiest class-path entries */
  +    private static Map pathMap = Collections.synchronizedMap(new HashMap());
  +
       /**
        * Constructor
        */
  @@ -272,36 +278,45 @@
               return;
           }
   
  -        String classpath = null;
  -        ZipFile jarFile = null;
  -        InputStream manifestStream = null;
  -        try {
  -            jarFile = new ZipFile(pathComponent);
  -            manifestStream
  -                = jarFile.getInputStream(new ZipEntry("META-INF/MANIFEST.MF"));
  -
  -            if (manifestStream == null) {
  -                return;
  -            }
  -            Reader manifestReader
  -                = new InputStreamReader(manifestStream, "UTF-8");
  -            org.apache.tools.ant.taskdefs.Manifest manifest
  -                = new org.apache.tools.ant.taskdefs.Manifest(manifestReader);
  -            classpath
  -                = manifest.getMainSection().getAttributeValue("Class-Path");
  +        String absPathPlusTimeAndLength =
  +            pathComponent.getAbsolutePath() + pathComponent.lastModified() + "-"
  +            + pathComponent.length();
  +        String classpath = (String) pathMap.get(absPathPlusTimeAndLength);
  +        if (classpath == null) {
  +            ZipFile jarFile = null;
  +            InputStream manifestStream = null;
  +            try {
  +                jarFile = new ZipFile(pathComponent);
  +                manifestStream
  +                    = jarFile.getInputStream(new ZipEntry("META-INF/MANIFEST.MF"));
  +
  +                if (manifestStream == null) {
  +                    return;
  +                }
  +                Reader manifestReader
  +                    = new InputStreamReader(manifestStream, "UTF-8");
  +                org.apache.tools.ant.taskdefs.Manifest manifest
  +                    = new org.apache.tools.ant.taskdefs.Manifest(manifestReader);
  +                classpath
  +                    = manifest.getMainSection().getAttributeValue("Class-Path");
   
  -        } catch (org.apache.tools.ant.taskdefs.ManifestException e) {
  -            // ignore
  -        } finally {
  -            if (manifestStream != null) {
  -                manifestStream.close();
  +            } catch (org.apache.tools.ant.taskdefs.ManifestException e) {
  +                // ignore
  +            } finally {
  +                if (manifestStream != null) {
  +                    manifestStream.close();
  +                }
  +                if (jarFile != null) {
  +                    jarFile.close();
  +                }
               }
  -            if (jarFile != null) {
  -                jarFile.close();
  +            if (classpath == null) {
  +                classpath = "";
               }
  +            pathMap.put(absPathPlusTimeAndLength, classpath);
           }
   
  -        if (classpath != null) {
  +        if (!"".equals(classpath)) {
               URL baseURL = fileUtils.getFileURL(pathComponent);
               StringTokenizer st = new StringTokenizer(classpath);
               while (st.hasMoreTokens()) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message