Jetty: Open Source Servlet Container & HTTP Server

Jetty logo

I’ve recently become interested in Microservices and Jetty is a good choice of servlet container for running and serving microservices.

From the Jetty homepage:

Jetty provides a Web server and javax.servlet container, plus support for SPDY, WebSocket, OSGi, JMX, JNDI, JAAS and
many other integrations. These components are open source and available for commercial use and distribution.

Features

  • Full-featured and standards-based
  • Open source and commercially usable
  • Flexible and extensible
  • Small footprint
  • Embeddable
  • Asynchronous
  • Enterprise scalable
  • Dual licensed under Apache and Eclipse

XMLBeam: Java library to project parts of a XML DOM tree into Java objects via XPath instead of using data binding

xmlbeam image

I haven’t tried this, but it looks interesting. It seems to be designed to
help break the dependency between the XML structure and the structure of your
code. With most data binding libraries, you either make your api mirror the
structure of the XML, or you transform the data to match your API. This lets
you map data from the XML directly onto Java objects using XPath and
annotations.

Take a look at the XMLBeam introduction page.

Sample from the website:

Access XML data directly via XPath-annotated Java interfaces:

<xml>
   <example>
      <content type="foo" >bar</content>
   </example>
</xml>

public interface Example {

    @XBRead("/xml/example/content")
    String getContent();

    @XBRead("/xml/example/content/@type")
    String getType();

}

Thymeleaf: Extensible Java-based XML / XHTML / HTML5 template engine

Thymeleaf Logo

A Java templating language. I like how the syntax modifies attributes on existing tags like this:

<input type="text" th:field="*{name}" />

From the Thymeleaf website:

Thymeleaf is a Java library. It is an XML / XHTML / HTML5 template engine
(extensible to other formats) that can work both in web and non-web
environments. It is better suited for serving XHTML/HTML5 at the view layer of
web applications, but it can process any XML file even in offline environments.

It provides an optional module for integration with Spring MVC, so that you
can use it as a complete substitute of JSP in your applications made with this
technology, even with HTML5.

The main goal of Thymeleaf is to provide an elegant and well-formed way of
creating templates. Its Standard and SpringStandard dialects allow you to
create powerful natural templates, that can be correctly displayed by browsers
and therefore work also as static prototypes. You can also extend Thymeleaf by
developing your own dialects.

Sample markup

<table>
  <thead>
    <tr>
      <th th:text="#{msgs.headers.name}">Name</th>
      <th th:text="#{msgs.headers.price}">Price</th>
    </tr>
  </thead>
  <tbody>
    <tr th:each="prod : ${allProducts}">
      <td th:text="${prod.name}">Oranges</td>
      <td th:text="${#numbers.formatDecimal(prod.price,1,2)}">0.99</td>
    </tr>
  </tbody>
</table>

Spek: BDD Specification Framework For The JVM

http://jetbrains.github.io/spek/ (via)

Sample code from the Spek website written in the Spek DSL:

class TaxCalculatorSpecs: Spek() {{

    given("Tax rate calculator with default locale settings") {
        val taxRateCalculator = TaxRateCalculator()
        on("calculating the rate for an income of 200 and an average change of 10 per semester") {
            val value = taxRateCalculator.calculateRate(200, 10)
            it("should result in a value of 300") {
                assertEquals(300, value)
            }
        }
    }
}}

Play Framework: Open source, Java/Scala, web development framework, based on a stateless architecture

Play Framework Logo

Play is a web application framework designed to make web development simpler. It is inspired by convention-based frameworks such as Ruby on Rails and Djnago. Play seems to be trying to take the best from the Java web development ecosystem and strip away some of the more cumbersome parts.

From the Play Framework Wikipedia page:

Major differences From other Java frameworks:

  • Stateless: Play 2 is fully RESTful – there is no Java EE session per
    connection.
  • Integrated unit testing: JUnit and Selenium support is included in the core.
  • API comes with most required elements built-in.
  • Static methods: all controller entry points are declared as static (or
    equivalently, in Scala, methods on Scala objects). After requests were made
    for this to be customisable, Play 2.1 now supports other styles of
    controllers, so controllers need not be static/Scala objects; however, this
    is still the default.
  • Asynchronous I/O: due to using JBoss Netty as its web server, Play can
    service long requests asynchronously rather than tying up HTTP threads doing
    business logic like Java EE frameworks that don’t use the asynchronous
    support offered by Servlet 3.0.
  • Modular architecture: like Rails and Django, Play comes with the concept of
    modules.
  • Native Scala support: Play 2 uses Scala internally, but also exposes both a
    Scala API, and a Java API that is deliberately slightly different to fit in
    with Java conventions, and Play is completely interoperable with Java.

FreeMarker: Java Templating Engine

Freemarker image

From the website:

FreeMarker is a “template engine”; a generic tool to generate text output (anything from HTML to autogenerated source code) based on templates.
It’s a Java package, a class library for Java programmers. It’s not an application for end-users in itself, but something that programmers can
embed into their products.

FreeMarker is designed to be practical for the generation of HTML Web pages, particularly by servlet-based applications following the MVC (Model
View Controller) pattern. The idea behind using the MVC pattern for dynamic Web pages is that you separate the designers (HTML authors) from the
programmers. Everybody works on what they are good at. Designers can change the appearance of a page without programmers having to change or
recompile code, because the application logic (Java programs) and page design (FreeMarker templates) are separated. Templates do not become
polluted with complex program fragments. This separation is useful even for projects where the programmer and the HTML page author is the same
person, since it helps to keep the application clear and easily maintainable.

Although FreeMarker has some programming capabilities, it is not a full-blown programming language like PHP. Instead, Java programs prepare the
data to be displayed (like issue SQL queries), and FreeMarker just generates textual pages that display the prepared data using templates.

We use Apache Velocity extensively at work in our web content, but it hasn’t seen much in the way of updates for quite some time.