The general problem: I have an open-source desktop app for which I would like to have proprietary or OSS plug-in modules. The idea is that a client could download the OSS framework, and then buy the module. How does the framework find the module and run it? Is there a standard way to do a plug-in architecture? My initial idea (suggestions welcome) is to have the module as a zip (or jar file) containing the module's class files (in a jar), help files (in a jar), native executables, config data, button images, etc. Then the framework could find the zip file, unzip it, and then load the buttons, add the module to the menu, etc., and run it when called. Do I need a custom ClassLoader for this? How does the classpath work? Is this plausible/possible? Does someone know how Eclipse or jEdit does this? Any pointers would be greatly appreciated.
It's definitely possible. Check out the source code for JBoss 3.0 ( www.jboss.org ) as they have plug-in capabilities. For example, if you create a new bean (a jar file containing all XML, .Class, etc files) in to the user's app folder, it will see something new has been "installed" and will load everything as it needs.
Robert is right here. You'll definitely want your modules to be JavaBeans or contain many JavaBeans. That way you can use Introspection to discover the properties, etc. Of course using some sort of XML deployment file would also be helpful. Michael Morris
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher