0

I have a requirement to load dynamic modules on a Spring Boot Microservice. i.e Assume I have a MicroService called ProductService that will create different kind of products. And assume that I want to dynamically add products so there I use OSGI product modules.

So if I add ProductXYZ as a OSGI module and how can I call a method on that module via Spring boot REST API. i.e /products/id/description?name=ProductXYZ

Here the issue is, in Spring Boot (even Spring web MVC) these rest calls are handle in the controller. And to get description of ProductXYZ I should create an object of ProductXYZ in the controller. But when coding the controller class it is impossible to call "new ProductXYZ()" as we don't have ProductXYZ when coding controller. We have ProductXYZ in later after we add osgi ProductXYZ module.

Thanks.

lsc
  • 681
  • 3
  • 8
  • 26
  • Typically in Rest design you would have a controller per product unless every product was identical. Is there a reason you just don't want to create a separate rest service for each product? If every product is the same why not just have a product name and id field? – Matthew Fontana Jun 01 '16 at 15:20
  • hmm, I don't have much differences between products. In class level some method implementations will differ. i.e there can be few methods that I need to override. So those methods will implement the specific behaviors for ProductXYZ. So in that case I don't think we need separate rest services for each product. – lsc Jun 01 '16 at 16:48
  • Is there a reason you can't just add those implementations over the lifecycle of the product? Why do you need runtime lookups? – Matthew Fontana Jun 01 '16 at 17:58
  • Yes. Good question. Dynamically adding features at runtime does not match very well with the whole microservice lifecycle. Typical toolings basically treat each service as more or less immutable. – Christian Schneider Jun 02 '16 at 06:42

0 Answers0