How goes the battle?
2021/02/22
This post is to show how I created a Helidon demo with a Raspberry PI. A simple web application to control a 14 segments display. This is another blog about Java on Raspberry PI.
Originally named J4C (Java for Cloud), Helidon was designed to be simple and fast, and the framework supports two programming models for writing microservices: Helidon SE and Helidon MP. Helidon SE is designed to be a microframework that supports the reactive programming model, it features three core APIs to create a microservice; a web server, configuration, and security. Helidon MP, on the other hand, is an Eclipse MicroProfile runtime that allows the Jakarta EE community to run microservices in a portable way; supports the MicroProfile 1.1 specification for building microservices-based applications.
But in both cases, a Helidon microservice is a Java SE application that starts a tinny HTTP server from the main method.
Helidon architecture
Microservices frameworks categories
Helidon 2.0 adds significant improvements for both Helidon SE and Helidon MP programming styles
Fun Facts
Helidon is a Greek word for swallow, a type of bird that according to Wikipedia has “a slender, streamlined body and long pointed wings, which allow great maneuverability and very efficient flight”. Perfect for darting through the clouds.
Idea
A simple Helidon example that shows a 14 segments display and control in real-time a real one with a Raspberry Pi 3 B.
I have the “5421AG” model. 14 segments display – 5421AG
The PI4J uses a different GPIO number.
Note: Pi4J (by default) uses an abstract pin numbering scheme to help insulate software from hardware changes. Pi4J implements the same pin number scheme as the Wiring Pi
PIN 11 -> GPIO 11
PIN16 -> GPIO 25
Code
1 2 | static Routing createRouting() { List<class<? extends="" encoder="">> encoders = Collections.singletonList(UppercaseEncoder.class);</class<?> |
1 |
1 2 3 4 5 6 7 8 9 10 | return Routing.builder() .register("/rest", component) .register("/websocket", TyrusSupport.builder().register( ServerEndpointConfig.Builder.create(MessageBoardEndpoint.class, "/board") .encoders(encoders).build()) .build()) .register("/web", StaticContentSupport.builder("/WEB").build()) .build(); } |
Disclaimer – I use the same CSS that I used in my Quarkus Qute example and I started this demo using this WebSocket sample
You can get the full code on my GitHub.
Links
https://github.com/oracle/helidon
https://www.youtube.com/channel/UChg00-uTTrCMmPsuzUNaZsA
https://twitter.com/helidon_project