Faron

I'm pretty sure that while DS supports the service factory concept, your 
component implementation class does not need to implement 
org.osgi.framework.ServiceFactory and MUST implement each of its provided 
service interfaces.  Please give that a try.

Alternatively, please repost to the mailing list quoting the sections of 
the OSGi spec that say that the component's implementation class must 
implement org.osgi.framework.ServiceFactory.

Thanks

Simon




"Dutton, Faron G" <[email protected]> 
Sent by: [email protected]
01/25/2009 01:31 PM
Please respond to
Equinox development mailing list <[email protected]>


To
"[email protected]" <[email protected]>
cc

Subject
[equinox-dev] [DS] servicefactory=true






I am using Eclipse 3.4.1 with org.eclipse.equinox.ds 1.0.0 and I have the 
following declarative service registered as a service factory.

<component name="unique.component.name">
  <implementation class="sample.ServiceFactory"/>
  <service servicefactory="true">
    <provide interface="sample.ServiceInterface"/>
  </service>
</component>

The class sample.ServiceFactory implements 
org.osgi.framework.ServiceFactory instead of sample.ServiceInterface. When 
Equinox parses the XML, it creates an instance of FactoryReg instead of 
ServiceReg. When time comes to actually instantiate an instance of 
sample.ServiceInterface, I expected FactoryReg to create an instance of 
sample.ServiceFactory then invoke the getService(Bundle, 
ServiceRegistration) method of sample.ServiceFactory, which would create 
the service object. My understanding of the OSGi spec confirms this. 
FactoryReg, instead, creates and returns an instance of 
sample.ServiceFactory. This causes an java.lang.IllegalArgumentException:
"org.eclipse.equinox.internal.ds.FactoryReg.getService() returned a 
service object that is not an instance of the service class 
sample.ServiceInterface"
in ServiceUse.getService(ServiceUse.java:148).

This appears to be a bug. Am I correct or, if not, what am I doing wrong?

Faron

_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev

_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Reply via email to