What's new in Rapidoid v5.2?

What's new in Rapidoid v5.2:

  • OAuth bootstrap: App.bootstrap(args).oauth() with pre-defined configuration structure
  • customizable session management: My.sessionManager(...) - in-memory by default
  • customizable JSON parser for the HTTP request body: My.jsonRequestBodyParser(...) - using Jackson by default
  • customizable JPA management: My.entityManagerFactoryProvider(...) and My.entityManagerProvider(...)
  • customizable security strategy when serving serving static files: My.staticFilesSecurity(...)
  • customizable templates path: My.templatesPath(...)
  • customizable templates loader (e.g. load them from DB): My.templateLoader(...)
  • customizable error handlers by type: On.error(...).handler(...)
  • customizable wrappers of the HTTP handlers (request/response interceptors): My.wrappers(...)
  • redesigned token API (previously known as the cookie-pack session)
  • smart serialization of the session and token - only when changed
  • basic reverse proxy (easily configurable from command-line or Docker)
  • round-robin load balancer (enabled by default in the reverse proxy)
  • customizable context path for web applications
  • great performance improvements in the built-in template engine
  • few GUI enhancements
  • several bug fixes
  • many small improvements

Note: Some of the new features aren't documented yet...

Breaking changes:

  • Renamed cookiepack to token in the HTTP Req and Resp API
  • the application.yml configuration files are not loaded by default, only config.yml
  • renamed profile-*.yml configuration files to config-*.yml
  • renamed application segment to zone in the HTTP API
  • redesigned ViewRenderer and renamed to ViewResolver
  • added Req parameter in the LoginProvider API
  • added Req parameter in the RolesProvider API
  • renamed Templates.fromFile to Templates.load, Templates.fromString to Templates.compile
  • renamed PageRenderer to PageDecorator
  • using My.jackson() instead of JSON.MAPPER
import org.rapidoid.setup.My;
import org.rapidoid.setup.On;
public class Main {
    public static void main(String[] args) {
        // Dummy template loader - constructs templates on-the-fly
        My.templateLoader(filename -> {
            String tmpl = "In " + filename + ": x = <b>${x}</b>";
            return tmpl.getBytes();
        // The URL parameters will be the MVC model
        On.get("/showx").mvc((req) -> req.params());
GET /showx?x=123&y=45
In showx.html: x = 123

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /showx main html showx
import org.rapidoid.setup.My;
import javax.persistence.EntityManagerFactory;
public class Main {
    public static void main(String[] args) {
        // The EntityManagerFactory's should be properly initialized
        EntityManagerFactory emf1 = null; // FIXME
        EntityManagerFactory emf2 = null; // FIXME
        My.entityManagerFactoryProvider(req -> {
            return req.path().startsWith("/db1/") ? emf1 : emf2;
import org.rapidoid.jpa.JPA;
import org.rapidoid.setup.My;
import javax.persistence.EntityManager;
public class Main {
    public static void main(String[] args) {
        // Use the built-in entity manager, and decorate it
        My.entityManagerProvider(req -> {
            EntityManager em = JPA.em();
            em = new SomeEntityManagerDecorator(em);
            return em;