API / Apache Velocity Interview questions
What is the RuntimeInstance in Velocity's architecture?
RuntimeInstance (in org.apache.velocity.runtime) is the internal core that both VelocityEngine and the older static Velocity singleton delegate to. It's the piece that actually owns configuration, the directive registry, the parser pool, the resource cache, and the Velocimacro manager.
When you call engine.init(), you're really initializing a RuntimeInstance under the hood: it reads the merged properties (defaults plus anything you set), instantiates and registers the configured ResourceLoader(s), loads any Velocimacro library files, and prepares a pool of parser objects so concurrent renders don't contend over a single parser instance.
Most application code never touches RuntimeInstance directly, it's an implementation detail behind VelocityEngine, but understanding it explains why constructing a new VelocityEngine and calling init() is a relatively heavyweight operation meant to happen once, not per request.
More Related questions...