Class EngineFactory

java.lang.Object
atessera.templ.EngineFactory

public final class EngineFactory extends Object
Factory for creating and caching Apache Velocity engines configured with in-memory template storage.

This class accepts a map of template names to template source lines at construction time. When newEngine() is called, it configures a VelocityEngine with a StringResourceLoader pointing to a static, named repository ("GlobalRepo"), populates it with all the templates, and caches the engine for subsequent calls.

Well-known template names are exposed as public constants:

See Also:
  • Base
  • VelocityEngine
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Template name for publication LaTeX source.
    static final String
    Template name for publication LaTeX source.
    static final String
    Template name for publication LaTeX source.
    static final String
    Template name for publication LaTeX source.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new engine factory with the given template sources.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.velocity.app.VelocityEngine
    Creates (or returns the cached) Velocity engine configured with all templates registered in this factory.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • EngineFactory

      public EngineFactory(Map<String,List<String>> templates)
      Constructs a new engine factory with the given template sources.
      Parameters:
      templates - a map where keys are template resource names and values are the template source lines; must not be null
  • Method Details

    • newEngine

      public org.apache.velocity.app.VelocityEngine newEngine() throws org.apache.velocity.exception.ResourceNotFoundException
      Creates (or returns the cached) Velocity engine configured with all templates registered in this factory.

      The engine uses a static StringResourceRepository named "GlobalRepo" so that templates survive engine re-creation. The returned engine is cached and the same instance is returned on subsequent calls.

      Returns:
      a configured VelocityEngine ready for template retrieval
      Throws:
      org.apache.velocity.exception.ResourceNotFoundException - if a template cannot be loaded