Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing plugin architecture in annotation based Spring Boot Application

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.

like image 322
yuva Avatar asked Oct 02 '15 05:10

yuva


People also ask

What is plugin architecture?

A plug-in is a bundle that adds functionality to an application, called the host application, through some well-defined architecture for extensibility. This allows third-party developers to add functionality to an application without having access to the source code.

What is the architecture of Spring boot application?

Spring Boot uses a hierarchical architecture in which each layer communicates with the layer immediately below or above it ( hierarchical structure).

What are spring boot plugins?

The Spring Boot Maven Plugin provides Spring Boot support in Apache Maven. It allows you to package executable jar or war archives, run Spring Boot applications, generate build information and start your Spring Boot application prior to running integration tests.

What is package for spring boot annotation?

Spring annotations present in the org.springframework.boot.autoconfigure and org.springframework.boot.autoconfigure.condition packages are commonly known as Spring Boot annotations. Some of the annotations that are available in this category are: @SpringBootApplication. @SpringBootConfiguration.


1 Answers

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

like image 98
Tran Ho Avatar answered Sep 22 '22 04:09

Tran Ho