• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class loading and plugin system  RSS feed

 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came up with a great way of making an app which could load plugins at run time. Unfortunately, it was only as great as my understanding of the problem at the time. Here is what I do -

The idea I had was to create an interface, IGPPlugin, that each plugin would implement. I would make a program that would run and go into a plugins directory and load any plugins it found there. I wanted to have a file structure like this -
myprogram
plugins/plugin1
plugins/anotherplugin
If I jar my application up, it will find the plugin directory, but then won't instantiate each plugin. If I leave it un-jarred, things are ok.
The other issue is with innerclasses. I had wanted to make this nice neat directory with each file/class being a plugin. The problem is that a gui is involved, which means some type of innerclass and more class files. That is why I had to do the simple check in the above code for the $, as innerclasses will compile with that in the filename.
Ok, the meat of the question is this - Does anyone have any solutions/ideas on a convenient way for me to make a 'nice' distributable that other developers can just drop plugins they or others develop into a directory?
Something like this maybe -
myprogram.jar
plugins/plugin1.jar
plugins/anotherplugin.jar
All ideas valued!
Regards!
 
rom chatterjee
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK Im not sure if this will be of much help, but jedit is an open source editor that is stable, widely used and handles plugins. The source code is avialable at sourceforge.
Might be a good place to start investigating..
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into extending ClassLoader and overriding findClass() to look in your plugin directories. I've never done this, but have been thinking about trying it the last couple days. So let me know what you find!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!