Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Plug-in Architectures With Layrry and the Java Module System (vJUG)

Plug-in Architectures With Layrry and the Java Module System (vJUG)

-- A joint talk with Andres Almiray at Virtual JUG --

The Java Module System lays the foundation for building modularized applications on the JVM. It doesn’t concern itself though with resolving module versions and obtaining modules from repositories.

This is where Layrry comes in: an API and launcher for modularized Java applications which takes a descriptor of the module layer(s) to assemble, fetches the modules and starts up the application.

Join us for this session and learn how to:

* Build Java applications using layers, e.g. providing isolation between different versions of one module.
* Use jbang to launch your layered apps in no time.
* Create plug-in based rich-client applications using JavaFX and Layrry, allowing to – dynamically reconfigure and update your layer hierarchy, no restarts required.
* Create your own customized Layrry launcher if needed

This session is code-centered, be ready to see the Java Module System, Layrry, and JavaFX in action!

8e25c0ca4bf25113bd9c0ccc5d118164?s=128

Gunnar Morling

November 24, 2020
Tweet

Transcript

  1. @gunnarmorling | @aalmiray #Layrry Plug-in Architectures With Layrry and the

    Java Module System Gunnar Morling | Andres Almiray
  2. @gunnarmorling | @aalmiray #Layrry Gunnar Morling • Open source software

    engineer at Red Hat ◦ Debezium ◦ Hibernate • Spec Lead for Bean Validation 2.0 • Java Champion • @gunnarmorling
  3. @gunnarmorling | @aalmiray #Layrry Andres Almiray • Senior Principal Product

    Manager @ Oracle ◦ “Seasoned Sourceror” • ❤ Open Source & Java • Apache Groovy PMC • Java Champion Alumni • @aalmiray
  4. @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
  5. @gunnarmorling | @aalmiray #Layrry However... © Alexander Henning Drachmann https://flic.kr/p/uUA4G

    (CC BY-SA 2.0)
  6. @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!”
  7. @gunnarmorling | @aalmiray #Layrry What no one ever said “Let’s

    use JPMS Layers to tackle (some of) these issues”
  8. @gunnarmorling | @aalmiray #Layrry Module Layers https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/ModuleLayer.html

  9. @gunnarmorling | @aalmiray #Layrry Using the Layers API

  10. @gunnarmorling | @aalmiray #Layrry Hello, Layrry! An API and Launcher

    for Modularized Java Applications
  11. @gunnarmorling | @aalmiray #Layrry Hello, Layrry!

  12. @gunnarmorling | @aalmiray #Layrry Layrry JPMS © Christoper Michel https://flic.kr/p/UMtHv5

    (CC BY 2.0)
  13. @gunnarmorling | @aalmiray #Layrry Ready-Made Launcher layrry-launcher-<version>-all.jar \ —layers-config layers.yml

  14. @gunnarmorling | @aalmiray #Layrry Parameterization

  15. @gunnarmorling | @aalmiray #Layrry Built-in Template Support layrry-launcher-<version>-all.jar \ —layers-config

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

    —properties versions.properties
  17. @gunnarmorling | @aalmiray #Layrry Local Repositories © Andres Almiray (CC

    BY 2.0)
  18. @gunnarmorling | @aalmiray #Layrry Local Repositories • Artifacts can be

    organized in a local repository that does not require remote resolution • Two layouts currently supported
  19. @gunnarmorling | @aalmiray #Layrry Local Repositories

  20. @gunnarmorling | @aalmiray #Layrry Local Repositories

  21. @gunnarmorling | @aalmiray #Layrry Plug-in Architectures © Justin Taylor https://flic.kr/p/4fQz9t

    (CC BY 2.0)
  22. @gunnarmorling | @aalmiray #Layrry Plug-in Architectures Can dynamically add (and

    remove) layers at runtime
  23. @gunnarmorling | @aalmiray #Layrry Plug-in Architectures

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

    2.0) Demo
  25. @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
  26. @gunnarmorling | @aalmiray #Layrry

  27. @gunnarmorling | @aalmiray #Layrry

  28. @gunnarmorling | @aalmiray #Layrry

  29. @gunnarmorling | @aalmiray #Layrry

  30. @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?!
  31. @gunnarmorling | @aalmiray #Layrry Resources Source code https://github.com/moditect/layrry https://github.com/moditect/layrry-examples

  32. @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/
  33. @gunnarmorling | @aalmiray #Layrry Q & A

  34. @gunnarmorling | @aalmiray #Layrry Demo

  35. @gunnarmorling | @aalmiray #Layrry JavaFX Demo