File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Plug-in architecture: custom ClassLoader? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Plug-in architecture: custom ClassLoader?" Watch "Plug-in architecture: custom ClassLoader?" New topic
Author

Plug-in architecture: custom ClassLoader?

Glenn Murray
Ranch Hand

Joined: Dec 07, 2001
Posts: 74
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.


Glenn Murray
Author of Yo Soy Una Vaca De Hoy
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
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.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Plug-in architecture: custom ClassLoader?