addPluginsFrom(...) is not finding my plugin

188 views
Skip to first unread message

galliv...@gmail.com

unread,
Oct 24, 2012, 6:28:23 PM10/24/12
to js...@googlegroups.com
First, thank you for this library. I have it up and working (minus this issue) in under 5 minutes.

My issue is regarding loading a custom plugin. I have the following relevant classes:

IPerson (interface which extends Plugin)
Person (class which inherits IPerson and uses the @PluginImplementation annotation)
PluginLoader (class which has a static variable PluginManager and the function:

public static List<IPerson> getPeoplePlugins() {
    PluginManagerUtil util = new PluginManagerUtil(pluginManager);
    System.out.println(util.getPlugins(IPerson.class) + " -- " + util.getPlugins());
    // ...
}

Note: I've also added the plugins using pluginManager.addPluginsFrom(New File(PLUGIN_DIR).toURI());

However, what is outputted is: "5 -- 0" meaning it found 5 Plugins but 0 of the IPerson variant. The Plugins it found are:

>>> Class Report <<<

>>> Object Report <<<
    net.xeoh.plugins.base.impl.PluginInformationImpl@3a56860b (status:'ACTIVE')
    net.xeoh.plugins.base.impl.PluginManagerImpl@360dc67e (status:'ACTIVE')
    net.xeoh.plugins.base.impl.PluginConfigurationImpl@7f712b3a (status:'ACTIVE')
    net.xeoh.plugins.informationbroker.impl.InformationBrokerImpl@527736bd (status:'ACTIVE')
    net.xeoh.plugins.diagnosis.local.impl.DiagnosisImpl@67a5a19 (status:'ACTIVE')

Is there anything I am missing / something to do with my static function?

galliv...@gmail.com

unread,
Oct 24, 2012, 6:58:58 PM10/24/12
to js...@googlegroups.com, galliv...@gmail.com
I seem to have fixed by problem by using:

addPluginsFrom(new ClassURI(Person.class).toURI());

So when I add a specific .class, I can't specify its interface?

galliv...@gmail.com

unread,
Oct 24, 2012, 6:59:40 PM10/24/12
to js...@googlegroups.com, galliv...@gmail.com
I apologize, I meant to say *directory instead of interface.

Ralf Biedert

unread,
Oct 26, 2012, 2:32:37 AM10/26/12
to js...@googlegroups.com, galliv...@gmail.com

Hi,

addPluginsFrom() needs to "see" what is to be added, and where that resides. This can either be an implementing class (in which case it implicitly is / must be on the classpath already), or a path to some JARs / classes. 

When you add an interface only, JSPF won't know anything about if and where an implementing class might be. 

Cheers,
Ralf
Message has been deleted

galliv...@gmail.com

unread,
Oct 29, 2012, 2:17:46 PM10/29/12
to js...@googlegroups.com, galliv...@gmail.com
Thanks Ralf, that makes sense.

ponniv...@gmail.com

unread,
Aug 4, 2015, 8:37:10 AM8/4/15
to jspf, galliv...@gmail.com
Hi Guys,

I have similar issue and needing a solution urgently since I am running on time. I implemented JSPF with same as above mentioned code but my plugin is not loaded. I use plugins directory wherein my plugin jars reside. My plugin interface i.e. the one that implements Plugin resides with the Main project. When I compile the project in NetBeans using maven, I dont see any errors but just the plugin is not loaded and I get a NULL reference to the following code. Please help

AppPlugin appplugin = Application.getPluginManager().getPlugin(AppPlugin.class);

I load plugins using

pluginManager = PluginManagerFactory.createPluginManager();
pluginManager.addPluginsFrom(new File("plugins/").toURI(), new OptionReportAfter());

Output is:

>>> Class Report <<<

>>> Object Report <<<
    net.xeoh.plugins.base.impl.PluginManagerImpl@7e8bed1c (status:'ACTIVE')
    net.xeoh.plugins.base.impl.PluginConfigurationImpl@3315a56d (status:'ACTIVE')
    net.xeoh.plugins.base.impl.PluginInformationImpl@42fbc1f7 (status:'ACTIVE')
    net.xeoh.plugins.informationbroker.impl.InformationBrokerImpl@66a71273 (status:'ACTIVE')
    net.xeoh.plugins.diagnosis.local.impl.DiagnosisImpl@1e7b617c (status:'ACTIVE')

No of plugins:[net.xeoh.plugins.base.impl.PluginManagerImpl@7e8bed1c, net.xeoh.plugins.base.impl.PluginConfigurationImpl@3315a56d, net.xeoh.plugins.base.impl.PluginInformationImpl@42fbc1f7, net.xeoh.plugins.informationbroker.impl.InformationBrokerImpl@66a71273, net.xeoh.plugins.diagnosis.local.impl.DiagnosisImpl@1e7b617c]
Message has been deleted

danilo ruggeri

unread,
Aug 8, 2015, 6:29:39 AM8/8/15
to jspf, galliv...@gmail.com, ponniv...@gmail.com
Try to change :
pluginManager.addPluginsFrom(
new File("plugins/").toURI()

to:
 pluginManager.addPluginsFrom(ClassURI.CLASSPATH);

Worked for me, i had also the "new OptionReportAfter()" call printing "Active", but that was wrong...

Ponnivalavan Chinnugoundar

unread,
Aug 10, 2015, 2:20:27 AM8/10/15
to danilo ruggeri, jspf, galliv...@gmail.com
Thanks..got it working after I changed the way the plugin classes are packaged
Reply all
Reply to author
Forward
0 new messages