webwork/src/main/webwork/util/classloader DirectoryClassLoader.java,1.2,1.3
[email protected] Fri, 2 Sep 2005 12:04:31 +0000 (UTC)
| Newsgroups | gmane.comp.java.open-symphony.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/opensymphony/webwork/src/main/webwork/util/classloader
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7633/src/main/webwork/util/classloader
Modified Files:
DirectoryClassLoader.java
Log Message:
Change key to be the actual File to save a ctor, and get rid of sync
Index: DirectoryClassLoader.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/util/classloader/DirectoryClassLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- DirectoryClassLoader.java 2 Sep 2005 09:44:02 -0000 1.2
+++ DirectoryClassLoader.java 2 Sep 2005 10:08:47 -0000 1.3
@@ -17,7 +17,7 @@
public class DirectoryClassLoader extends WebworkClassLoader
{
private File directory;
- private Map timestamps = new HashMap();
+ private HashMap timestamps = new HashMap();
public DirectoryClassLoader(File file, ClassLoader parent)
{
@@ -27,18 +27,15 @@
public boolean isStale()
{
- synchronized(timestamps)
+ Iterator iter = ((Map)timestamps.clone()).entrySet().iterator();
+ while(iter.hasNext())
{
- Iterator iter = timestamps.entrySet().iterator();
- while(iter.hasNext())
+ Map.Entry entry = (Map.Entry)iter.next();
+ File toCheck = (File)entry.getKey();
+ long time = ((Long)entry.getValue()).longValue();
+ if(toCheck.lastModified() > time)
{
- Map.Entry entry = (Map.Entry)iter.next();
- File toCheck = new File(directory, (String)entry.getKey());
- long time = ((Long)entry.getValue()).longValue();
- if(toCheck.lastModified() > time)
- {
- return true;
- }
+ return true;
}
}
return false;
@@ -53,17 +50,13 @@
{
try
{
-
- File f = new File(directory, path);
- if(!f.exists()) return null;
- int size = (int)f.length();
- InputStream in = new FileInputStream(f);
+ File file = new File(directory, path);
+ if(!file.exists()) return null;
+ int size = (int)file.length();
+ InputStream in = new FileInputStream(file);
//we're ok not storing timestamps for jars, since the whole jar
//will be modified in that case.
- synchronized(timestamps)
- {
- timestamps.put(path, new Long(f.lastModified()));
- }
+ timestamps.put(file, new Long(file.lastModified()));
return ClassLoaderUtils.readStream(in, size);
}
catch(IOException e)
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf