Bug 501950 - [ds] replace Equinox DS implementation with Felix SCR (DS) implementation
Summary: [ds] replace Equinox DS implementation with Felix SCR (DS) implementation
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: 4.7.0 Oxygen   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: Oxygen M5   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on: 510288 511123
Blocks: 510406 510673 510676 510679 510985 511162
  Show dependency tree
 
Reported: 2016-09-21 17:02 EDT by Thomas Watson CLA
Modified: 2017-01-27 04:27 EST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Watson CLA 2016-09-21 17:02:11 EDT
The Equinox implementation of DS has gone dormant now for several releases.  It is implementing an old DS specification (from OSGi R5 I think).

Without a significant contribution from a new contributor or an existing Equinox committer the Equinox DS implementation will remain at its current specification level and will continue to show signs of age.

I suggest we investigate replacing the Equinox implementation with the Felix one.  I know of several products that use Equinox framework with Felix SCR implementation.  It is very stable and in many cases performs better than the Equinox DS implementation.
Comment 1 Dirk Fauth CLA 2016-09-22 04:53:45 EDT
Just as a small hint. I'm sure you are aware of it, but I wanted to mention it as I came across it lately.

Some of the DS related interfaces in package org.osgi.service.component are located in the bundle org.eclipse.osgi.services. But in Felix they are located in the SCR bundle. 

If developers use Require-Bundle org.eclipse.osgi.services (which is the wrong approach of course) they will get a uses-constraint-violation. At least by only taking in the Felix SCR bundle. I recently fixed an issue in Platform UI with regards to that.

I personally think the interfaces should be removed from org.eclipse.osgi.services. But of course that depends on the way it is planned to make use of Felix SCR in Equinox. I just wanted to mention that this could cause issues on the way.
Comment 2 Thomas Watson CLA 2016-09-22 09:12:15 EDT
(In reply to Dirk Fauth from comment #1)
I will be removing the classes from org.eclipse.osgi.services.  That bundle is really bad, wish we never put all these packages in one bundle in the first place.

But to remain backwards compatible I am going to have org.eclipse.osgi.services import the component package AND export the component package with mandatory directive (mandatory:="do-not-import-from-me") but I will not specify the value for the do-not-import-from-me attribute.  This little trick allows require-bundle wires to org.eclipse.osgi.services to get forwarded to the package exported by the provider of the component package which org.eclipse.osgi.services is wired to.  This also prevents any Import-Package wires getting inadvertently wire to the org.eclipse.osgi.services bundle.
Comment 3 Dirk Fauth CLA 2016-10-14 07:41:18 EDT
@Thomas
I just stepped on an issue with Felix SCR 2.0.6. There a dependency to cm is introduced. Surely an issue with Felix SCR as it should be an optional dependency and with 2.0.2 this is correct. But with 2.0.6 that dependency isn't optional.

Just in case you come around a related issue when working on this topic.
Comment 4 Thomas Watson CLA 2016-10-17 08:35:19 EDT
(In reply to Dirk Fauth from comment #3)
> @Thomas
> I just stepped on an issue with Felix SCR 2.0.6. There a dependency to cm is
> introduced. Surely an issue with Felix SCR as it should be an optional
> dependency and with 2.0.2 this is correct. But with 2.0.6 that dependency
> isn't optional.
> 
> Just in case you come around a related issue when working on this topic.

Are you referring to package imports or the dependency on a CM service being registered.  Equinox DS implementation currently has a non-optional Import-Package of the osgi cm package.
Comment 5 Dirk Fauth CLA 2016-10-17 08:57:47 EDT
(In reply to Thomas Watson from comment #4)
> Are you referring to package imports or the dependency on a CM service being
> registered.  Equinox DS implementation currently has a non-optional
> Import-Package of the osgi cm package.

Good question. What I can tell so far is that I am able to have a runtime that only contains Felix SCR (2.0.2) and no CM and it runs fine. Exchanging 2.0.2 with 2.0.6 a NoClassDefFoundError occurs.

https://groups.google.com/forum/#!topic/bndtools-users/U6nOsvmo67o

But probably Equinox DS doesn't run into that because of the org.eclipse.equinox.osgi.services bundle that contains all the interfaces.
Comment 6 Eclipse Genie CLA 2017-01-10 16:02:10 EST
New Gerrit change created: https://git.eclipse.org/r/88414
Comment 8 Eclipse Genie CLA 2017-01-10 16:52:09 EST
New Gerrit change created: https://git.eclipse.org/r/88419
Comment 10 Eclipse Genie CLA 2017-01-17 12:56:08 EST
New Gerrit change created: https://git.eclipse.org/r/88883
Comment 11 Eclipse Genie CLA 2017-01-17 13:32:10 EST
New Gerrit change created: https://git.eclipse.org/r/88887
Comment 14 Eclipse Genie CLA 2017-01-17 17:29:17 EST
New Gerrit change created: https://git.eclipse.org/r/88911
Comment 15 Thomas Watson CLA 2017-01-17 17:34:10 EST
One thing to note on performance.  I did detect a slowdown for startup when using the felix SCR.  I attributed this to two defects in felix SCR for which I have provided fixes to in felix:

https://issues.apache.org/jira/browse/FELIX-5474
https://issues.apache.org/jira/browse/FELIX-5360

Both of these are now fixed and released as part of felix SCR 2.0.8 release.  I have a CQ open to update to this version for Oxygen.
Comment 17 Thomas Watson CLA 2017-01-18 09:03:03 EST
I have released everything to start using felix SCR implementation for DS.  Marking as fixed.  I'll open a follow on bug to update to felix scr 2.0.8.
Comment 18 Thomas Watson CLA 2017-01-18 09:17:41 EST
(In reply to Thomas Watson from comment #17)
> I have released everything to start using felix SCR implementation for DS. 
> Marking as fixed.  I'll open a follow on bug to update to felix scr 2.0.8.

See bug 510635.
Comment 19 Dirk Fauth CLA 2017-01-19 04:02:44 EST
I downloaded the latest Oxygen Integration Build I20170118-2000 and tried to create a new E4 RCP application.

The application does not start and contains several errors:

1. org.apache.felix.scr is missing the the product definition created by the wizard. This is surely a PDE issue and need to be fixed in the wizard there. But that also shows that we can expect regressions for products that are plugin-based. So we need to at least mention this in the N&N

2. Felix SCR requires CM
This seems to be an issue with Felix SCR 2.0.6 [1]. While org.osgi.service.cm is configured as an optional dependency, it seems to be required. Maybe they are able to fix it with 2.0.8 as you plan to upgrade to it because of your performance fixes. The following exception can be seen on startup after adding org.apache.felix.scr to the product definition:

Caused by: java.lang.ClassNotFoundException: org.osgi.service.cm.ConfigurationListener cannot be found by org.apache.felix.scr_2.0.6.v20161206-1638

3. There are several issues regarding unresolved requirements. Probably they are a follow up on this:

!ENTRY org.eclipse.osgi.services 2 0 2017-01-19 09:36:41.055
!MESSAGE Could not resolve module: org.eclipse.osgi.services [5]
  Unresolved requirement: Import-Package: javax.servlet; resolution:="optional"
  Unresolved requirement: Import-Package: javax.servlet.http; resolution:="optional"
  Unresolved requirement: Import-Package: org.osgi.util.function; version="[1.0.0,2.0.0)"

while javax.servlet is optional, it looks like org.osgi.util.function can not be resolved.

And as org.osgi.service.component.annotations and org.osgi.service.event are provided by org.eclipse.osgi.services, a lot of bundles are not able to resolve.

Is some additional bundle missing that contains org.osgi.util.function? Or are we in a intermediate state in the Equinox development where this package is added? IIRC this package contains some functional style code, but I haven't worked with that yet, so I can't say for sure.


[1] https://groups.google.com/forum/#!topic/bndtools-users/U6nOsvmo67o
Comment 20 Dirk Fauth CLA 2017-01-19 04:32:40 EST
I added org.eclipse.osgi.util to the product definition and this seems to solve the dependency issues. But I wonder why org.eclipse.osgi.util has at the same time an

Export-Package: org.osgi.util.function;version="1.0"

aswell as an

Import-Package: org.osgi.util.function; version="[1.0, 1.1)"

Is this intended?

Nevertheless it seems the issues can be solved by adding the following bundles to the product definition:

org.apache.felix.scr
org.eclipse.osgi.util

And because of the dependency to org.eclipse.osgi.util, also the e4.rcp feature needs to be extended to include that bundle.
Comment 21 Dirk Fauth CLA 2017-01-19 07:27:32 EST
The missing bundle in the e4.rcp feature is resolved via Bug 510406

The reported dependency issues in Comment 19 can be resolved by adding the missing bundles to the product configuration.

I created Bug 510676 to modify the PDE wizards to include the missing bundles.
Comment 22 Lars Vogel CLA 2017-01-19 08:09:27 EST
This should be added to the N&N M5 to make users aware of the change.
Comment 23 Thomas Watson CLA 2017-01-19 09:29:24 EST
(In reply to Lars Vogel from comment #22)
> This should be added to the N&N M5 to make users aware of the change.

I'll get the item added to N&N.
Comment 24 Eclipse Genie CLA 2017-01-19 10:08:32 EST
New Gerrit change created: https://git.eclipse.org/r/89113
Comment 26 Markus Keller CLA 2017-01-19 14:27:27 EST
Bug 510673 has been fixed in master, so that clients using org.eclipse.equinox.ds get this property setting for free:

ds.delayed.keepInstances=true

The removal of the 3 interfaces Component, Reference, ScrService in package org.apache.felix.scr was a breaking API change, but this can be discussed in bug 510679.