There is an issue with the Apache Felix SCR implementation of OSGi DS

58 views Asked by At

The OSGi DS Specification mentions :

When the service is requested, if the service has the scope attribute set to bundle, SCR must create and activate a unique component configuration for each bundle requesting the service.

In other words, if a component specifies a service with bundle scope, and this service is requested by two different bundles at the same time, then you call the method org.osgi.service.component.runtime.ServiceComponentRuntime.getComponentConfigurationDTOs(ComponentDescriptionDTO), you should get two different ComponentConfigurationDTO.

But based on the Apache Felix implementation org.apache.felix.scr_2.2.6.jar, you can only get one ComponentConfigurationDTO.

I checked the source code and it uses class org.apache.felix.scr.impl.manager.ServiceFactoryComponentManager to manage such component and its field serviceContexts to maintain all the component instances under that component :

// maintain the map of ComponentContext objects created for the
// service instances
private IdentityHashMap<S, ComponentContextImpl<S>> serviceContexts = new IdentityHashMap<>();

Such a code implementation, which makes a single component configuration associated with multiple component instances, it is also inconsistent with the specification

Component Instance - An instance of the component implementation class. A component instance is created when a component configuration is activated and discarded when the component configuration is deactivated. A component instance is associated with exactly one component configuration.

0

There are 0 answers