Micro Java Web Framework
It's an open source (Apache License) micro web framework in Java, with minimal dependencies and a quick learning curve.
The goal of this project is to create a micro web framework in Java that should be easy to use and hack.
The size of pippo-core is only 140 KB and the size of pippo-controller (optional) is only 45 KB.
First we must create an Application and add some routes:
…where Contact is a simple POJO:
public class Contact {
private int id;
private String name;
private String phone;
private String address;
// getters and setters
}The second step is to choose your favorite server,
template engine
and content type engine.
For example, I will choose Jetty as server, Freemarker as template engine, Jackson as JSON engine and JAXB as XML engine.
My Maven pom.xml looks like:
ro.pippo
pippo-core
${pippo.version}
ro.pippo
pippo-jetty
${pippo.version}
ro.pippo
pippo-freemarker
${pippo.version}
ro.pippo
pippo-jackson
${pippo.version}
The last step it's to start Pippo with your application as parameter:
public class BasicDemo {
public static void main(String[] args) {
Pippo pippo = new Pippo(new BasicApplication());
pippo.start();
}
}Pippo launches the embedded web server (found in your classpath) and makes the application available on port 8338 (default value).
Open your internet browser and check the routes declared in Application:
http://localhost:8338http://localhost:8338/filehttp://localhost:8338/jsonhttp://localhost:8338/xmlhttp://localhost:8338/negotiatehttp://localhost:8338/templateDefine controller(s):
……Add controller(s) in your application:
public class BasicApplication extends ControllerApplication {
@Override
protected void onInit() {
addControllers(ContactsController.class); // one instance for EACH request
// OR
addControllers(new ContactsController()); // one instance for ALL requests
addControllers(FilesController.class);
}
}Don't forget that the Controller concept is included in pippo-controller module so you must add this module as dependency in your project.
Documentation is available on pippo-java.github.io
Demo applications are available on pippo-demo
For a real life application built with Pippo please look at Web Accounting - Pippo Demo
No open issues yet, or sync has not completed.