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

[Metatype annotations] $ as pid/factoryPid to indicate id #2785

Closed bjhargrave closed 7 years ago

bjhargrave commented 8 years ago

Original bug ID: BZ#2917 From: David Jencks <djencks@us.ibm.com> Reported version: R6

bjhargrave commented 8 years ago

Comment author: David Jencks <djencks@us.ibm.com>

I often want to use the annotation fully qualified class name as id (already the default) and pid/factory pid. Similarly to the use of "$" in DS for the component name as pid, it would be convenient to use "$" in @ ObjectClassDefinition pid/factoryPid to indicate the id (defaulting to the FQCN).

It would also be convenient in DS to be able to specify configuration annotations in place of pids, perhaps Class[] configurationClass, where any annotation you specified would have to have only one pid/factory pid specified and you could not use both confgurationClass and configurationPid in the same component. This might be too complex and error prone.

bjhargrave commented 8 years ago

Comment author: @bjhargrave

(In reply to David Jencks from comment BZ#0)

I often want to use the annotation fully qualified class name as id (already the default) and pid/factory pid. Similarly to the use of "$" in DS for the component name as pid, it would be convenient to use "$" in @ ObjectClassDefinition pid/factoryPid to indicate the id (defaulting to the FQCN).

So you are asking that use of "$" as an ObjectClassDefinition.pid or ObjectClassDefinition.factoryPid element value be replaced with the id value of the ObjectClassDefinition? This seems to conflict with the description of id element which states: "The id is not to be confused with a PID which can be specified by the pid or factoryPid element."

It would also be convenient in DS to be able to specify configuration annotations in place of pids, perhaps Class[] configurationClass, where any annotation you specified would have to have only one pid/factory pid specified and you could not use both confgurationClass and configurationPid in the same component. This might be too complex and error prone.

The Designate annotation is the way to connect an ObjectClassDefinition to a Component. This is the most common scenario. If your component needs multiple pids then an element of type Class[] would also be error prone since there is no compile-time way to ensure types annotated with ObjectClassDefinition are used as arguments.

bjhargrave commented 8 years ago

Comment author: David Jencks <djencks@us.ibm.com>

Replacing "$" with the FQCN would be even better than the id.

I discussed the Class[] configurationClass idea with BJ and we decided it is not very clear if a metatype element has to be in the same bundle as the element it references and this should be resolved before proceeding. The Class[] configurationClass could still be useful in case a single configuration is shared between many bundles as well as the multi-pid situation. I would think that bnd could verify that all the classes listed are appropriately annotated.

bjhargrave commented 8 years ago

Comment author: @bjhargrave

CPEG f2f 7 Sep 2016: Agreed to map $ to the FQCN of the type being annotated.

bjhargrave commented 7 years ago

Comment author: @bjhargrave

Both the org.osgi.service.metatype and org.osgi.service.metatype.annotation packages are versioned at 1.3 (we keep the versions in sync as is done for component).

To add a the support to org.osgi.service.metatype.annotation would require bumping its version to 1.4 which would mean we also bump the org.osgi.service.metatype package to 1.4 also. But we are not adding any new function to Metatype runtime. This bug just asks for some tooltime support for the annotations processing.

I think we should wait to add this support until we are otherwise adding some new function to the Metatype spec which would increment the org.osgi.service.metatype package version to 1.4.

At that time, we should also add the @ Requirement(namespace = ExtenderNamespace.EXTENDER_NAMESPACE, ...) annotation to ObjectClassDefinition.

bjhargrave commented 7 years ago

Comment author: @bjhargrave

CPEG call: Agreed to defer until we bump the org.osgi.service.metatype spec to 1.4.

bjhargrave commented 7 years ago

Comment author: @bjhargrave

Bring back to R7 since we must update Metatype spec for new component property type name mapping features ($$ to -, PREFIX, and single-element annotations).

bjhargrave commented 7 years ago

Comment author: @bjhargrave

Fixed by https://osgi.org/gitweb/build.git/commit/3621a8506547ed755138333422cfd7e8963c7ac0