Simplified and corrected the behavior of the JarFileClassLoader (now the
SiteClassLoader). git-svn-id: https://samskivert.googlecode.com/svn/trunk@1459 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -165,7 +165,7 @@ public class SiteResourceLoader
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
loader = new JarFileClassLoader(bundle.jarFile);
|
loader = new SiteClassLoader(bundle);
|
||||||
_loaders.put(siteId, loader);
|
_loaders.put(siteId, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,6 +285,14 @@ public class SiteResourceLoader
|
|||||||
return _lastModified;
|
return _lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of this instance.
|
||||||
|
*/
|
||||||
|
public String toString ()
|
||||||
|
{
|
||||||
|
return "[bundle=" + file + "]";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reopens our site-specific jar file if it has been modified
|
* Reopens our site-specific jar file if it has been modified
|
||||||
* since it was last opened.
|
* since it was last opened.
|
||||||
@@ -322,38 +330,31 @@ public class SiteResourceLoader
|
|||||||
protected long _lastModified;
|
protected long _lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class JarFileClassLoader extends ClassLoader
|
protected static class SiteClassLoader extends ClassLoader
|
||||||
{
|
{
|
||||||
public JarFileClassLoader (JarFile jarFile)
|
public SiteClassLoader (SiteResourceBundle bundle)
|
||||||
{
|
{
|
||||||
_jarFile = jarFile;
|
_bundle = bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getResourceAsStream (String path)
|
public InputStream getResourceAsStream (String path)
|
||||||
{
|
{
|
||||||
// Log.info("Seeking resource [jarFile=" + _jarFile +
|
|
||||||
// ", path=" + path + "].");
|
|
||||||
try {
|
try {
|
||||||
JarEntry entry = _jarFile.getJarEntry(path);
|
return _bundle.getResourceAsStream(path);
|
||||||
return (entry == null) ? null :
|
|
||||||
_jarFile.getInputStream(entry);
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.warning("Error loading resource from jarfile " +
|
Log.warning("Error loading resource from jarfile " +
|
||||||
"[jar=" + _jarFile + ", error=" + ioe + "].");
|
"[bundle=" + _bundle + ", path=" + path +
|
||||||
|
", error=" + ioe + "].");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a string representation of this instance.
|
|
||||||
*/
|
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return "[jarFile=" + (_jarFile == null ? "<none>" :
|
return _bundle.toString();
|
||||||
_jarFile.getName()) + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JarFile _jarFile;
|
protected SiteResourceBundle _bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The site identifier we use to identify requests. */
|
/** The site identifier we use to identify requests. */
|
||||||
|
|||||||
Reference in New Issue
Block a user