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 a开发者_如何转开发ware 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?
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 are looking for a very nice, light and very functional plugin framework, have a look at Java Simple Plugin Framework. I have made extensive use of this and it works great.
Using Spring's autowiring, you have to consider the implications around it. eg. you can only autowire Spring Beans etc etc.
精彩评论