File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Groovy and the fly likes Dynamically discovering and/or loading plugins at run time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Dynamically discovering and/or loading plugins at run time " Watch "Dynamically discovering and/or loading plugins at run time " New topic
Author

Dynamically discovering and/or loading plugins at run time

Lubos Pochman
Greenhorn

Joined: Jan 20, 2006
Posts: 1
Hi,

is there an easy/documented way to dynamically discover and load Groovy/Grails plugins at application run time similar to OSGi?

I know about using and developing plugins during application development, but I would like to add ability to my application to dynamically load plugins while my application starts.
I do not really care about other OSGi like dynamic plugin loading/unloading of a plugin (bundle) during the lifetime of the application, discovery and loading at application start time
would be sufficient.

Thanks, Lubos Pochman


Lubos Pochman
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
there is this [older] JPF (java plugin framework) project here http://jpf.sourceforge.net/

They define simple interfaces and sample implementations for loading plugins on startup.

Or, if you wanted to do a full custom thing, invent a convention like a plugins/ folder and any .jar file found in that folder is a plugin that is to be loaded on application startup.

You could use the MANIFEST.MF file inside the jar file, or invent your own descriptor, to contain the meta information, such as plugin name, description, version, depends on ohter plugins, so your boot strap method to discover plugins on application startup could use this to try to load them in an order that makes sense, if there are dependencies between plugins.

as far as finding the code from the pluginzs, its likely not to hard to use a URLClassLoader, that works to target classes contained inside the plugin jar files.


Error: Keyboard not attached. Press F1 to continue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically discovering and/or loading plugins at run time
 
Similar Threads
Class loading and plugin system
OSGi and Grails
SWT/Eclipse: Getting Installed Plugins from Eclipse Manage Configuration
OSGi as a Java standard
OSGi Use Cases