This document proposes a Java cloud application stack using Google Guice, Hibernate, Jersey, and Vaadin. It discusses choosing a framework based on Java, serving web and mobile interfaces, and the MVC pattern. It describes using Guice to integrate Hibernate ORM with a PostgreSQL database, Vaadin for a Java web UI, and Jersey for RESTful services. Finally, it mentions a proof-of-concept demo project implementing this stack on GitHub.
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
Simple Open Source Java Cloud App Stack with Guice, Hibernate, Jersey and Vaadin
1. A Simple Open Source Java Cloud App Stack with
Google Guice, Hibernate, Jersey and Vaadin
Jian Wu
03/09/2014
2. History of Web Frameworks
(Adopted from Matt Raible http://raibledesigins.com)
3. How do you choose a Cloud App Framework/Stack?
● Java is still the most mature and reliable language and
platform when developing the Web Apps and Services
running in the Cloud
● Two must-have features/functionalities for any Cloud Apps
and Services:
– Serving HTML5 Web UI to the Browsers
– Serving data to the Mobile Devices through Restful
Services/APIs
● MVC is still the design pattern to guide UI
● ACID is still important for Your Data Integrity
(Note: A Java Framework or Tool will be considered first as it can simplify the
development process including dev/debugging, testing, deployment and monitoring)
4. Layered Architecture for Java Cloud Apps & Services
Using Guice, Hibernate, Jersey and Vaadin
PostgreSQL
Java
Web Container
JDBC Connection
Google Guice
Hibernate ORM
App Business Logic … ...
HTML5/CSS3/JavascriptHTTP XML/JSON
5. Vaadin: Java Web UI Framework
Architecture
ServerBrowser
GWT
SQL
Container
View
Presenter
Application
Service
Application
Vaadin Platform
Server-side
Components
Terminal
Adapter
Client-side
Engine
Data
BindingCRUD
6. Vaadin: Java Web UI Framework
Advanced Web UI with Rich UI Components (1)
7. Vaadin: Java Web UI Framework
Advanced Web UI with Rich UI Components (2)
8. Building RESTful Web Services
with Jersey (JAX-RS)
(From: http://jersey.java.net)
9. Hibernate ORM with Back-end PostgreSQL DB
Hibernate is an object-relational
mapping (ORM) library for the Java
language, providing a framework for
mapping an object-oriented domain
model to a traditional relational
database.
Hibernate solves object-relational
impedance mismatch problems by
replacing direct persistence-related
database accesses with high-level
object handling functions.
“Open Session in View” is a well-known design pattern
to integrate Java Web/Service Tier with Hibernate ORM
for CRUD operations; and will be used in both Web UI
Interaction and Service Request Processing.
10. Glue everything together with Google Guice
To make Hibernate, Jersey, and Vaadin seamlessly working together
in Java Middle-tier Container, we are using Google Guice to “glue”
everything together.
Google Guice is a light-weight Dependency Injection Framework, its
runtime libraries are less than 1M. Guice organizes Java Object
Graph through its Module and Binding, Guice's servlet extensions
provide Dependency Injection in Web Application and Servlet
Container, including configuration of your servlet and filter
components.
Through Guice Filter and Guice ServletModule, Jersey and Vaadin
can be setup and configured in a Servlet Container, such as Tomcat,
working nicely with Hibernate “Open Session in View” Pattern.
11. A Proof-of-Concept Demo Project at github.com
As proof of concept, a sample guice-hibernate-jersey-vaadin-cloudapp project is
created at github.com: https://github.com/jianwu-github/guice-hbn-jersey-vaadin-cloudapp
This demo project has:
1. A simple PostgreSQL DB with “subscriber” table
2. Hibernate Mapping is used to map Subscriber Class to “subscriber” table
3. A simple “Subscriber Web UI” is built on top of Vaadin 7 utilizing HbnContainer Add-on,
it can be accessed at “http://localhost:8080/[appName]/ui/” when running on a local
Tomcat Server.
4. A simple “Subscriber” REST Service is built on top of Jersey 1.18, it can be accessed at
“http://localhost:8080/[appName]/rest/subscriber/” when running on a local Tomcat
Server.
5. All the components are wired together through Guice 3.0 with ServletModule.
6. The project is built with Maven