This content has been marked as final. Show 2 replies
The standard approach is a "services" file. Say your plugins are characterised by implementing org.widget.MyPluinInterface you create a text file with the path
Each line of this file is a concrete plugin class FQN.
The usual convention of ignoring lines starting with # applies.
Your framework program accesses these files using getResources(). If you use a URLClassLoader to load your plugins, then call getResources() on that ClassLoader.
The framework picks up every such file on the class path (getResources() does this), so you can have mutliple jars or directories with plugin implementations and all the concrete implementations will be picked up.
Unfortunately there's no serive loader in the standard library (though I think there's one in one of the proprietry sun classes), but it's not hard to code.
The service function will be in the new "Mustang" release of java when it comes out:
Message was edited by: