Maybe not the appropriate forum to ask, but I suspect there are a bunch of power users in the group. My company has used activators for quite some time, instead of annotations, due to a perceived inability for the annotations to fit our needs.
I have cornered the use case that is reported to be the challenge. We have services that are both aspects on services by their interfaces and also implement another (common) interface which are whiteboarded in elsewhere. The plumbing to get that to work would look like…
@AspectService(ranking = 10, service = AimEncryptionKeyService.class)
@Component(provides = EntitySynchronizer.class)
… however it seems as if these two annotations are not intended to be used as the same time. Whichever one is first is applied and the second is ignored. Is anyone aware of a workaround to get this scenario to work?
FWIU @AspectService comes from Apache Dependency Manager (DM) which is not related to @Component from Declarative Services (DS) specification.
The reason you probably find you are using BundleActivator a lot is because Apache DM is a component framework that bootstraps its component creation off the BundleActivator lifecycle.
This sadly cannot be combined with DS.
A given bundle typically uses either DM or DS, not both at the same time.
HTH clarify things,
Thanks for the response. I definitely left room for interpretation in my question.
The annotations I am using are of the org.apache.felix.dm.annotation.api variety consumed by org.apache.felix.dependencymanager.runtime. I know I have seen at least 2 different implementations of a @Component annotation which certainly has added to my confusion ramping up on this. I probably need to find a Felix specific forum to post in.
Ok got it!
However, even if @Component is the DM one, DM has an imperative bootstrapping model (as opposed to being fully declarative i.e. “bundle extender” like DS is) where the bundle using DM must contain a Bundle Activator that extends from a DM base class (DependencyActivatorBase) which then does all the component processing. Components themselves, I understand, can be purely declarative (using annotations as you’ve shown) but the activator is still required. This gives DM the visibility into the internals of the bundle.
I don’t pretend to know the details of how any of this works. But I have services being created in bundles that don’t have activators. Perhaps that is the magic that
in my bnd files provides?
Probably! I’d check the produced bundle to see what is in the manifest (see if it contains a Bundle-Activator header)! Maybe that plugin instruments the bundle rather than forcing you to write the Activator.
Hey, interesting. I think that DM may have learned to be fully declarative because apparently it generates a
META-INF/dependencymanager/ dir with some descriptors. So maybe it has evolved into a “bundle extender” pattern.
Anyway, yeah, the Felix list would be the place to discuss this in more detail