Introducing Espresso, a core web abstraction for Java – The future of Java web ecosystem?
Things have been evolving pretty rapidly in the Java ecosystem, however, there is a part of this ecosystem that is still lagging behind: web Java. Today, we have a look at a new Java tool that aspires to become the soul of modern Java web application! Meet Espresso, a core web abstraction for Java.
One of the things that never bore us is covering new and interesting Java tools! Today, we have a core web abstraction for Java, called Espresso that aspires to become the soul of modern Java web application!
As Java has been experiencing a more intense cycle of innovation with the new release cadence, it’s not unusual to see the development of the Java ecosystem as well as the language itself move a lot faster lately.
However, there’s still a part of the Java ecosystem that is arguably underdeveloped and that is web Java. As Ning Sun, the creator of Espresso argued, the Servlet API is outdated, heavy, and verbose and even though Spring Boot has improved Java development, a simpler abstraction like Python’s WSGI would still be the preferred choice.
SEE ALSO: Testcontainers is a lightweight Java library for anything that can run in a Docker container
And that was the main motivation behind the creation of Espresso!
Espresso is heavily inspired by Clojure’s Ring and Rust’s Iron and it is accompanied by three micro-libraries that support it, namely:
The key concepts of the espresso ecosystem include:
- App: Espresso function implementation.
- Server: A container to run espresso function.
- Adapter: A adapter layer for existed Java web server to run espresso function.
- Plugin or Middleware: An espresso function wrapper that provides additional features or data to core espresso function.
This is how a ‘hello world’ web application with espresso can look like:
import io.github.espresso4j.espresso.*; import io.github.espresso4j.jettino.Jettino; public class App { public static void main(String[] args) throws Exception { new Jettino().start((req) -> Response.of(200).body("It works.")); } }
Getting started
You can find a simple demo here that you can run with
gradle run.
You can also find the libraries published on Maven central.