Question: With OSGi 6+ is it possible to reference components based on different implementing interfaces?
Example:
Consider ServiceXImpl implementing aspect ServiceX and AspectA:
import static org.osgi.service.component.annotations.*;
@Component(services = {ServiceX.class, AspectA.class})
class ServiceXImpl implements ServiceX, AspectA {
}
Consider ServiceYImpl implementing aspect ServiceY and AspectB:
import static org.osgi.service.component.annotations.*;
@Component(service = {ServiceY.class, AspectB.class})
class ServiceYImpl implements ServiceY, AspectB {
}
Consider AspectServiceImpl referencing service by different aspects:
@Component
class AspectServiceImpl{
@Reference
volatile List<AspectA> aspectAs;
@Reference
volatile List<AspectB> aspectBs;
}
Note: I'm aware that @Component(services = is illegal. Also having multiple @Component annotations ist not valid. One possible solution I could think of, would be some inheritance hierarchy.
Aucun commentaire:
Enregistrer un commentaire