Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon

Javalin 2.0 RC3 released with major updates!

Save for later
  • 3 min read
  • 06 Aug 2018

article-image

Javalin is a web framework for Java and Kotlin which is simple, lightweight, interoperable, and flexible.

With the major changes introduced in the codebase, the team has now announced the release of Javalin 2.0 RC3. Some of the updates include removal of some abstraction layers, using Set instead of List, removal of CookieBuilder, Javalin lambda replacing Javalin Jetty, and more.

Updates in the Javalin 2.0 RC3

Package structure improvements


The following table lists the packages whose structure have been updated in this release:












Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime
Javalin 1.7 Javalin 2.0 RC3
io.javalin.embeddedserver.jetty.websocket io.javalin.websocket
io.javalin.embeddedserver.Location io.javalin.staticfiles.Location
io.javalin.translator.json.JavalinJsonPlugin io.javalin.json.JavalinJson
io.javalin.translator.json.JavalinJacksonPlugin io.javalin.json.JavalinJackson
io.javalin.translator.template.JavalinXyzPlugin io.javalin.rendering.JavalinXyz
io.javalin.security.Role.roles io.javalin.security.SecurityUtil.roles
io.javalin.ApiBuilder io.javalin.apibuilder.ApiBuilder
io.javalin.ApiBuilder.EndpointGrooup io.javalin.apibuilder.EndpointGrooup

Changes in the server defaults

  • Earlier, when we wanted to customize our embedded server, we used to write the following:

app.embeddedServer(new EmbeddedJettyFactory(() -> new Server())) // v1


Now with the removal of embedded server abstraction, we can directly write this:

app.server(() -> new Server()) // v2

  • Since the static method Javalin.start(port) has been removed, use Javalin.create().start(0) instead.
  • defaultCharset() method has been removed


The following are enabled by default:

  • Dynamic gzip, turn it off with disableDynamicGzip()
  • Request-caching is now limited to 4kb
  • Server now has a LowResourceMonitor attached
  • URLs are now case-insensitive by default, meaning Javalin will treat /path and /Path as the same URL. This can be disabled with app.enableCaseSensitiveUrls().

Javalin lambda replaces Jetty WebSockets


Since Jetty WebSockets have limited functionality, it is now replaced with the Javalin lambda WebSockets.

AccessManager


This is an interface used to set per-endpoint authentication and authorization. Use Set instead of List. It now runs for every single request, but the default-implementation does nothing.

Context


Context is the object, which provides you with everything needed to handle an http-request.

The following updates are introduced in Context:

  • ctx.uri() has been removed, it was a duplicate of ctx.path()
  • ctx.param() is replaced with ctx.pathParam()
  • ctx.xyzOrDefault("key") are changed to ctx.xyz("key", "default")
  • ctx.next() has been removed
  • ctx.request() is now ctx.req
  • ctx.response() is now ctx.res
  • All ctx.renderXyz methods are now just ctx.render(), since the correct engine is chosen based on extension
  • ctx.charset(charset) has been removed
  • You can use the Cookie class in place of CookieBuilder, as it is now removed
  • Now List<T> is returned instead of Array<T>
  • Things that used to return nullable collections now return empty collections instead
  • Kotlin users can now do ctx.body<MyClass>() to deserialize json


In this article we looked at some of the major updates in Javalin 2.0. To know more, head over to their GitHub repository.

Kotlin 1.3 M1 arrives with coroutines, and new experimental features like unsigned integer types

Top frameworks for building your Progressive Web Apps (PWA)

Kotlin/Native 0.8 recently released with safer concurrent programming