On-Demand Script Loading with JavaScript

In this screencast a script is dynamically loaded by user action (with click on a button) and without any external libraries:

Dynamic script loading is particularly useful for polyfills, which can be conditionally loaded depending on browser's capabilities.

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


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Java EE 8: Manipulating JsonObjects with JsonPatch

JSON-P (JSR-374) from Java EE 8 comes with JSON Patch support, which can be used for manipulation (patching) of JsonObject instances (see also Java EE 8 and JSON-P Simplify System Testing with JSON Patch):


@Test
public void patch() {
    JsonObject sub = Json.createObjectBuilder().
            add("name", "EE4J").
            build();

    JsonObject initial = Json.createObjectBuilder().
            add("fact", "Java EE is nice").
            add("myth", "Java EE is heavyweight").
            add("future", sub).
            build();

    JsonPatch patch = Json.createPatchBuilder().
            add("/version", "8").
            replace("/fact", "Java EE rocks").
            replace("/future/name", "Jakarta EE").
            remove("/myth").
            build();

    JsonObject result = patch.apply(initial);
    System.out.println("result = " + result);
}

Output:

result = {"fact":"Java EE rocks","future":{"name":"Jakarta EE"},"version":"8"}

JSON-P comes as a single maven dependency:


<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>1.1.2</version>
</dependency>

See you at Java EE Workshops at MUC Airport, particularly at the Effective Java EE 8 workshop


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Java EE, Thin WARs, Microservices and Continuous Delivery at Otto

Bastian, please introduce yourself (feel free to share your twitter, linkedin, github etc. accounts)

My name is Bastian Sperrhacke and I am a software developer and technical lead in a ten people team called "Verfügbarkeit" (availability) at Otto GmbH & Co. KG. There are three business analysts, six developers (including me) and one teamlead responsible for the product availability calculation and the product sell services. We are one of many teams in the backend IT of Otto. You can find me at @deratzmann and Bastian Sperrhacke.

What are you building with Java EE?

We build our latest system for additional sell services for products offered in a shop with Java EE 7. For example, if you want to add an additional warranty to your mobile phone or want to get rid of your old washing machine while receiving the new one, there is a business case called "article service" which abstracts these kind of cases. We build this system as a Java EE microservice and offer REST Services for our frontends and shops.

Can you share with us some geeky numbers like e.g. TX per seconds, heap sizes, thinnest WARs etc -- whatever Java EE devs might find interesting.

Currently our WAR file is about 300kb, the biggest file inside is our swagger documentation file (71kb). From commit to production we are live in about 7 minutes with our continuous delivery pipeline, including Unit-, Integration-, System- and Performancetests. Our software is running since begin of February 2018 and had 5280823 requests in the last week.

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

Yes, I am very happy with Java EE. It provides me a standardized way to code, is well documented and highly used. With Java EE you can become productive in minutes, no bloated configuration or dependency hell anywhere. Just code your business requirements.

Which application servers, tools or IDEs are you using?

First of all we use the Payara full server, it is very fast and productive, well documented. It provides the stable Java EE API and the innovative, fast moving microprofile. The Payara team is very nice, I got to know them at JavaOne last year. Relating IDEs it is up to each team member to use his favorite IDE or editor. Most of us (including me) are using netbeans, very nice, fast and lean IDE. For our pipeline we use Jenkins. Our docker containers are orchestrated by docker swarm.

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

The first big challenge was to structure the class and the packages in a business, not a technical driven way. So no more "persistence", "valueobjects" or "service" package. For decades developers learned to structure in a technical way. But for new guys in a team it is hard, to find a business case implementation in such a structure. The ECB pattern is the easiest way to fit in that context. You start with an entity and a service called boundary. There is no easier way. And if (and only if) the boundary "gets too big", you refactor the non-standalone functions out to a so called control. In my opinion this way leads to a clearly arranged code, not overengineered, just fitted to the current required business case.

How important are standards for you? Does your application depend on application server specific APIs?

Standards are very important for me. When you are professionally developing products, you have to ask yourself: Do I technically need an early adopter software or a long lasting lean product. In real world projects the truth lies between these two approaches. And Java EE is a perfect fit for that. First you get a quite stable API, which is continuously evolving. Since Java EE was transferred from Oracle to the community, I think there will be much more drive behind it. Let's have a look at the great companies standing behind the microprofile initiative. This initiative is also responsible for a quite innovative de facto standardization. Using one of the application servers like Payara means, I get the API stability of Java EE and a fast evolving feature set of the microprofile. In our project we currently use the microprofile-config-api and plan to use the new fault-tolerance-api. Furthermore we use some Payara specific implementations like the Jackson API. We also planned to use the build-in Hazelcast for distributed job scheduling and caching.

Which Java EE APIs are you using in your products?

Generally we use EJB, JPA, CDI, Bean Validation, Jax-RS, JTA and JSF.

You attended JavaOne last year. What was your impression?

This was my first time at JavaOne and also my first time in the US. It was amazing and I hope to get a chance for a second visit in the near future. I attended as much sessions as I could get. It was exhausting but worth it. Hopefully I can introduce some ideas in our daily business.

Can you share any resources (blogs, etc feel free to promote yourself) with us?

I get my newest info from twitter. I read tweets and blogs from Vlad Mihalcea, Thorben Janssen (hellish good JPA specialists), Sebastian Daschner (Java EE evangelist), Payara (Java EE Server) and last but not least Adam Bien. :)

Bastian, thank you for the interview!


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Java EE 8 and JSON-P Simplify System Testing with JSON Patch

JSON-P (JSR-374) from Java EE 8 comes with JSON Patch support, which is useful for system testing.

A JSON object returned from a HTTP endpoint can be easily compared to a local representation loaded from a file:


import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonPatch;
import javax.json.JsonReader;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

public class JSONPDiffTest {

    @Test
    public void subtraction() {
        //e.g. server result
        JsonObject actual = Json.createObjectBuilder().
                add("a", 21).
                add("b", 1).
                build();

        try (JsonReader reader
                = Json.createReader(this.getClass().getResourceAsStream("/expected.json"))) {
            JsonObject expected = reader.readObject();
            JsonPatch diff = Json.createDiff(expected, actual);
            assertTrue(diff.toString(), diff.toJsonArray().isEmpty());
        }
    }
}    

The code above loads the file src/test/resources/expected.json with the content:


{
    "a": 21,
    "b": 2
}    

and compares it to the actual instance.

The result is:

java.lang.AssertionError: [{"op":"replace","path":"/b","value":1}]

JSON-P comes as a single maven dependency:


<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>1.1.2</version>
</dependency>

See you at Java EE Workshops at MUC Airport, particularly at the Java EE CI/CD, Testing and Quality workshop


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

What is a Mixin?

In this screencast I implement and use a Mixin with stock JavaScript / ES2015 (ES6):

"In object-oriented programming languages, a Mixin is a class that contains methods for use by other classes without having to be the parent class of those other classes (...)":

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


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Database Authentication, Microservices with JSF, Denormalization, DB Audits, JAX-RS Audit, Devs and Ops -- or 47th airhacks.tv

Questions and topics for the 47th airhacks.tv -- a monthly Questions and Answers show:

  1. Database Authentication: SSH vs. username / password
  2. Microservices with JSF frontend -- architectural discussion
  3. How to modularize WARs
  4. Dealing with denormalized databases
  5. Java EE authentication (Active Directory)
  6. Identity preservation and audits in DB
  7. JAX-RS authentication and principal delegation to EJB / CDI
  8. Development in intranet environment
  9. Reducing coupling between Javascript components like e.g. in React
  10. Developers and operations -- their roles in the future
  11. DeltaSpike project review -- with or without @Repository
  12. Impact of 3rd party libraries on build performance -- with some numbers
  13. Unpredictable, long running transactions
  14. Propagating principals from JAX-RS to EJBs
  15. Why it is a bad idea to resend a password on each request?
  16. Dealing with security in projects like e.g. credit card processing

Ask questions during the show via twitter mentioning me: http://twitter.com/AdamBien (@AdamBien) or using the hashtag: #airhacks. You can join the Q&A session live each first Monday of month, 6 P.M at airhacks.tv or http://www.ustream.tv/channel/adambien

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 online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Using Vaadin Date Picker as WebComponent

WebComponents are an interesting set of browser APIs to implement entire applications from scratch. However: WebComponents were also designed for reuse, so you can easily include 3rd-party (like e.g. Vaadin) components with your application.

In this screencast I'm integrating a Vaadin Date Picker WebComponent with plain JavaScript / ES 6. From scratch, in 6 minutes:

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 online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

FN, Serverless and Exploded Servers -- airhacks.fm

A smalltalk :-) with Shaun Smith, @shaunmsmith, Director of Product Management for Oracle Serverless and Fn project committer.

From TopLink, EclipseLink over fnproject.io to Fn Java Functions Developer Kit (screencast), exploded application servers, Docker and serverless architectures or the 5th episode of airhacks.fm.

Subscribe to airhacks.fm podcast via: iTunes or RSS

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 online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

2018 Predictions

My 2018 predictions:

  1. Thin WARs become mainstream. Packaging the infrastructure together with the business logic although only <1% changes is not reasonable in containerized environments and slow. Fast turnaround cycles are crucial for productivity. Developers infected with "Thin WAR" mindset thrive for Micro WARs with fast deployments. It is common in green field Java EE 7 projects to have WARs smaller than 1 MB.
  2. Microservices become just another solution for a problem and not a general architecture. It is perfectly fine to deploy a single, small, WAR containing everything: a macroservice / microlith.
  3. Serverless overuse: serverless architectures claim to safe costs and to simplify operations. This is not true for all use cases -- I expect first reports of failing serverless projects due additional implementation complexity and plumbing. However: combining "traditional" Thin WARs with serverless endpoints brings the best of both worlds together. Servers for the main load and functions for (infrequent) events.
  4. OpenLiberty could become the killer Java EE 8 / Java 9 application server. Small, lightweight and with interesting production features.
  5. SQL revival: Modern relational databases like e.g PostgreSQL will regain traction.
  6. JMS revival: there is a lack of popular common messaging API in microservice context. JMS 2.0 is just an API and could be implemented by many messaging services. JMS API with a "funky" implementation could (should) gain traction.
  7. I got the first requests about Java 9 modules within microservices. There should be a buzz around additional module complexity introduced with "premature modularization" in second half of 2018 (or earlier).
  8. Fat Clients are back: Service Workers, Cache API, Progressive Web (Offline) Apps, IndexedDB, "offline first" encourage developers to put more and more logic on the client. This is exactly how Fat Client is defined.
  9. The year of "UseThePlatform": more and more "enterprise" projects will move away from JavaScript frameworks to plain WebStandards. Frequent migrations are expensive and come with no additional value.
  10. Server Side Rendering (SSR): server side rendering is a viable architecture for SPAs / PWAs. Java Server Pages have a bad name, but are a fast and capable serverside templating technology with great tool support.
  11. Raise of WebComponents (v1): Custom Elements, Shadow DOM together with ES 6 are a viable alternative to JavaScript frameworks. The longer you wait, the leaner your application becomes.
  12. Frameworks known from Java ecosystem like Vaadin Elements and Prime Elements become a popular WebComponent-compatible UI widget provider.
  13. HTTP/2 and Webstandards will dramatically simplify the JavaScript build pipeline. No build is the best build.
  14. JavaScript (ES 7+) will become more and more similar to Java. Now Java developers can become easily webapp developers with 20+ years experience :-)

My 2017 predictions were...


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Using lit-html with WebComponetns (Custom Elements and Shadow DOM)

WebComponents can use ES 6 Template Literals to render dynamic contents out-of-the-box [see e.g. webcomponents.training ].

In this screencast an efficient (~500 unminified LoC), ES 6 template titeral-based, template library: lit-html was used to render only the "dirty" parts of the DOM tree.

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 online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

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