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

Bug 492717

Summary: [DS] Reference event method "updated" only executed with ServiceReference parameter
Product: [Eclipse Project] Equinox Reporter: Dirk Fauth <dirk.fauth>
Component: CompendiumAssignee: equinox.compendium-inbox <equinox.compendium-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: s.boshev, tjwatson
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Example showing the issue none

Description Dirk Fauth CLA 2016-04-29 07:26:29 EDT
I recently came across the fact that there is an issue with the Equinox DS implementation regarding the reference event methods. The specification says that the following method signatures are supported;

void <method-name>(ServiceReference);
void <method-name>(<parameter-type>);
void <method-name>(<parameter-type>, Map);

But for the updated method only the signature that accepts the ServiceReference parameter is called by the Equinox DS implementation. As far as I understand this doesn't match the specification because the other two method signatures should also be supported.

I also opened a ticket for the DS annotations introduced in Neon: Bug 492645
Comment 1 Thomas Watson CLA 2016-04-29 14:02:51 EDT
Will need a testcase.  The following code seems to check for at least the service object type method:

org.eclipse.equinox.internal.ds.model.ComponentReference.getMethod(ComponentInstanceImpl, Reference, String, ServiceReference)

I don't recall when the Map variant was added to the specification, but it could be later than what is implemented by Equinox DS impl.
Comment 2 Dirk Fauth CLA 2016-04-29 16:25:26 EDT
(In reply to Thomas Watson from comment #1)
> I don't recall when the Map variant was added to the specification, but it
> could be later than what is implemented by Equinox DS impl.

Would be strange. I just checked the 4.2 Spec which contains the Declarative Service Specification 1.1. And there it is already specified. And the bind and unbind methods support it already. It is only the updated method that doesn't work.

I will prepare a small sample so you are able to verify it easily.
Comment 3 Dirk Fauth CLA 2016-04-29 17:28:48 EDT
Created attachment 261384 [details]
Example showing the issue

The attached example contains two small bundle projects. One contains a configurable component, the other Felix shell commands. One command uses the ConfigurationAdmin to set a configuration property, the other command references the configurable component.

The WelcomeCommand contains the "updated" methods that should be triggered in case of configuration changes.

Only the method with the ServiceReference gets triggered. The others not. 

Note that you should test this with only one method uncommented. If you have all methods uncommented always the one with the ServiceReference parameter should be called because of the specified order in the DS spec.

Also note that you need the ConfigurationAdmin to test this. Unfortunately the ConfigurationAdmin bundle is not included in a default Eclipse installation, therefore it needs to be added manually.
Comment 4 Dirk Fauth CLA 2016-04-29 17:54:09 EDT
I forgot to mention, after you start via the launch configuration in the command bundle, you should start with the "welcome" command to activate the component. It should print "Service says: null".
After that execute the "configure xxx" command. Now the modified and the updated methods should be triggered.
If you execute the "welcome" command afterwards, it should print "Service says: xxx".
Comment 5 Stoyan Boshev CLA 2016-05-04 18:56:41 EDT
This is not a bug in the DS implementation.

1. The updated method for references is added in Declarative services specification v1.2. Therefore, you need to use schema v1.2.0 in your component.

2. You need to specify the updated method in your reference. In your testcase you have specified only the bind method.

If you fix (1) and (2) in your testcase, it will work as expected.
Comment 6 Dirk Fauth CLA 2016-05-05 08:18:48 EDT
Thanks for the verification and the hint on the wrong component xml. I can confirm that changing the spec and adding the updated attribute works.

I realized that the issue is in the newly introduced DS annotations added to PDE with Eclipse Neon. The two other signatures are not taken into account on xml generation which leads to the wrong xml file.

I created/updated Bug 492645 for this.