Quoting Thom Park <[EMAIL PROTECTED]>:

> Hmm...
> 
> so what about this line of code in StandardClassLoader:
> 
>     public InputStream getResourceAsStream(String name) {
> 
>         if (debug >= 2)
>             log("getResourceAsStream(" + name + ")");
>         InputStream stream = null;
> 
>         // (0) Check for a cached copy of this resource
>         stream = findLoadedResource(name);
>         if (stream != null) {
>             if (debug >= 2)
>                 log("  --> Returning stream from cache");
>             return (stream);
>         }...

That code won't be used if you do ServletContext.getResourceAsStream.

Also, the code in StandardClassLoader.findLoadedResource actually is :

    protected InputStream findLoadedResource(String name) {

        return (null);  // FIXME - findLoadedResource()

    }

In the new WebappClassLoader, it actually does some caching :

    protected InputStream findLoadedResource(String name) {

        ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
        if (entry != null) {
            if (entry.binaryContent != null)
                return new ByteArrayInputStream(entry.binaryContent);
        }
        return (null);

    }

but it does create a stream each time.

For the ServletContext, the thing creating the stream is the directory context 
(FileDirContext), and it also does create a new stream each time.

Remy

Reply via email to