3

My Spring Boot Application features a content management system. I would like to be able to dynamically load new components without requiring an application restart. An example component may be loading a new video player component or ad component. Each component would likely contain its own controllers and views.

What would the recommended pattern be for this, and what is a good framework to help handle this? Is OSGi an option?

sparkyspider
  • 13,195
  • 10
  • 89
  • 133

1 Answers1

2

I'm afraid there isn't a 100% solution. There's maybe some options; let me highlight the following three:

  1. There are Spring factories, a way to (auto-)configure your beans.

  2. Another interesting approach to go is the way of how Spring Boot handles extensions by itself - by having its own spring-boot-starters, like in this article: https://blog.codecentric.de/en/2014/11/extending-spring-boot-five-steps-writing-spring-boot-starter/, combined with Spring Factories you could

  3. The most plugin-like solution is the spring-plugin-project. However it looks like only loading is supported, some other features like versioning are missing, too. So you probably have to build it by yourself.

So the main problem might be in unloading and updating these things at runtime, which leads me to the final observation:

In general I have the impression that the concept of having a plugin is working a bit against the idea of Spring Boot, as it is designed for microservice architectures. So the added (plugin) functionality probably would rather be a separate microservice (with its own storage) which gets orchestrated by a gateway, here let me highlight the spring-boot-based JHipster project to show the idea of such an architecture.

halfer
  • 19,824
  • 17
  • 99
  • 186
gtonic
  • 2,295
  • 1
  • 24
  • 32