Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 249852

Summary: [ds] Reference service's target cannot be specified by a property
Product: [Eclipse Project] Equinox Reporter: Simon Archer <sja.eclipse>
Component: CompendiumAssignee: Stoyan Boshev <s.boshev>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: caniszczyk, hargrave, s.boshev, tjwatson
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Simon Archer CLA 2008-10-06 14:39:09 EDT
The Equinox implementation of DS does not allow a Target Property to be set using a <property> or <properties> element.  Consider the following component XML declaration:

 <?xml version="1.0" encoding="UTF-8"?>
  <component name="my.component">
    <implementation class="my.Component"/>
    <reference
      name="log"
      interface="org.osgi.service.log.LogService"
      target="(size>=100)"/>
  </component>

The following alternative, where the <reference> element's target attribute is omitted, is currently NOT handled:

 <?xml version="1.0" encoding="UTF-8"?>
  <component name="my.component">
    <implementation class="my.Component"/>
    <reference
      name="log"
      interface="org.osgi.service.log.LogService"/>
    <property name="log.target" value="(size>=100)"/>
  </component>

This approach is not as crazy as you might think, especially when you consider that a <properties> element could be used instead of a <property> element to allow the "log" referenced service's target to be stored in a properties file rather than in the component's XML description.

The following should also work, since it simply follows the rule that later property declarations override earlier property declarations.

 <?xml version="1.0" encoding="UTF-8"?>
  <component name="my.component">
    <implementation class="my.Component"/>
    <reference
      name="log"
      interface="org.osgi.service.log.LogService"
      target="(size>=100)"/>
    <property name="log.target" value="(size>=500)"/>
  </component>

Today, this case results in the <property> being quietly ignored by the SCR. Again, the <property> element could have been replaced by a <properties> element.
Comment 1 BJ Hargrave CLA 2008-10-06 15:27:09 EDT
Good description Simon.

In short, the target attribute of the reference element is a shorthand for a property element specifying the target property.

The target property for a reference can come from the reference's target attribute, a property element, a properties file referenced by a properties element or a Configuration.
Comment 2 Stoyan Boshev CLA 2008-11-05 09:15:25 EST
Simon, which was the version of DS you were using? Was it M2?
I think this is already fixed in M3. 

This bug seems to be duplicate of bug #246757
Comment 3 Simon Archer CLA 2008-11-05 09:32:50 EST
I was using Eclipse 3.5M2, so yes this could be a duplicate of 246757. Let's assume that it is a duplicate and I'll re-test using 3.5M3.  Thanks Stoyan.

*** This bug has been marked as a duplicate of bug 246757 ***