Spring MVC Plugin Architecture

I am new to JavaEE, but have some experience with ASP.NET MVC. With ASP.NET MVC, I know that we can create a plug-in architecture with an ASP.NET MVC web application so that you can create a dll with an MVC structure and put it in an existing ASP.NET MVC web application so that it works without compiling the network attachment. http://www.wynia.org/wordpress/2008/12/05/aspnet-mvc-plugins/

I wonder if such an architecture is possible with Spring MVC. For example, when I make a file with a bank (or war) with an MVC structure and put it into an existing Spring MVC web application, it should work without recompiling the web application. If possible, how can I achieve this? Any link would be appreciated.

+6
source share
2 answers

This is possible without recompiling, but probably not without restarting. You can create a .jar that you enter in the WEB-INF / lib directory. Using class scanning, you can deploy your new controllers at startup. You can completely skip the view and directly output data to ServletResponse. Providing a presentation from a bank may or may not be possible, I do not know.

+2
source

It looks like you want to find "hotdeploy".

What you are asking for is not a Spring function, but rather a JVM function and an application server. The application server can see that your classes have actually changed and with some clever ClassLoader cheat, it can load new versions into the runinng JVM as they become available. Java was not really designed to work in such a way that there are some problems (ClassLoader, memory leak, hotdeploy - good keywords to find more about potential problems and possible solutions). I would not recommend this for use in production, but it can be useful during development.

Since this is a feature of application servers, the actual data depends on the specific application server and is explained in it by the documentation.

If you just want some kind of magic plugin and not the actual hotdeploy, there are other things you could do. Custom ClassLoader can load classes from any source (file, network, database ..) that you want, and then you can create instances and use them with reflection. (This is what happens when you deploy a war with Tomcat / JBoss or something else). Access and dynamic reloading of non-class resources in jar / war files is easier.

+1
source

Source: https://habr.com/ru/post/894323/


All Articles