Package atessera.templ
Class EngineFactory
java.lang.Object
atessera.templ.EngineFactory
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:
PUBLICATION—"publication.vm"PRESENTATION—"presentation.vm"METAPOST—"metapost.vm"GNUPLOT—"gnuplot.vm"
- See Also:
-
BaseVelocityEngine
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEngineFactory(Map<String, List<String>> templates) Constructs a new engine factory with the given template sources. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.velocity.app.VelocityEngineCreates (or returns the cached) Velocity engine configured with all templates registered in this factory.
-
Field Details
-
PUBLICATION
Template name for publication LaTeX source.- See Also:
-
PRESENTATION
Template name for publication LaTeX source.- See Also:
-
METAPOST
Template name for publication LaTeX source.- See Also:
-
GNUPLOT
Template name for publication LaTeX source.- See Also:
-
-
Constructor Details
-
EngineFactory
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 benull
-
-
Method Details
-
newEngine
public org.apache.velocity.app.VelocityEngine newEngine() throws org.apache.velocity.exception.ResourceNotFoundExceptionCreates (or returns the cached) Velocity engine configured with all templates registered in this factory.The engine uses a static
StringResourceRepositorynamed"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
VelocityEngineready for template retrieval - Throws:
org.apache.velocity.exception.ResourceNotFoundException- if a template cannot be loaded
-