Java EE 7 Killer Architecture in 229 lines of code – Wildfly, Olingo, OpenUI5

Java EE 7 - Olingo - OData

This blog post will describe a killer Java EE architecture that connects the database through a JPA layer to the client.

The client will use OpenUI5 with a OData Model. I coded this whole project in around 2 hours on a sunday. The results are published on github:

https://github.com/ManuelB/blueprint

Application Code

Here is the amount of code that was needed:

$ find . -name "*.j*" | xargs wc -l
LOC File
34 ./src/main/java/de/incentergy/architecture/JAXRSConfiguration.java
92 ./src/main/java/de/incentergy/architecture/JpaODataServiceFactory.java
26 ./src/main/java/de/incentergy/architecture/entities/Todo.java
21 ./src/main/webapp/blueprint/Component.js
28 ./src/main/webapp/blueprint/controller/TodoDetails.controller.js
7 ./src/main/webapp/blueprint/controller/App.controller.js
21 ./src/main/webapp/blueprint/controller/TodoList.controller.js
229 total

Database

I am using the default relational database that comes with my application server. When using wildfly this will be the H2 database engine. There is currently a lot of hype for No SQL databases. My personal opinion is, that one of the best no sql databases is the Java Heap this means that a Java HashMap will have amazing performance. Most of NoSQL databases are not solving any new problems. Most of the time they are only invented for a single purpose e.g. Amazon Dynamo to save the Amazon Cart and Voldemort was used by LinkedInn to cache social content. If you do not have these special requirements there is no need to use a no sql database.

Application Server

Every application has to run on an application server. I prefer Wildfly 10 mainly because it has a fast innovation cycle and is the basis for a commercial product. Java EE application servers are known to be big and slow which is kind of true. Nevertheless there are a lot of people trying to make them work easily e.g. my demo application is based on a maven build. The maven build will automatically download the application server and start it. Every other solution for installing enterpise applications like docker, Java Web Start, .NET click once has a similar overhead and has the same complexity. So our application can be run with these simple commands:

git clone https://github.com/ManuelB/blueprint.git
cd blueprint
mvn wildfly:run

Prequisits are: Git, Java 8, and Maven 3.3

Server-side-application a.k.a. Web Application

The application itself is a tuned Java EE version of Olingo exposed through a JAX RS endpoint. The transaction handling is done with a UserTransaction that is retrieved from JNDI. Currently Olingo does not have nice support yet for JTA or even better for CDI. It is necessary to use JNDI to get the correct objects that are needed.

Client-side-application a.k.a. HTML5 OpenUI5 GUI

The client side is implemented as an OpenUI5 component containing 5 views and 3 controllers. These are connected through the ODataModel that is exposed the global model and it can be used everywhere to bind server values to view.

Conclusion

The given architecture is state of the art. If you want to learn more about these technologies ask you boss to book one of our classes.


Posted

in

, , ,

by

Comments

2 responses to “Java EE 7 Killer Architecture in 229 lines of code – Wildfly, Olingo, OpenUI5”

  1. Sergey Batsura Avatar
    Sergey Batsura

    Hi!

    Where is business logic? On client?
    IMHO it is not good idea for security reason…

    Best regards, Sergey Bastura

    1. Manuel Blechschmidt Avatar

      Hi Sergey,
      the business logic can be implemented in a JAX-RS EJB.
      Just create a class annotated with @Stateless and @Path and add it in Ressourcen class.

      Greeting
      Manuel

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.