How to implement extensions mechanism in appserver?
I developing the servlet that should work 24/开发者_Python百科7. And I want to create some extensions mechanism: placing new jar in classpath must be detected by the main servlet and some class should loaded (without appserver restart).
Purpose: main servlet recieves events and redirect data to process to loaded classes (extensions). Extensions implements some interface (e.g. IMyExtension
).
Maybe there is way to find all classes that implements particular interface? Or what do you suggest?
A good option for such systems is OSGi. Take a look at http://www.eclipse.org/equinox/ or http://www.springsource.com/products/dmserver for application servers. OSGi lets you dynamically deploy and enable modules without shutting down the server.
Generally, you don't need to find all implementations. Extensions should register themselves on their startup and unregister on stop.
精彩评论