[ 
https://issues.apache.org/jira/browse/VELOCITY-439?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nathan Bubna resolved VELOCITY-439.
-----------------------------------

    Resolution: Fixed

Ok, all done, including custom, faster implementations for FileResourceLoader 
and StringResourceLoader.

> Improve Resource existence detection
> ------------------------------------
>
>                 Key: VELOCITY-439
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-439
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.4, 1.5
>            Reporter: Tassos Bassoukos
>            Priority: Trivial
>             Fix For: 1.6
>
>         Attachments: resourceloader.patch
>
>
> Depending on the ResourceLoader used, testing the existence of a resource is 
> somewhat expensive, as the resource has to be opened to test for its 
> existence.
> I'm proposing the following changes:
> 1.
> Add a new method to 
> org.apache.velocity.runtime.resource.loader.ResourceLoader:
>     public boolean resourceExists(String source) {
>         InputStream is = null;
>         try {
>             is = resourceLoader.getResourceStream(resourceName);
>             if (is != null) {
>                 return true;
>             }
>         } catch (ResourceNotFoundException e) {
>         } finally {
>             if (is != null) {
>                 try {
>                     is.close();
>                 } catch (Exception e) {
>                 }
>             }
>         }
>         return false;
>     }
> This method keeps compatibility with all current ResourceLoaders, and can be 
> overriden by subclasses.
> 2. org.apache.velocity.runtime.resource.ResourceManagerImpl
> Modify the String getLoaderNameForResource(String resourceName) method to use
> the new ResourceLoader.resourceExists(String) method.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to