Access Java API from another Plugin

Hi All,

I’m currently trying to implement an extension point in our plugin from another plugin (Portfolio) using the Java API. With the help of a few articles and posts here it worked well at first, but things got complicated when we take the plugin lifecycle into account. (Install / Uninstall / Upgrading of plugins)

There are a few cases where the Spring Beans will no longer work for this API and even “ComponentAccessor.getOSGiComponentInstanceOfType()” will return a null even when portfolio is installed.

Currently I can’t figure out a way to implement a stable connection to the Java API of another plugin, which gives me a strong headache and frustration.
Is there a different approach to solve it than using Spring Beans / ComponentAccessor or am I wasting my time to solve something that can’t be resolved?

I tried the following solutions:

1 Like

After some more try and error, I gained the following insight:
Java Reflections seems the only stable way to implement a optional API connection to another plugin.

The Beans/dependencies are only resolved when you install a plugin. As a result if your plugin is installed before the optional dependency it will only work if you reinstall your plugin or restart the system. The related exception is NoClassDefFoundError.
Keep in mind that reinstalling (update?) the optional plugin may result in the same error.