PluginManager multiple instances

113 views
Skip to first unread message

KrishnaG

unread,
Jun 14, 2013, 4:30:56 PM6/14/13
to js...@googlegroups.com

Hi, 

Its very good & simple framework to start with for scalable plugin frameworks creation. Thanks for the effort.
 
I've noticed one issue while exploring the PluginManager usage. According to JSPF Javadoc for PluginManager, PluginManager should be only one instance for entire application life cycle.
 
 

http://data.xeoh.net/jspf/api/net/xeoh/plugins/base/PluginManager.html  During the lifetime of your application there should only be one PluginManager.  ]

 
But multiple calls to PluginManagerFactory.createPluginManager() can create multiple instances of PluginManagerImpl.
 
PluginManager pm1 = PluginManagerFactory.createPluginManager();
pm1.addPluginsFrom( ClassURI.CLASSPATH );


PluginManager pm2 = PluginManagerFactory.createPluginManager();

// here pm1 != pm2
 
Should we enforce singleton nature to PluginManager instance in PluginManagerFactory?
 
regards,
Krishna
 

KrishnaG

unread,
Jun 17, 2013, 9:13:27 AM6/17/13
to js...@googlegroups.com
Should we have Toolkit.getDefaultToolkit() type implementation in PluginManager/PluginManagerFactory to get the singleton instance of PluginManager?
Message has been deleted

theincre...@gmail.com

unread,
Jan 21, 2015, 8:45:59 PM1/21/15
to js...@googlegroups.com

I have observed the same behaviour. At startup of an application I create an instance and load plugins from a directory:

    PluginManager pm = PluginManagerFactory.createPluginManager();
    pm.addPluginsFrom( new File( "./plugins" ).toURI() );

I use a library that supports plugins of a given type. However, in this library the plugins loaded by the main application are not existent. Comparing the pluginManager-objects I found out, that they are different.

First, I would consider this as a bug because it is opposite behaviour than described in the documentation.

Second, if this is not a bug, what is the expected way to deal with this? Just have more instances and load plugins twice? Can this introduce severe problems? I use the plugins not only in the library, but also in the main application.
Reply all
Reply to author
Forward
0 new messages