I have one OSGi bundle (BundleA) for Sling that I deploy in Felix. This bundle loads initial Sling content and then through an activator executes some operations on this content (sets permissions and sorts nodes). That works well, I build it with the Felix maven-bundle-plugin and I've put a bundle event listener in the activator:
@Override
public void bundleChanged(BundleEvent event) {
if (BundleEvent.STARTED == event.getType()) {
logger.info("Bundle A has started");
BundleContext context = event.getBundle().getBundleContext();
}
}
But I have another bundle (BundleB) that when deployed, somehow triggers BundleA's activator. Consequently, the code is executed again and I don't want that.
I didn't find any documentation about "linked" bundles. But I'm not familiar with Felix/OSGi so I don't really know what to look for. The BundleA has BundleB has a Maven dependency, scope provided, because it uses some Constants from it. Otherwise, I have no idea what could link the two of them.
Any hint about what can trigger another bundle's activator would be really helpful to understand how it works. I can post more code/info if needed. Thank you
EDIT: This is the cycle raising the issue, when using CI
- Deploy BundleB (sling-core): contains an enum class to store constants
- Deploy BundleA (sling-content): loads Sling initial content, and with an activator automatically sets permissions and sort nodes using the Jackrabbit API. This codes uses enums stored in BundleA.
- Re-deploy BundleB (sling-core) because some changes were pushed
- Issue: BundleA also restarts and then re-do permissions and nodes sorting, which I do not want