Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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.”

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

WHAT’S NEW IN JAVA >10: CONTAINER SUPPORT & MODULE DECOUPLING SWAPPABLE HELLOPROVIDER MODULES ▸ API ▸ HelloProvider(s) ▸ CLI

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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 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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

KEEP THE SERIES GOING RATE THIS SESSION http://bit.ly/java12containermodules