DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. Databases
  4. Introduction to the Jooby Framework

Introduction to the Jooby Framework

Want to learn more about the Jooby framework? Check out this post to learn more about Jooby features and whether to incorporate it in your next Java project.

Mostafa Hosseinzadeh user avatar by
Mostafa Hosseinzadeh
·
Oct. 19, 18 · Presentation
Like (27)
Save
Tweet
Share
20.95K Views

Join the DZone community and get the full member experience.

Join For Free

Jooby

Why Java? Why Jooby?

Do you think Java is slow? I want to change your mind. Let‘s take a look!

I check the Techempower benchmarks once every three months. But this month, I was surprised by what I found. You know that the Java platform is very fast and often after integrating C and C++, the Java platform is faster than others. But this time, I saw a micro framework as well as faster of such as raws servlet.

Java has a lot of frameworks, microframeworks, and platforms, as well as libraries. In the last year, we saw a lot of scalable, fast frameworks and microframeworks for Java. But, do you know anything about Jooby?

In this article, we talk about Jooby and the reason why you should test and use it in your project.

What Is Jooby?

Jooby is a scalable, fast, and modular micro web framework for Java and Kotlin.

Jooby follows the basic concept: “do more, more easily” — so, for example, annotations and dependency injection are reduced to a minimum and completely optional in a few areas. Thanks to the use of the JVM Bootstrap in the standard deployment mode, developers can furthermore be shown a way out from the “classpath abyss.”

Built by developer Edgar Espina, Jooby offers modular, stateless application development leveraging NIO (non-blocking IO) servers, including Netty, Jetty, or Undertow.

In this article, we’ll learn what options Jooby offers when it comes to building large-scale web applications and its features.

What Is a Microframework?

A microframework is a term used to refer to minimalistic web application frameworks. It is contrasted with full-stack frameworks. It lacks most of the functionality that is common in a full-fledged web application framework, such as:

  • Accounts, authentication, authorization, and roles
  • Database abstraction via an object-relational mapping
  • Input validation and input sanitation.
  • Web template engine

Typically, a microframework facilitates by receiving an HTTP request, routing the HTTP request to the appropriate controller, dispatching the controller, and returning an HTTP response. Microframeworks are often specifically designed for building the APIs for another service or application.

Microframeworks and the Jooby Framework

  • You have a template engine
  • Multiple ORM
  • Security (accounts, authentication, and more)
  • Input validation

So, is Jooby a microframework? I don’t think so. Actually, in Jooby, all objects are a module, and you can use them in your project.

Image title

Jooby: Features

    • Easy to learn
    • Simple and effective programming model for building small and large-scale web applications
    • Scalable, stateless application development
    • Scripting programming model, like express.js, Sinatra
    • Built with developer productivity in mind
    • Plain Java DSL for routes (no XML or similar languages)
    • Reflection, annotations, and dependency injections are kept to a minimum, and in some cases, they are completely optional
    • No classpath issues — the default deployment model uses a normal JVM bootstrap
    • MVC routes and Script routes
    • Multi-protocol: HTTP, HTTPS, HTTP 2.0, Web-Socket
    • Multiple API tools for creating an API documentation
    • Database Access Module for SQL and NoSQL
      • JDBC Access for Relational Database
      • NOSQL
    • Asset Management for creating your front end for nodes and resources
    • Template Engine to create your view and parsing it
    • Important Section: Reactive and Async
      • You can see Jooby as an event loop server thanks to the supported web servers: Netty, Jetty, and Undertow. The default web server is Netty.
    • HTTP Session and Cache
      • Session(Default)
      • GUAVA Session Store
      • CASSANDRA Session Store
      • COUCHBASE Session Store
      • REDIS Session Store
      • MONGODB Session Store
    • Security
    • Multiple ways for deployment
    • Servers
      • Netty— an asynchronous event-driven network application framework
      • Undertow— a flexible performant web server written in Java
      • Jetty— provides a web server and javax.servlet container, plus support for HTTP/2 and many other integrations
      • Servlets — deploy into a servlet container
    • Other modules:
      • Language support
        • Kotlin
      • Web services
        • AWS
        • Consul
      • Job scheduling
        • quartz
      • Full-text search
        • Elastic Search

Code Quality

Code quality is the only way to build rock-solid software. We took code quality very serious in Jooby with more than 4000 tests and a code coverage of 99.5 percent.

You can check it out for yourself on GitHub.

Jooby Benchmark

To learn more about performance in Jooby, check out these links below:

  • Techempower

  • GitHub

This is the benchmark in my server for hello world:

ab -n 10000 -c 100 http://172.16.0.6:8080/

This is ApacheBench, Version 2.3 <$Revision: 1757674 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/




Benchmarking 172.16.0.6 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests




Server Software:        

Server Hostname:        172.16.0.6

Server Port:            8080




Document Path:          /

Document Length:        9 bytes




Concurrency Level:      100

Time taken for tests:   3.351 seconds

Complete requests:      10000

Failed requests:        0

Total transferred:      860000 bytes

HTML transferred:       90000 bytes

Requests per second:    2984.59 [#/sec] (mean)

Time per request:       33.505 [ms] (mean)

Time per request:       0.335 [ms] (mean, across all concurrent requests)

Transfer rate:          250.66 [Kbytes/sec] received




Connection Times (ms)

             min mean[+/-sd] median   max

Connect:        2 15 2.7 16      23

Processing:     5 18 9.2 17     120

Waiting:        5 17 9.0 16     118

Total:          7 33 7.9 32     124




Percentage of the requests served within a certain time (ms)

 50%     32

 66%     33

 75%     33

 80%     34

 90%     35

 95%     36

 98%     55

 99%     76

100%    124 (longest request)


Run Your Application

A Jooby app looks like this:

public class App extends Jooby { // 1.
 {
   // 2. add a route
   get("/", () -> "Hello");
 }

 public static void main(String[] args) {
   // 3. run my app
   run(App::new, args);
 }
}


1) Create a new app extending Jooby

2) Define your application in the instance initializer

3) Run the application.

Conclusion

Jooby makes Java web development easy and fun. It has good documentation, and you can run your web application quickly and easily. Readability became an important measure of the quality of programs, with readability in Jooby code being very high.

Also, Orthogonality is one of the important factors in Jooby. Moreover, it’s simple, expressive, effective, and of course, has great performance, so it can keep you safe by using a worker thread.

Jooby provides all the tools to make you more productive, such as hotreload, browser live reload, unit/integrations test, and lots of modules. Additionally, the number of lines required to build something is usually smaller than any other Java framework.


You can join the Jooby channel here.

Application framework Relational database Web Service Java (programming language) Web server Web application

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Journey to Event Driven, Part 1: Why Event-First Programming Changes Everything
  • Strategies for Kubernetes Cluster Administrators: Understanding Pod Scheduling
  • 5 Steps for Getting Started in Deep Learning
  • Choosing the Right Framework for Your Project

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: