What’s New in Java >10: Container Support & Module Decoupling

4813f9eeba90ce3bef852c9b7f3d0e8e?s=47 Billy Fisher
September 12, 2019

What’s New in Java >10: Container Support & Module Decoupling

Java 9 module decoupling using the ServiceLoader & container improvements since Java 10.

Now streaming at https://youtu.be/5eexiA1fIGI.

4813f9eeba90ce3bef852c9b7f3d0e8e?s=128

Billy Fisher

September 12, 2019
Tweet

Transcript

  1. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    @_BILLYJF
  2. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    I’LL BE COVERING ▸ New Container Support ▸ Decoupling Modules Using Services ▸ Quick Minimal Overview ▸ Mob ▸ Links ▸ Please help prioritize the next session by providing feedback
  3. NEW CONTAINER SUPPORT WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT

    & MODULE DECOUPLING ▸ Java 10: CPU and memory limits of container respected ▸ “Java 10+ brings a lot of improvements but still needs manual configuration. To be safe, load test your stuff.”
  4. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    DECOUPLING MODULES USING SERVICES ▸ The Minimum ▸ Hello CLI ▸ Runtime Swappable HelloProvider
  5. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    SWAPPABLE HELLOPROVIDER java --module-path api.jar:World.jar:hellocli.jar \ --module helloworld
  6. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    SWAPPABLE HELLOPROVIDER java --module-path api.jar:World.jar:hellocli.jar \ --module helloworld
  7. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    SWAPPABLE HELLOPROVIDER java --module-path api.jar:Jupiter.jar:hellocli.jar \ --module helloworld
  8. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    SWAPPABLE HELLOPROVIDER MODULES ▸ API ▸ HelloProvider(s) ▸ CLI
  9. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINING

    A NEW MODULE ▸ /src ▸ [module name] ▸ [package folders]/[interface].java ▸ module-info.java
  10. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE API INTERFACE MODULE ▸ /src ▸ helloapi ▸ com.billyjf.hello.api/HelloProvider.java ▸ module-info.java CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  11. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE API INTERFACE MODULE: HELLOPROVIDER.JAVA package com.billyjf.hello.api; public interface HelloProvider { String getMessage(); } CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  12. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE API INTERFACE MODULE: MODULE-INFO.JAVA module helloapi { exports com.billyjf.hello.api; } CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  13. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES BUILD

    THE API INTERFACE MODULE: /BUILD.SH #!/usr/bin/env bash -e rm -rf out/* && rm -f *.jar javac -d out --module-source-path src $(find src -iname '*.java') jar --create --file=api.jar \ --module-version=1.0 -C out/helloapi . CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  14. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE WORLD HELLOPROVIDER MODULE ▸ /src ▸ worldhelloprovider ▸ com.billyjf.hello.providers/World.java ▸ module-info.java CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  15. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE WORLD HELLOPROVIDER MODULE: WORLD.JAVA package com.billyjf.hello.providers; public class World implements com.billyjf.hello.api.HelloProvider { public String getMessage() { return "World"; } } CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  16. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE WORLD HELLOPROVIDER MODULE: MODULE-INFO.JAVA module worldhelloprovider { requires helloapi; provides com.billyjf.hello.api.HelloProvider with com.billyjf.hello.providers.World; } CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  17. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES BUILD

    THE WORLD HELLOPROVIDER: /BUILD.SH #!/usr/bin/env bash -e rm -rf out/* && rm -f *.jar javac -d out --module-source-path src $(find src -iname '*.java') jar --create --file=api.jar --module-version=1.0 -C out/helloapi . CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  18. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES BUILD

    THE WORLD HELLOPROVIDER: /BUILD.SH #!/usr/bin/env bash -e rm -rf out/* && rm -f *.jar javac -d out --module-source-path src $(find src -iname '*.java') jar --create --file=api.jar --module-version=1.0 -C out/helloapi . jar --create --file=World.jar --module-version=1.0 -C out/worldhelloprovider . CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  19. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE HELLOWORLD CLI MODULE ▸ /src ▸ helloworld ▸ com.billyjf.helloworld/Hello.java ▸ module-info.java CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  20. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE HELLOWORLD CLI MODULE: HELLO.JAVA package com.billyjf.helloworld; import com.billyjf.hello.api.HelloProvider; import java.util.ServiceLoader; public class Hello { public static void main(String... args) { Iterable<HelloProvider> providers = ServiceLoader.load(HelloProvider.class); System.out.println(String.format("Hello Modular %s!", providers.iterator().next().getMessage())); } } CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  21. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES DEFINE

    THE HELLOWORLD CLI MODULE: MODULE-INFO.JAVA module helloworld { requires helloapi; uses com.billyjf.hello.api.HelloProvider; } CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  22. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES BUILD

    THE HELLO CLI: /BUILD.SH #!/usr/bin/env bash -e rm -rf out/* && rm -f *.jar javac -d out --module-source-path src $(find src -iname '*.java') jar --create --file=api.jar \ --module-version=1.0 -C out/helloapi . jar --create --file=World.jar \ --module-version=1.0 -C out/worldhelloprovider . CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  23. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES BUILD

    THE HELLO CLI: /BUILD.SH #!/usr/bin/env bash -e rm -rf out/* && rm -f *.jar javac -d out --module-source-path src $(find src -iname '*.java') jar --create --file=api.jar \ --module-version=1.0 -C out/helloapi . jar --create --file=World.jar \ --module-version=1.0 -C out/worldhelloprovider . jar --create --file=hellocli.jar \ --main-class=com.billyjf.helloworld.Hello \ --module-version=1.0 -C out/helloworld . CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  24. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES RUN

    THE HELLO CLI: /RUN.SH #!/usr/bin/env bash -e java --module-path api.jar:World.jar:hellocli.jar \ --module helloworld CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  25. WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES RE-BUILD

    EVERYTHING & RUN THE HELLO CLI $ ./build.sh && ./run.sh Hello Modular World! CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES
  26. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    MOB PRE-REQUISITES ▸ Java 12 ▸ http://www.sdkman.io ▸ sdk use java 12.0.1-open ▸ sdk current java ▸ java -version
  27. None
  28. WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING

    LINKS ▸ These slides ▸ http://bit.ly/java12containermodules ▸ References ▸ http://aboullaite.me/docker-java-10/ ▸ https://dzone.com/articles/improved-docker-container- integration-with-java-10 ▸ https://medium.com/adorsys/jvm-memory-settings-in-a- container-environment-64b0840e1d9e
  29. KEEP THE SERIES GOING RATE THIS SESSION http://bit.ly/java12containermodules