HeadlinesBriefing favicon HeadlinesBriefing.com

JExten: Java Plugin Framework with JPMS

DEV Community •
×

Java developers often need to let users add functionality without recompiling the core application, typically starting with `java.util.ServiceLoader`. However, as applications grow, they encounter Classpath Hell, a situation where conflicting library versions cause runtime exceptions. JExten addresses this by leveraging Java's JPMS (Java Platform Module System), which allows for isolated module layers. This enables plugins to define their own dependencies without interfering with the host application or other plugins.

Introduced in Java 9, JPMS offers strong encapsulation and explicit dependency graphs. JExten uses this to create isolated "layers" of modules, ensuring that plugins can coexist even if they rely on different versions of the same library. This is crucial for maintaining application stability and avoiding the pitfalls of Classpath Hell.

JExten's architecture is divided into two main managers: the PluginManager and the ExtensionManager. The PluginManager handles raw artifacts and ensures integrity, while the ExtensionManager manages the lifecycle and dependency injection of extensions. This separation of concerns makes JExten both powerful and user-friendly, providing a modern solution for Java plugin development.

For developers, JExten offers a lightweight, annotation-driven approach to plugin development. It simplifies the process of creating and managing extensions, making it easier to build extensible Java applications. By focusing on the 80% use case, JExten provides a "lite" version of OSGi, offering isolation and dependency management without the complexity.