I've searched the archives and have seen this discussed before, although I've
failed to find a definitive answer, and I'm hoping to get one.  I also have
not seen evidence that this is addressed in Velocity 1.5.  
 
My templates reload on the fly as expected if changed, but changes to the
macro library macros used by these same templates do not take effect until a
Tomcat restart.  According to the documentation setting
velocimacro.library.autoreload to true should mean that they take effect
immediately.  This is a real annoyance when developing
 
Here are my relevant config properties for the development environment.
Velocity 1.4, Tomcat 4.1.  Note I'm including the fact that I'm using a
custom ClasspathResourceLoader in case that is relevant, although I don't see
why it would be.  I need to do this because it seems velocity's built in one
must be loaded from a different class loader then my .jar that contains the
templates as it won't find them.  Code below.
 
      p.setProperty(Velocity.RESOURCE_LOADER, "class");
      p.setProperty("class.resource.loader.class",
ABEVelocityTemplateLoader.class.getName());
      p.setProperty("class.resource.loader.cache", "false");
      p.setProperty("velocimacro.library.autoreload", "true");
      p.setProperty("runtime.log.invalid.references", "true");
 
 
thanks,
Peter
 
 
-------------
 
public class ABEVelocityTemplateLoader extends ClasspathResourceLoader {
  public ABEVelocityTemplateLoader() {
  }
 
  public synchronized InputStream getResourceStream(String name)
        throws ResourceNotFoundException
    {
        InputStream result = null;
        if(name == null || name.length() == 0)
            throw new ResourceNotFoundException("No template name provided");
        try
        {
            ClassLoader classLoader = getClass().getClassLoader();
            result = classLoader.getResourceAsStream(name);
 
            if (result == null)
            {
              result = ClassLoader.getSystemResourceAsStream(name);
            }
        }
        catch(Exception fnfe)
        {
            throw new ResourceNotFoundException(fnfe.getMessage());
        }
        return result;
    }
 
    public static String getDefaultResourceLocation(Class classUsingResource)
    {
      if (classUsingResource == null)
      {
        throw new IllegalArgumentException("classUsingResource cannot be
null");
      }
 
      return classUsingResource.getPackage().getName().replace('.', '/') +
'/';
 
    }

 
--
Peter Locke
Senior Engineer / Dev Lead
www.abebooks.com <http://www.abebooks.com/> 
 
t: 250.412.3240
f: 250.475-6014
e: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
--
P.S. I'm currently reading Rainbow Six
<http://www.abebooks.com/servlet/SearchResults?bx=off&sts=t&ds=30&bi=0&an=Tom
+Clancy&tn=Rainbow+Six>  by Tom Clancy
 

Reply via email to