powered by Jive Software

Communication between plugins

I’m trying to find out the easier way to communicate between plugins.

My problem is that I have two plugins, both are using the same dependency. but it looks that each plugin uses the dependency in a separate process isolating memory regions from each other.

I know that there are multiple ways to connect plugins to each others e.g., using IPC mechanism or even using IQHandlers. but it is better to find any method in openfire API to perform this.

thanks in advance


I don’t think there’s such an API.
Each plugin is isolated and uses its own Classloader.

You can grab the class loader of the “other” plugin, and use introspection to call the appropriate method.

Something like

final PluginManager pluginManager = XMPPServer.getInstance().getPluginManager()
final Plugin plugin = pluginManager.getPlugin("the-other-plugin");
final PluginClassLoader pluginClassLoader = pluginManager.getPluginClassloader(plugin);
final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
try {
    // Do something using the other plugins class loader
} finally {

1 Like

For each plugin, you can define a “parent plugin”, by adding an element named parentPlugin in the plugin.xml. The value of that element should be the name of the parent plugin (given as “foo” for the “foo.jar” plugin). When a plugin has a parent plugin, the parent plugin’s class loader will be used instead of creating a new class loader. This lets plugins work together more closely. A child plugin will not function without its parent present.

1 Like