Apache Velocity

Apache Velocity is replaced in text files by date content software that placeholder. Thereby, following the principle of the form letter as many text files, such as HTML pages or e- mails with different content but the same structure are generated from a single template.

Apache Velocity is programmed in the Java programming language. The source code is under the Apache Software License, making it free.

Operation

Processed by Apache Velocity text files are called template, english for " template" or "template". Therefore, this type of software is also known as template engine ( " template engine").

Apache Velocity interpreted the placeholders in the templates as references to Java objects, ie executable software that was written in the Java programming language. Velocity generated from the template executable source code, on the one hand, the static text components of the template outputs, and on the other hand, calls the referenced Java objects in the right places. The Java objects must return strings that are inserted into the text.

Apache Velocity can be used as a standalone application or as a class library into other applications (eg, Web applications ) are integrated and perform for these ancillary services.

Applications

Apache Velocity is used in different application areas of software engineering and is part of many software products:

  • Code Generators: Velocity can also be used to generate code in any formal languages ​​such as Java, SQL, or PostScript.
  • E -mail generation: Many applications generate automatic e -mails, for example, to log on to websites or password reminders using Velocity. The text produced can be stored directly in a text file without java code must be generated.
  • Text reports: Velocity is used to pre textual reports to fill. This is far easier than with the specialized graphical reports reporting engines such as JasperReports.
  • Web applications: Web developers make HTML pages with placeholders for dynamically generated information. To this end, such a HTML page is processed, for example by a velocity component called VelocityViewServlet. This approach is an alternative to Java Server Pages ( JSP) or PHP intended.
  • XML Conversion: Velocity also provides an Ant task called Anakia ready that reads an XML file and makes it workable for a Velocity template. A typical application of this is to convert present in XDoc format documentation to HTML.

Velocity is a template engine component of many applications such as integrated Java development environment, IntelliJ IDEA or the UML tool Poseidon for UML and frameworks such as Spring, as well as from sites such as the open source development community Tigris.org.

Velocity Template Language

Apache Velocity defines its own description language for templates, Velocity Template Language ( VTL). This lead double crosses ( "#") to fill the placeholder, double hash marks ("# #") begin comments and dollar sign ( "$") serve as a marker of references.

The following example template defines next comment a reference named "foo ", which is assigned a simple string with the content " Velocity". Thereafter, the reference "foo " is replaced by the string in the text.

# # Velocity Hello World              # set ($ foo = "Velocity" )         # # Followed by         Hello $ foo world!      This Apache Velocity generates this HTML structure:

The first beta version of Velocity was published on 26 March 2001. On 26 October 2006 Velocity was appointed Apache Top Level Project.

72091
de