velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Glass-Husain" <wgl...@forio.com>
Subject Re: Private fields and methods in ResourceLoader
Date Thu, 20 Apr 2006 19:48:18 GMT
That sounds interesting.  Did you remember to call VelocityEngine.init() or
Velocity.init() before parsing a template?

WILL

On 4/20/06, Tim Pizey <timp@paneris.org> wrote:
>
> Hi,
>
> I have been trying to write a ResourceLoader, initially a
> FileResourceLoader, but found that I could not extend
> FileResourceLoader as the members and findTemplate method are private.
>
> This has forced me to a more general solution, where I have a
> ResouceLoader
> which is a decorator to any other and takes the InputStream returned,
> converts it to a String, does Perl5 substitutions on it and then
> converts the String back to an InputStream.
>
> My code is at work but from memory I do something like
>
> public abstract class WebMacroResourceLoader extends ResourceLoader {
>
> private ResourceLoader loader ;
>
> public void init( ExtendedProperties configuration) {
>   loader.init(configuration);
> }
>
> public InputStream getResourceStream(String templateName) {
>    if (templateName.endsWith(".wm") {
>       // mugle about with Perl5
>       // return new input stream
>    } else
>      return loader.getResourceStream(templateName);
> }
>
> }
>
> public class WebMacroClasspathResourceLoader extends
> WebMacroResourceLoader {
>   public WebMacroClasspathResourceLoader() {
>     this.loader = new ClasspathResourceLoader();
>   }
> }
> public class WebMacroFileResourceLoader extends WebMacroResourceLoader {
>   public WebMacroClasspathResourceLoader() {
>     this.loader = new FileResourceLoader();
>   }
> }
>
> Mine feels like a not-unusual requirement, is my approach sensible?
> PS Any idea why I am getting NPE thrown from the init method?
>
> yours
> Tim Pizey
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>


--
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message