osgi / bugzilla-archive

Archive of OSGi Alliance Specification Bugzilla bugs. The Specification Bugzilla system was decommissioned with the move to GitHub. The issues in this repository are imported from the Specification Bugzilla system for archival purposes.
0 stars 1 forks source link

[ds] Mention that a provided service type must be a super-type of the component's implementation class #742

Closed bjhargrave closed 15 years ago

bjhargrave commented 15 years ago

Original bug ID: BZ#843 From: Simon Archer <sarcher@us.ibm.com> Reported version: R4 V4.2

bjhargrave commented 15 years ago

Comment author: Simon Archer <sarcher@us.ibm.com>

Section 112.4.6 discusses the component's element and its nested elements, but it neglects to mention that a provided service must be a super-type of the component's implementation class.

// 112.4.6

"The service element must have one or more provide elements that define the service interfaces. The provide element has a single attribute:

The description of the "interface" attribute should mention the constraint on the type, for example:

"The interface must be a super-type of the component's implementation class."

Of course the attribute's value can also be the component's implementation class, but I don't think we need to mention that since, as the spec says, it is not a good practice to provide a class.

This enhancement will compliment what is said in section 5.2.3, Registering Services:

"The names of the service interfaces under which a bundle wants to register its service are provided as arguments to the registerService methods. The Framework must ensure that the service object actually is an instance of each specified service interfaces, unless the object is a Service Factory. ... To perform this check, the Framework must load the Class object for each specified service interface from either the bundle or a shared package. For each Class object, Class.isInstance must be called and return true on the Class object with the service object as the argument."

Of course, with DS the runtime check is NOT performed at service registration time, but rather postponed until the component's implementation class is loaded, which unless the component is "immediate", will only happen when the service is acquired from the service registry. It might be worth mentioning this also.

bjhargrave commented 15 years ago

Comment author: @bjhargrave

CPEG call: Assign to BJ to update spec.

bjhargrave commented 15 years ago

Comment author: @bjhargrave

Updated spec in r6455.

112.4.4. already says: If the component description specifies a service, the class must implement all interfaces that are provided by the service.

I updated 112.4.6 to add the following: The component implementation class must implement all the specified service interfaces.