Implementing plugin architecture in annotation based Spring Boot Application

yuva picture yuva · Oct 2, 2015 · Viewed 12.4k times · Source

I want to implement plugin architecture in Spring Boot application. Let me explain my scenario. I have a main application, which starts the server, manages security, etc. The app is like the root of my final product which will include this root app and other plugins added to it.

Now, the plugins are Spring Boot application themselves, which I may add to the root app by dynamically searching for jars in the specific path or by added them to project dependency as library.

Plugins have their own configurations and are like apps running inside the main root app. Let's say if the root app runs the server, the plugin app may have all the controllers (endpoints), beans etc that provide functionality to my product.

This is the premise, now what I want to know is,

  1. How can I achieve this architecture?
  2. How will the root app communicate with the plugins?
  3. Will they have separate application contexts?
  4. How can I boot and configure child app from the root app?
  5. When the application receives the request from clients how can I route the request to specific controller inside specific plugin considering I may have many plugins.

I am confused about the concept here, and how it can work. Any sort of help is appreciated. If there is some example that anyone can provide, that will be just wonderful.

Answer

Tran Ho picture Tran Ho · Jul 6, 2018

This post was 3 years ago. However, I'd like to answer this for someone who looking for a solution for a similar scenario. It seems that pf4j which is a plugin framework that is suitable for you. Beside supporting native app, it also has spring-pf4j, so you can use it into spring.

URL: https://pf4j.org