Slide 1

Slide 1 text

@gunnarmorling | @aalmiray #Layrry Plug-in Architectures With Layrry and the Java Module System Gunnar Morling | Andres Almiray

Slide 2

Slide 2 text

@gunnarmorling | @aalmiray #Layrry Gunnar Morling ● Open source software engineer at Red Hat ○ Debezium ○ Hibernate ● Spec Lead for Bean Validation 2.0 ● Java Champion ● @gunnarmorling

Slide 3

Slide 3 text

@gunnarmorling | @aalmiray #Layrry Andres Almiray ● Senior Principal Product Manager @ Oracle ○ “Seasoned Sourceror” ● ❤ Open Source & Java ● Apache Groovy PMC ● Java Champion Alumni ● @aalmiray

Slide 4

Slide 4 text

@gunnarmorling | @aalmiray #Layrry JPMS Java Platform Module System (also known as Jigsaw) Introduced in Java 9 Designed to break down the JVM monolith Applicable to user space as well The promise is to give developers better code encapsulation and design foundations

Slide 5

Slide 5 text

@gunnarmorling | @aalmiray #Layrry However... © Alexander Henning Drachmann https://flic.kr/p/uUA4G (CC BY-SA 2.0)

Slide 6

Slide 6 text

@gunnarmorling | @aalmiray #Layrry Some User Statements “JPMS only allows for one version of a module” “JPMS doesn’t allow to add modules at runtime” “I have to modularize ALL my dependencies in order to benefit from JPMS” “It’s so hard to map dependency coordinates to module dependencies” “Help, non-exported packages of different modules collide!”

Slide 7

Slide 7 text

@gunnarmorling | @aalmiray #Layrry What no one ever said “Let’s use JPMS Layers to tackle (some of) these issues”

Slide 8

Slide 8 text

@gunnarmorling | @aalmiray #Layrry Module Layers https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/ModuleLayer.html

Slide 9

Slide 9 text

@gunnarmorling | @aalmiray #Layrry Using the Layers API

Slide 10

Slide 10 text

@gunnarmorling | @aalmiray #Layrry Hello, Layrry! An API and Launcher for Modularized Java Applications

Slide 11

Slide 11 text

@gunnarmorling | @aalmiray #Layrry Hello, Layrry!

Slide 12

Slide 12 text

@gunnarmorling | @aalmiray #Layrry Layrry JPMS © Christoper Michel https://flic.kr/p/UMtHv5 (CC BY 2.0)

Slide 13

Slide 13 text

@gunnarmorling | @aalmiray #Layrry Ready-Made Launcher layrry-launcher--all.jar \ —layers-config layers.yml

Slide 14

Slide 14 text

@gunnarmorling | @aalmiray #Layrry Parameterization

Slide 15

Slide 15 text

@gunnarmorling | @aalmiray #Layrry Built-in Template Support layrry-launcher--all.jar \ —layers-config javafx.toml \ —properties versions.properties

Slide 16

Slide 16 text

@gunnarmorling | @aalmiray #Layrry jbang layrry@moditect \ —layers-config javafx.toml \ —properties versions.properties

Slide 17

Slide 17 text

@gunnarmorling | @aalmiray #Layrry Local Repositories © Andres Almiray (CC BY 2.0)

Slide 18

Slide 18 text

@gunnarmorling | @aalmiray #Layrry Local Repositories ● Artifacts can be organized in a local repository that does not require remote resolution ● Two layouts currently supported

Slide 19

Slide 19 text

@gunnarmorling | @aalmiray #Layrry Local Repositories

Slide 20

Slide 20 text

@gunnarmorling | @aalmiray #Layrry Local Repositories

Slide 21

Slide 21 text

@gunnarmorling | @aalmiray #Layrry Plug-in Architectures © Justin Taylor https://flic.kr/p/4fQz9t (CC BY 2.0)

Slide 22

Slide 22 text

@gunnarmorling | @aalmiray #Layrry Plug-in Architectures Can dynamically add (and remove) layers at runtime

Slide 23

Slide 23 text

@gunnarmorling | @aalmiray #Layrry Plug-in Architectures

Slide 24

Slide 24 text

@gunnarmorling | @aalmiray #Layrry © Bob Adams https://flic.kr/p/cYV7gq (CC BY-SA 2.0) Demo

Slide 25

Slide 25 text

@gunnarmorling | @aalmiray #Layrry Bonus: Class Unloading ● Classes and layer class loader subject to GC after plug-in removal ● Dragons beware, class loader leaks can happen ○ Dangling references in remaining layers ○ Started threads ○ Shutdown hooks

Slide 26

Slide 26 text

@gunnarmorling | @aalmiray #Layrry

Slide 27

Slide 27 text

@gunnarmorling | @aalmiray #Layrry

Slide 28

Slide 28 text

@gunnarmorling | @aalmiray #Layrry

Slide 29

Slide 29 text

@gunnarmorling | @aalmiray #Layrry

Slide 30

Slide 30 text

@gunnarmorling | @aalmiray #Layrry Outlook ● Remote layer files ● Binary distributions: Github Releases, Homebrew, SDKMan, etc. ● Integration with jlink ● Derive layers from pom.xml? ● Programmatic plug-in API ● Your contributions?!

Slide 31

Slide 31 text

@gunnarmorling | @aalmiray #Layrry Resources Source code https://github.com/moditect/layrry https://github.com/moditect/layrry-examples

Slide 32

Slide 32 text

@gunnarmorling | @aalmiray #Layrry Resources Blog posts https://www.morling.dev/blog/introducing-layrry-runner-and-api-for- modularized-java-applications/ https://www.morling.dev/blog/plugin-architectures-with-layrry-and- the-java-module-system/ https://www.morling.dev/blog/class-unloading-in-layered-java-applications/

Slide 33

Slide 33 text

@gunnarmorling | @aalmiray #Layrry Q & A

Slide 34

Slide 34 text

@gunnarmorling | @aalmiray #Layrry Demo

Slide 35

Slide 35 text

@gunnarmorling | @aalmiray #Layrry JavaFX Demo