Apache Velocity

from Wikipedia, the free encyclopedia
Apache Velocity
Basic data

developer Apache Software Foundation
Publishing year November 21, 2006
Current  version 2.0
(August 6, 2017)
operating system platform independent
programming language Java (programming language)
category Template engine
License Apache software license
velocity.apache.org

Apache Velocity is software that replaces placeholders in text files with current content. Using the serial letter principle, any number of text files - for example websites or e-mails  - with different content but the same structure can be generated from a single template.

Apache Velocity was programmed in the Java programming language. The source code is under the Apache Software License and is therefore free .

functionality

The text files processed by Apache Velocity are called templates , English for "template" or "template". This is why this type of software is also known as the template engine .

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

Apache Velocity can be used as a stand-alone application program or integrated into other application programs (e.g. web applications ) as a class library and perform auxiliary services for them.

Areas of application

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

  • Code generators : Velocity can also be used to generate source text in any formal language such as Java , SQL or PostScript .
  • E-mail generation: Many applications generate automatic e-mails, for example for logging into websites or for password reminders with the help of Velocity. The generated text can be saved directly in a text file without having to generate Java code.
  • Text reports: Velocity is used to fill predefined textual reports. This is far easier than with the reporting engines that specialize in graphical reports such as JasperReports .
  • Web applications : Web developers design HTML pages with placeholders for dynamically generated information. For this purpose, such an HTML page is processed, for example, by a Velocity component called VelocityViewServlet . This approach is intended as an alternative to JavaServer Pages (JSP) or PHP .
  • XML Conversion: Velocity also provides an Ant task called Anakia that reads an XML file and makes it processable for a Velocity template. A typical application of this is to convert documentation in XDoc format to HTML.

As a template engine, Velocity is part of many application programs such as the integrated Java development environment IntelliJ IDEA or the UML tool Poseidon for UML and frameworks such as Spring , as well as websites such as the open source development community Tigris.org .

Velocity Template Language

Apache Velocity defines its own description language for templates, the Velocity Template Language (VTL). Conduct while double crosses ( "#") to be filled placeholder, double double crosses ( "##") begin comments and dollar sign ( "$") serve as a marker of references.

In addition to comments, the following sample template defines a reference named “foo” to which a simple character string with the content “Velocity” is assigned . Then the reference “foo” in the text is replaced by the character string.

## Velocity Hello World
<html>
    <body>
       #set( $foo = "Velocity" )
       ## followed by
       Hallo $foo Welt!
    </body>
</html>

From this, Apache Velocity generates this HTML structure:

<html>
    <body>
     Hallo Velocity Welt!
    </body>
</html>

history

The first beta version of Velocity was released on March 26, 2001. On October 26, 2006, Velocity was named the Apache Top Level Project .

literature

Web links

Individual evidence

  1. projects.apache.org . (accessed on April 8, 2020).
  2. Apache Velocity Site
  3. Velocity - VelocityView. (No longer available online.) In: The Apache Velocity Project. Archived from the original on January 26, 2009 ; accessed on January 26, 2008 (English).
  4. Powered by Velocity. In: VelocityWiki. December 4, 2008, accessed January 26, 2008 .
  5. March 20, 2001 - Velocity 1.0 Beta 1 release. In: The Jakarta Site - New and Status - 2001. March 20, 2001, accessed January 28, 2009 .
  6. ^ Velocity Approved as a Top Level Project. In: Apache Velocity Site - Project news. October 26, 2006, accessed January 28, 2009 .