Lean WebApps with Skinny Miniservices #usetheplatfom #slideless Devoxx Poland 2018

"Lean WebApps with Skinny Miniservices #usetheplatfom" session from devoxx.pl 2018 (The Dragon Edition)

See you at MicroProfile With or Without Jakarta EE, at Munich Airport, Terminal 2 and at Single Page Applications (SPAs) -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webstandards.training (online).


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Managing Taxi Companies with Thin WARs and Java EE

Victor, please introduce yourself

Hi Adam, thank you first of all to consider me and my project for an interview :-).
My name is Victor Röder, and I'm simply a freelancing software developer and I'm living close to the geographical midpoint of the European Union (at least till 2019), that is in Germany somewhere 70 km north east of Frankfurt/Main.
You can find me on Github https://github.com/victorroeder and on Twitter @vicaware. But in both spheres I'm not that active.

You told me you are building a small Taxi App. Why Java EE?

Yes, in 2017 I actually planned to do a sabbatical and suddenly I got a request from several smaller taxi companies whether I'm willed and able to build something that could help them with their paper-and-pencil-based taxi management. So it would be a software that I could develop on my own, nearly without time pressure and the ability to earn some money, so I said "ok". And - who guessed it - the backend of it is (of course) done using Spring.

Ok, kidding - Java EE :). Or how I meanwhile call it: JSYSNRTO (for 'Java Stuff You Should Not Rename That Often')
Why Java EE? Well through your workshops I could recognize how lean and easy Java EE is/became, so I wanted to use it in a real-life project as soon as possible. And this was an opportunity.
I used J2EE years before and was impressed how it developed. But of course - as every technique - you even can also make it mega complicated with Java EE. So I'm glad to use the Adam Edition of the Enterprise Edition :-).

What is the purpose of the application?

The purpose is to simplify the management of small and medium-sized taxi companies. Every taxicab gets an Android-based provisioned tablet installed with which the drivers could record and manage their shift data and record-only the taxi tours (I'm explicitly writing 'recording-only the tours' since some guys of the German Tax Authority might read this interview as well... "hi guys..." :-D). The tablet itself is connected via BlueTooth to a small mobile printer to print out the tour receipts for the passengers and daily receipts with all shift details at the end of the shift for the drivers themselves.
The tablets transfer the shift and tour information to the backend and request possible changes of the master data if there was a server-side change. The maintaining of the master data is done by the company owner via a web UI. The App for the tablets is installed via the Play Store and the tablets initialize and configure themsevles when they are registered (with a correct key) and accepted by the backend. An easy on-boarding (and usage of the software later on) was very important to me, since I did not want to become a support center :-).

Are you happy with Java EE so far? Is Java EE productive?

Happy: Very. Now that the product is in place since over one year and being now somehow in a retrospective mode while preparing me for this interview, there are of course several things, I would not repeat in future projects. I'm using Vaadin for the backend's UI and I'm quite sure that using JSF would have been more than sufficient and JSF would have integrated better with CDI & stuff. Also I was playing around with the Fat Entity approach for the JPA entities, meaning that the entities managed their persistence themselves (using the ThreadLocal hack), contain the code for JSON de-/serializiation and other logic. Reason was, that a) I wanted to try it out and b) tried to find a way to log (for audit purposes) changes - made by UI users - on JPA level. With hindsight, I would keep it simple. But ok - honestly - I could not blame Java EE for that but rather you Adam, because you wrote about it in your book and thus put the bee in my bonnet ;-P.
The last but not least point that comes into mind, is that the code for JAX-RS and the stateless session beans share the same classes. I should have split that up (and let the JAX-RS classes inject the according session beans - as you recommend it) even if this results in partially tiny classes.

Which application servers, tools or IDEs are you using?

I started development with Glassfish and in production it is still Glassfish. And since I was crazy enough to implement a server-dependent JAAS module for login, my escape possibilities are limited... Locally and for my server's dev environment I'm using Payara. I should align that in a timely manner.
On the other hand I was playing around with other application servers and find them more polished than Glassfish/Payara...
The IDEs: Android Studio for developing the App, IntelliJ for the backend and Eclipse for the BIRT reports. Build tools: Maven for the backend project (because I wanted to) and Gradle for the Android stuff (because I had to). Of course there are many other tools, reminding me that there are nearly no small or trivial software projects out there (especially when you are working on them alone). You have to take care of so many stuff (build & quality environment, database stuff (and integration with other systems), versioning and release process, etc.), that you should always reach your goal with the most possible minimum of complexity and dependencies. Fast deployment and fast unit tests is a key metric. And automate as much and as simple as you can...

You are using the Boundary Control Entity pattern to structure your applications. What were your experiences, challenges and findings so far?

My experiences with BCE are very good. It enforces you to structure your code from the business point of view and not from a technical perspective. That even helps other developers to find their way through the structure more easier. Packages named 'dto' or 'services' say nothing, but business or domain related names show (new) developers clearly the way. Additional benefit: my scroll wheel is happy, too :).
But I used the pattern only for the business-related backend code. The server-centric presentation (and thus part of the backend project) and the Android project are structured slightly different by simply having expressive (again, from business point of view) package names and all topic-related classes are found their according package (without the deeper separation of boundary/control/entity). But classes that are cross-cutting are in the parent package (as it would be for BCE). No Util, Helper or Common packages or classes (bom chicka wah wah ;)

How big is your WAR? On which exernal dependencies are you relying?

4.8 MB. But with tricks. I put several external Jars (like those for Vaadin and BIRT) directly on the application server. Around 850 KB of the total size is my code.
Especially bringing BIRT and the thin WAR approach together is impossible. I thought about externalizing the BIRT stuff into a separate WAR whose services (i.e. report generation) could then be addressed by HTTP/REST... Or maybe I misunderstood the integration of the BIRT runtime somehow...?
(oh boy, this interview creates or reminds me of a lot of To-Dos ;-))

You are an airhacks.com alumni. Do you had any interesting conversations with other attendees (in the extensive breaks :-)

Yes, I already joined several of your workshops and had short but interesting conversations everytime (mostly chewing my food in parallel). And as far I remember all of them were related how to fight the technical or infrastructural complexity beast or dealing with difficult developers, architects, managers, etc that are more interested in creating themselves a monument within the project. None of them was about complaining "Oh, my business is so complex and it's so hard to implement."
Yes, the conversations mirrored my experiences I made with software projects so far, that they are lacking discipline for minimalism on many levels.
And it's a pity that it's often like that...

Victor, big thanks for the interview!


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

CDI and plugins, Bean Discovery, Migrations, Async Microservice Communication, Validations with JAX-RS, Serialization---or 52nd airhacks.tv is available

"CDI components as plugins, CDI bean discovery mode recommendations, asynchronous microservice calls, modelling validations with REST, JSON-B and selective serialization, DB migrations with Java EE 7, how to be a happy consultant" , or 52nd airhacks.tv is available:

Any questions left? Ask now: https://gist.github.com/AdamBien/24c3560d05e7bcba9a82af072955a6c4 and get the answers at the next airhacks.tv.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

From Zero to Hello with Open Liberty 18 Full Profile Java EE 8

How long does it take to install, start "Java EE 7/8 Full Profile" Open Liberty 18 (the opensource version of IBM WebSphere) server, then clone, build and deploy a Java EE application (ping) with Maven 3?

No tricks, no magic, no dependencies:

Also checkout other Java EE "Full Profile" application servers.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Generating Swagger / OpenAPI Without External Dependencies

A CRUD JAX-RS 2 (Java EE 7/8) service:


@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("workshops")
public class WorkshopsResource {

    @GET
    public JsonArray all() {
        return Json.createArrayBuilder().
                add("java").
                add("web").
                build();
    }

    @GET
    @Path("{name}")
    public JsonObject get(@PathParam("name") String name) {
        return null;
    }

    @PUT
    @Path("{name}")
    public void add(@PathParam("name") String name, JsonObject workshop) {

    }

    @DELETE
    @Path("{name}")
    public void remove(@PathParam("name") String name) {

    }
}    

...deployed on MicroProfile compatible application servers (tested with Payara Server 5 Full Profile), emits the following OpenAPI/swagger document from the standardized uri: http://localhost:8080/openapi:


openapi: 3.0.0
info:
    title: Deployed Resources
    version: 1.0.0
servers:
- url: http://localhost:8080/openapi-sample
    description: Default Server.
paths:
    /resources/workshops:
    get:
        operationId: all
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
    /resources/workshops/{name}:
    get:
        operationId: get
        parameters:
        - name: name
        in: path
        required: true
        style: simple
        schema:
            type: string
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
    put:
        operationId: add
        parameters:
        - name: name
        in: path
        required: true
        style: simple
        schema:
            type: string
        requestBody:
        content:
            application/json:
            schema:
                type: object
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
    delete:
        operationId: remove
        parameters:
        - name: name
        in: path
        required: true
        style: simple
        schema:
            type: string
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
components: {}

For the creation of the document above, no additional dependencies, configuration or changes were needed. The example above is a 3.9kB Thin WAR.

Because servers like Payara Server 5 Full Profile or OpenLiberty support Java EE 8 and MicroProfile at the same time, you neither have to change your runtime, nor your lean Java EE 8 build setup:


<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.airhacks</groupId>
<artifactId>openapi-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
   <dependency>
       <groupId>javax</groupId>
       <artifactId>javaee-api</artifactId>
       <version>8.0</version>
       <scope>provided</scope>
   </dependency>
</dependencies>
<build>
   <finalName>openapi-sample</finalName>
</build>
<properties>
   <maven.compiler.source>1.8</maven.compiler.source>
   <maven.compiler.target>1.8</maven.compiler.target>
   <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>    
For customizations (coming with the MicroProfile OpenAPI) you will need a single provided dependency to the MicroProfile API:

<dependency>
    <groupId>org.eclipse.microprofile</groupId>
    <artifactId>microprofile</artifactId>
    <version>1.3</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>	    

Enjoy Java EE 8 + MicroProfile and stay light!

See you at MicroProfile With or Without Jakarta EE, at Munich Airport, Terminal 2


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

From JSF and PrimeFaces to WebComponents--A Conversation With Cagatay Civici

An airhacks.fm podcast conversation with Cagatay Civici (@cagataycivici) about starting with Java, interfaces and return statements, IBM RAD JSF, Sun JSF Woodstock, Apache MyFaces, Apache MyFaces Tomahawk, JSF Chart Creator, Apache MyFaces Tobago, Oracle's ADF, YUI, jQuery and JSF, the non-dependency mindset, building complex UI components, Jakarta EE and microprofile, a scientific approach to design, choosing colors and color palletes, ideas for themes, standards and PrimeFaces, keeping up with Angular, React and WebComponents, StencilJS, PrimeFaces NG, an opensource model with commercial support, why "Prime", component sponsorship, performance under pressure and PrimeTek.

Subscribe to airhacks.fm podcast via: RSS iTunes

See you at Effective Progressive-, Offline-, Single Page-, Desktop Apps with Web Standards -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webcomponents.training (online).


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

From Zero to Hello with WildFly Full 13.0.0.Final

How long does it take to install, start "Java EE 7/8 Full Profile" WildFly 13 (and the largest available WildFly distribution) server, then clone, build and deploy a Java EE application (ping) with Maven 3?

No tricks, no magic, no dependencies:

Also checkout other Java EE "Full Profile" application servers.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Building PWA with Polymer 3, WebComponents and Java EE 8 Backend

I'm starting with the implementation, build and deployment of a Java EE 8 HTTP/JSON endpoint, then scaffold a polymer 3 Progressive Web Application (PWA) with CLI, and finally create a vanilla Custom Element which calls the Java EE 8 backend. From scratch, without tricks or magic. #usetheplatform

In 8 mins:

See you at Structuring Single Page Applications (SPA)s / Progressive Web Applications (PWA)s with WebComponents -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webcomponents.training (online).


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Using enums as CDI Events

Java enum can be used as an CDI "command" event:


public enum OrderEvent {
    CREATE, CANCEL;
}

Now you can sent enum instances:


public class OrderProcessor {

    @Inject
    Event<OrderEvent> events;

    public void createOrder() {
        events.fire(OrderEvent.CREATE);
    }

    public void cancelOrder() {
        events.fire(OrderEvent.CANCEL);
    }
}

...and consume them:


public class OrderMetrics {

    //...

    public void onSuccess(@Observes(during = TransactionPhase.AFTER_SUCCESS) OrderEvent event) {
        switch (event) {
            case CREATE:
                //...
                break;
            case CANCEL:
                //...
                break;
        }
    }
    public void onFailure(@Observes(during = TransactionPhase.AFTER_FAILURE) OrderEvent event) {
        switch (event) {
            case CREATE:
                //...
                break;
            case CANCEL:
                //...
                break;
        }
    }
}    

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

When "There is a process already using the admin port 4848", but it is not true

When you try to start Payara 5 / GlassFish with:

asadmin start-domain

...and you get the following error:

There is a process already using the admin port 4848 -- it could be another instance of Payara Server or Payara Micro. Command start-domain failed.

although there is no running Java process and the port is not occupied, you hostname is probably not pingable:

ping $(hostname)

output: Request timeout

Solution:

Add the following line to the /etc/hosts file:

127.0.0.1 [YOUR_NOT_PINGABLE_HOSTNAME]

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW MUC Airport Workshop: Migrating Java Client (Swing / Java FX) to Web Standards

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License