Rapidoid - Extremely Fast, Simple and Powerful Java Web Framework!

Open source (Apache license). View benchmark... Community: [email protected]

Dependency injection
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Bar.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
 
import javax.inject.Inject;
 
@Controller("/bar")
public class Bar {
 
    @Inject
    public Foo foo;
 
    @GET("/hi")
    public String hello() {
        return foo.msg();
    }
 
    public String msg() {
        return "Hello from Bar!";
    }
 
}
Foo.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
 
import javax.inject.Inject;
 
@Controller("/foo")
public class Foo {
 
    @Inject
    public Bar bar;
 
    private int count;
 
    @GET("/hi")
    public String hello() {
        return ++count + ": " + bar.msg();
    }
 
    public String msg() {
        return "Hello from Foo!";
    }
 
}
GET /foo/hi
"1: Hello from Bar!"
GET /bar/hi
"Hello from Foo!"
GET /foo/hi
"2: Hello from Bar!"

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /bar/hi main json
GET /foo/hi main json