Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plug-in architecture: custom ClassLoader?

 
Glenn Murray
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic