V
VisionSet
My app uses plugins. Plugins are written to implement an interface.
What is the normal way to specify the package with a plugin like this?
I could have the app jar along side a directory for the plugins
myDir/myApp.jar
myDir/plugins/PluginA.class
myDir/plugins/PluginB.class
then just use the default package for the plugins and search that directory
doing Class.forName and checking the class does implement the correct
interface.
Otherwise what package would be logical? A client programmer writes the
plugin and shouldn't add to the existing package. And I thought the JLS
said these days that packages must be used.
Another related query:
If the plugin class that implements the interface requires an object
reference that is created by the system, is it okay to have the interface
specify a setMyObjectINeedPluginToHaveAccessTo() method?
Just seems a bit wierd. Though I realise I could have an abstract class
that does that bit.
What is the normal way to specify the package with a plugin like this?
I could have the app jar along side a directory for the plugins
myDir/myApp.jar
myDir/plugins/PluginA.class
myDir/plugins/PluginB.class
then just use the default package for the plugins and search that directory
doing Class.forName and checking the class does implement the correct
interface.
Otherwise what package would be logical? A client programmer writes the
plugin and shouldn't add to the existing package. And I thought the JLS
said these days that packages must be used.
Another related query:
If the plugin class that implements the interface requires an object
reference that is created by the system, is it okay to have the interface
specify a setMyObjectINeedPluginToHaveAccessTo() method?
Just seems a bit wierd. Though I realise I could have an abstract class
that does that bit.