[{TableOfContents}]

!Configuration

ztemplates is a [Filter|ZServletFilter].

Configuration is easy: look at the [empty application tutorial|TutorialEmpty] for how to do it.

[Maven|ZtemplatesAndMaven]

[Spring|Spring]

[Build]

[Context Configuration]

!Classpath Filter

(since 1.0.0)

ztemplate scans the classpath at startup for annotated classes. If your application contains many jars this is time-consuming. You may wish to speed things up by providing a filter that only includes jars and classes you need. 

Do it as follows to ensure that the default ztemplates classes are included.

The default implementation only scans WEB-INF/lib and WEB-INF/classes.

__ZClassPathFilter has changed to ZIClassPathFilter, note the 'I'__

If no filter can be found ztemplates prints a warning to the console, so check the console to
see if the filter is used or not.

{{{
    <context-param>
      <param-name>ZIClassPathFilter</param-name>
      <param-value>com.mycompany.MyClassPathFilter</param-value>
      <description>
      	Restrict classpath scan to jars/classes known to contain ztemplates-relevant classes.
      	Best MyClassPathFilter extends ZDefaultClassPathFilter
      </description>
    </context-param>
}}}



{{{

public class MyClassPathFilter extends ZDefaultClassPathFilter
{
  @Override
  public boolean acceptClass(String name) throws Exception
  {    
    //include the default ztemplates classes
    if(super.acceptClass(name))
    {
      return true;
    }
    
    //include your own classes here
    return name.startsWith("com.mycompany");
  }
}
}}}

The default implementation only scans WEB-INF/lib and WEB-INF/classes.
To add more locations override acceptClasspathPart.

{{{

public class MyClassPathFilter extends ZDefaultClassPathFilter
{
  @Override
  public boolean acceptClasspathPart(String name) throws Exception
  {    
    //include the defaults
    if(super.acceptClasspathPart(name))
    {
      return true;
    }
    
    //include your own classpath locations here
    return ...;
  }
}
}}}