Using abstract class instead of interface as the base of a plugin?

38 views
Skip to first unread message

Michael Grässlin

unread,
May 14, 2015, 5:49:11 PM5/14/15
to js...@googlegroups.com
Is it somehow possible to use an abstract class instead of an interface when making the base of a plugin?

I need to implement some specific methods to all of my plugins so an abstract class would be the easiest way.

Thanks in advance
- Michael

Michael Grässlin

unread,
May 14, 2015, 6:06:46 PM5/14/15
to js...@googlegroups.com
I just found out how to do it right after posting this. For anyone who needs to know this too, here's the answer:


This is what I used before changing the base to an abstract class:

PluginManager pm = PluginManagerFactory.createPluginManager();
PluginManagerUtil pmu = new PluginManagerUtil(pm);

pm
.addPluginsFrom(new File("Path/to/plugins").toURI());

for(MyPlugin pluginToLoad : pluginManagerUtil.getPlugins(MyPlugin.class) {
   
//Do things with pluginToLoad here...
}



This is what I use now:

PluginManager pm = PluginManagerFactory.createPluginManager();
PluginManagerUtil pmu = new PluginManagerUtil(pm);

pm
.addPluginsFrom(new File("Path/to/plugins").toURI());

for(Plugin plugin : pluginManagerUtil.getPlugins() {
   
if (plugin instanceof MyPlugin) {
       
MyPlugin pluginToLoad = (MyPlugin) plugin;

       
//Do things with pluginToLoad here...
   
}

}

Please tell me if anything I did here is wrong.
For me this worked so I assume that it's correct.
Reply all
Reply to author
Forward
0 new messages