Let’s see how to develop a super-hipster Java Web App. This will be a long-running post, evolving as time goes, using technologies that are solving problems I’ll face. Please follow along and ask questions as they come!
We’ll start with a monolith from 2015: access to a NoSQL database, business logic and a web UI in a single deploy/release/file.
As you can guess from the title, I’ll already sprinkle some hipsterness to this Web app microlith. I’ll use:
- For NoSQL Access, JNoSQL
- For the business logic, CDI (coming from Wildly Swarm) 1.2
- For the UI layer, Vaadin 8 (because I love not having to learn HTML/CSS/JSF to develop good functional Web UIs)
Life’s better with a scenario, so let’s pretend we’re developing a database of programming languages and will store their name, main link and allow visitors to comment about the languages.
So let’s code!
We need a way to interact with the database, so I created a simple Web UI to add new data. Currently it only adds Languages; we’ll deal with comments later.
So, now we have CDI + Vaadin working. You can run this project with mvn clean wildfly-swarm:run and package it into a überjar with mvn clean package.
At this point, NoSQL is still missing in our app. I don’t want to create the NoSQL access with a proprietary API because I know that my initial choice of NoSQL database may not be the best for my use case. There are so many databases (more than 255) that I (still) don’t know where to start. So, I’ll use JNoSQL to model and connect my app to a NoSQL database. For now, I’ll use MongoDB as database just because, no real reason.
To start a new MongoDB instance using Docker, just run docker run -d –name mongodb-instance -p 27017:27017 mongo
That’s it for now: started with CDI + Vaadin, added JNoSQL support. There are still many ways to go so this is super-hipster:
- Break UI and Backend into Microservices talking over
- Do away with DAO and use a Repository instead
- Handle comments!
- Add events to notify concurrent users of new languages
- Launch Wildfly Swarm inside/as a Docker instance
- … And many more!
What would you like to see next? Let me know!