aspose file tools
The moose likes Java in General and the fly likes Class loading and plugin system Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Class loading and plugin system" Watch "Class loading and plugin system" New topic
Author

Class loading and plugin system

Aaron Roberts
Ranch Hand

Joined: Sep 10, 2002
Posts: 174
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

Joined: Dec 11, 2001
Posts: 46
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..


Rom Chatterjee<BR>Sun Certified Java Programmer
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Class loading and plugin system
 
Similar Threads
Dynamically finding classes that implement an interface
Writing Plug-Ins (Not web)
Where should I start from?
Problems implementing plug-ins....!
Use Reflection to "find" classes