fr.gedeon.telnetservice
Class OutputFormatVelocityImpl

java.lang.Object
  extended by fr.gedeon.telnetservice.OutputFormatDefaultImpl
      extended by fr.gedeon.telnetservice.OutputFormatVT100Impl
          extended by fr.gedeon.telnetservice.OutputFormatVelocityImpl
All Implemented Interfaces:
OutputFormat, OutputFormatSpi, OutputFormatVT100Constants

public abstract class OutputFormatVelocityImpl
extends OutputFormatVT100Impl

This implementation of the OutputFormat interface formats a given subject using a selected Apache Velocity Engine template. For more information on the Apache Velocity Engine and the Apache Software Foundation, please refer to the 'See Also' section below.

The template selection process is based on the class structure of the subject to be represented. This class is abstract but does not require any method implementation, the extension mechanism is used to provide bundle specific templates as follows:
If a class custompackage.MyOutputFormatVelocityImpl extends OutputFormatVelocityImpl, the templates that are provided by this class are located under: custompackage/vms/ in the custom bundle's domain. Subject classes or interfaces that require a template must have a template in that location, the template for a class or interface would be named: [package].[classname].vm. For example, the template for java.util.List.class in the above situation would be named in: custompackage/vms/java.util.List.vm

The search order is as follows:

  1. The subject class is checked
  2. The subject interfaces are checked in the order they are provided by the class definition, this order is described here
  3. The process is repeated with the subject's superclass

When a template is found, it is cached against all the classes and interfaces that were visited to arrive to it, and when a lookup fails for a class that class is cached as a failed lookup class. The caches are checked before a lengthy search operation to improve performance.
If a different template source is to be used, it is strongly recommended to override findClassTemplate(Package, Class), this would allow to load the templates from a different location while still having the caching mechanism. The same Package/Class pair will not be requested twice.

The template is merged with the following context entries: