I would say that OSGi is something you should consider. I don't have expertise in the area but you can find examples and descriptions in stackoverflow and other online resources.
What does OSGi solve?
Trouble understanding the whole OSGi web eco system
The Introduction to OSGi tutorial uses Apache Felix and Apache Karaf and gives a seemingly straightforward tutorial on creating service bundles. From the tutorial:
The Open Service Gateway Initiative is a specification defining a Java-based component system. It’s currently managed by the OSGi Alliance, and its first version dates back to 1999. Since then, it has proved to be a great standard for component systems, and it’s widely used nowadays. The Eclipse IDE, for instance, is an OSGi-based application.
A seemingly more sophisticated tutorial could be OSGi Modularity - Tutorial
The ServiceLoader provides A simple service-provider loading facility.
but looks way to simplified for your needs. It works will for spring-boot but it does not seem to be meant to enterprise applications. A simple example of it is like this:
The Framework
of your application:
public class FrameworkClass {
public static void main(String[] args) {
new FrameworkClass().run();
}
private void run() {
ServiceLoader<IFrameworkModule> modules = ServiceLoader.load(IFrameworkModule.class);
modules.forEach(IFrameworkModule::initialize);
modules.forEach(IFrameworkModule::execute);
}
}
An interface that service modules implement:
public interface IFrameworkModule {
public void initialize();
public void execute();
}
A module - in a separate jar - for the application
public class Module1 implements IFrameworkModule {
@Override
public void initialize() {
System.out.println("initialize module1");
}
@Override
public void execute() {
System.out.println("execute module1");
}
}
which needs a framework.IFrameworkModule
file in the META-INF/services
folder
fmodule.Module1
But considering the complexity of your application I think it makes more sense to go with OSGi.