Skip to content

seumoose/pluggable-extensions

Repository files navigation

Pluggable Extensions

Playground repository for experimenting with multi-module Maven setup and the ServiceLoader class in Java.

Table of Contents

About

A proof-of-concept project that uses Java's ServiceLoader to dynamically discover and register plugin implementations at runtime — no hardcoded references required. Application entry point is ApplicationLauncher.java.

Plugins are grouped into families, each representing a type of capability (e.g. a weather plugin family). A family can have multiple variants, each configured independently to target different endpoints, retry limits, etc. At startup, variant configuration files are read from disk, merged with per-family defaults, and used to initialise each plugin instance.

Prerequisites

Optional version managers

This project includes version files for jenv (.java-version) and mvnvm (mvnvm.properties). Both can be installed via Homebrew:

brew install jenv mvnvm

jenv requires additional shell configuration, after which the installed JDK can be registered with:

jenv add /opt/homebrew/opt/openjdk@23

Configuration

The application reads plugin configuration files from a root directory. The path is resolved in order of precedence:

  1. JVM system property-DCONFIGURATION_ROOT_PATH=<path>
  2. Environment variableCONFIGURATION_ROOT_PATH=<path>
  3. Default~/config

The path must point to an existing directory. Each plugin implementation (family) has its own subdirectory containing a defaults.json (shared base values) file and one or more variant files that are merged on top of the default plugin configuration values when read in. An example of such can be found in the Extension A defaults.

Building

From the project root:

mvn package

This produces a thin jar for the launcher along with all dependency jars in launcher/target/lib/.

Running

CLI

java -DCONFIGURATION_ROOT_PATH="$(pwd)/config" -jar launcher/target/launcher-1.0-SNAPSHOT.jar

VS Code

The launch configuration sets CONFIGURATION_ROOT_PATH to the workspace config/ directory. Open the Run and Debug panel (⇧⌘D), select Java Application, and press F5.

About

Playground repository for experimenting around with multi-modile Maven stup and the ServiceLoader class in Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages