I'm afraid this is going to turn out as a real stupid question, but ...

I have declared a class as service:

@org.osgi.service.component.annotations.Component(scope=ServiceScope.SINGLETON)
public class BundleListPortletFactory
    implements PortletFactory<BundleListPortlet> {
...

}

Please ignore that the class name ends in "...Factory". The service is
used to create objects, but these objects aren't OSGi services, so it
has the role of a factory in my application, but it is not an OSGi
service factory.

The generated XML looks fine:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0";
name="org.jgrapes.osgi.portlets.bundles.BundleListPortletFactory">
  <implementation
class="org.jgrapes.osgi.portlets.bundles.BundleListPortletFactory"/>
  <service scope="singleton">
    <provide interface="org.jgrapes.osgi.factory.portlet.PortletFactory"/>
  </service>
</scr:component>

And everything works as expected. But when I retrieve the
ServiceReference for this component from the BundleContext at runtime,
and query the SERVICE_SCOPE property, I get SCOPE_BUNDLE! I cannot
believe that this is a framework error that has been overlooked (I'm
using Apache Felix Declarative Services (org.apache.felix.scr) 2.0.2).
I've also checked that "PortletFactory" does not inherit from
"ServiceFactory" (which -- from my understanding -- would be the
prerequisite for having scope "bundle" in the first place).

Any ideas?



_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to