Suppose I have a Java Spring
-based client application, which sends a request to a server and process the response. It uses Command
pattern for the response processing.
Now I would like to discover and load these Commands
in run-time. How would you implement it?
I am aware of "plugin" technologies, such as JPF
and OSGI
but they look as a huge overkill for me. I am thinking about using Spring's
autowiring. Would you recommend it?
Spring Plugin provides a more pragmatic approach to plugin development by providing the core flexibility of having plugin implementations extending a core system's functionality but of course not delivering core OSGi features like dynamic class loading or runtime installation and deployment of 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.
To enable Spring integration, simply include struts2-spring-plugin-x-x-x. jar in your application. The framework enables “autowiring” by default. (Autowiring means to look for objects defined in Spring with the same name as your object property).
The spring-plugin project is probably worth looking at for this need. Unlike JSPF in the accepted answer, spring-plugin is designed specifically for Spring. It touts itself as "The smallest plugin system ever" which might be debatable (I replaced my own mini-framework that was even smaller/lighter) but it's definitely easy to swallow and yet flexible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With