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

Bug 328653

Summary: Improve equinox service implementation dependencies to be more stand alone
Product: [Eclipse Project] Equinox Reporter: Thomas Watson <tjwatson>
Component: CompendiumAssignee: equinox.compendium-inbox <equinox.compendium-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: hargrave, jeffmcaffer, jwross
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard: stalebug

Description Thomas Watson CLA 2010-10-25 16:30:19 EDT
For most of the OSGi service implementations we provide in equinox the org.osgi.service packages are not packaged with the implementation bundles.  Instead most of them are packaged within the org.eclipse.osgi.services bundle.

This requires means none of our implementation bundles are stand-alone.  They can only resolve if there is an additional bundle installed which exports the org.osgi.service.* package.  It has been suggested that we should consider packaging the org.osgi.service.* packages in our actual implementation bundles.  Then we can export AND import the org.osgi.service.* package from the implementation bundles.  This would allow the export to be substituted with another provider if it is installed (e.g. org.eclipse.osgi.services).

Note that org.eclipse.osgi.services already does export AND import each org.osgi package it contains.  If we did this we would need to take care that the package attributes match up between the existing org.eclipse.osgi.services package exports and org.osgi.service.* packages which we export from the impl bundles.  Otherwise we run the risk of getting multiple versions of the org.osgi.service.* packages available in the system (i.e. not being substituted properly) which can result in service clients not seeing the service implementation.

The overall goal is to make our service implementation bundles as close to stand-alone as possible.  So before we go about doing this work we need to investigate what each of our current implementation bundles require today.

For example, our event admin bundle (org.eclipse.equinox.event) imports the following:

org.eclipse.osgi.framework.eventmgr -> equinox framework or supplemental
 org.eclipse.osgi.util              -> equinox framework or supplemental
 org.osgi.framework                 -> equinox framework
 org.osgi.service.event             -> o.e.osgi.services
 org.osgi.service.log               -> o.e.osgi.services
 org.osgi.util.tracker              -> equinox framework


We could consider packaging org.osgi.service.event in the o.e.equinox.event bundle but we would still need an additional bundle to export org.osgi.service.log package when running on Equinox.

When running on another framework (e.g. felix) you would need at least two bundles (supplement + something exporting org.osgi.service.log) and potentially a third bundle to export org.osgi.util.tracker (note that the latest felix framework actually exports this package, but earlier versions did not).

So what did we gain from this effort?  IMHO Nothing.  Before doing anything we need to evaluate our different bundles and determine if there is anything gained by packaging the OSGi packages we implement in the implementation bundles.  We also need to evaluate if there are some dependencies we can remove to achieve something more close to stand alone.
Comment 1 BJ Hargrave CLA 2010-10-25 17:00:06 EDT
Compendium implementation bundles from Equinox have been criticized for having too many external dependencies (compared with their counter parts from Felix). So much so that some OSGi instructors steer their students to the Felix bundles to simplify the class.

One systemtic difference is in the tooling support used to build these bundles. Felix is built using bnd (in a maven plugin) which makes it very easy for a bundle to be packaged with a private copy of a java package. For example, org.eclipse.osgi.framework.eventmgr. The only value in importing this package is class file sharing at runtime. But there is no functional reason why the equinox.event bundle could not have its own copy to reduce the coupling to the framework/supplemental bundle. Since Eclipse builds with PDE and PDE does not have such functionality, we are limited to simply importing the package and taking the coupling.

One can argue (as Tom does), that the changes requested here do not really add any useful function. But I think they do simplify people using these bundles if we reduce their coupling.
Comment 2 Thomas Watson CLA 2010-10-25 17:06:51 EDT
(In reply to comment #1)
> 
> One can argue (as Tom does), that the changes requested here do not really add
> any useful function. But I think they do simplify people using these bundles if
> we reduce their coupling.

One can argue that our build process is not properly suited for copying packages into multiple bundles (which is true).  But playing devil's advocate makes me question why maintaining a common package used by several bundles in a single bundle is not a good idea?  If we are talking about a single class then I can understand the case to copy it to multiple bundles.  But for more complicated "libraries" it seems sharing the package is a better idea.
Comment 3 BJ Hargrave CLA 2010-10-25 17:19:23 EDT
(In reply to comment #2)
> One can argue that our build process is not properly suited for copying
> packages into multiple bundles (which is true).  But playing devil's advocate
> makes me question why maintaining a common package used by several bundles in a
> single bundle is not a good idea?  If we are talking about a single class then
> I can understand the case to copy it to multiple bundles.  But for more
> complicated "libraries" it seems sharing the package is a better idea.

Sure, for a complicated libraries with several interconnected packages and which may share state you need to have people using the same package. But for packages which are nicely stand alone and have no shared state, you can have multiple copies to reduce coupling. 

Packages such as OSGi service packages can be placed in the bundle implementing the API. This really is not a sharing issue until multiple implementation bundles are installed. And with substitution and matching version constraints, we end up all using the same package. I think the idea of the org.eclipse.osgi.services bundle is a bad idea. It is essentially Eclipse's version of the osgi.cmpn jar which is intended as a compile-time jar and not a runtime bundle.

Packages like org.eclipse.osgi.framework.eventmgr have no functional value in sharing. There is no functional reason why every bundle that uses this package cannot have its own private copy. But since we have no way in the build to have a single copy of the source code be packages as a built package in multiple bundles, we end up putting the package in a single bundle and others import it: increased coupling.
Comment 4 Jeff McAffer CLA 2010-10-26 10:57:03 EDT
I am NOT arguing for the current services bundle.  However, your coupling point is interesting. The real problem with the current services bundle is that it is not cohesive.  Lots of random stuff jammed into one bundle for convenience. From a coupling point of view, your suggestion of putting the API and implementation together seems more "against the OSGi ethos". It tightly couples the supplier of an API to the supplier of the implementation.  If they are both in the same bundle then updating the implementation (and refreshing) causes all those wired to the API to be cycled when really only the users the service should see some service fluctuation.  This could have huge and unnecessary ripples. 

It feels like the motivation for putting them together is to make it easy to deploy just one bundle and get a service working.  I'm all for convenience but introducing that level of runtime/management coupling to facilitate shorter command lines seems counter-productive.  Perhaps we just need better ways of manually installing services.  Then OSGi itself could supply the relevant API bundles, one for each service interface, and everyone can consume them and supply implementations.
Comment 5 BJ Hargrave CLA 2010-10-26 11:35:40 EDT
(In reply to comment #4)
> I am NOT arguing for the current services bundle.  However, your coupling point
> is interesting. The real problem with the current services bundle is that it is
> not cohesive.  Lots of random stuff jammed into one bundle for convenience.

Yes, the services bundle is not cohesive.

> From a coupling point of view, your suggestion of putting the API and
> implementation together seems more "against the OSGi ethos". It tightly couples
> the supplier of an API to the supplier of the implementation.  If they are both
> in the same bundle then updating the implementation (and refreshing) causes all
> those wired to the API to be cycled when really only the users the service
> should see some service fluctuation.  This could have huge and unnecessary
> ripples. 

This is not true. Putting the service API package in the implementation bundle includes using substitutable exports. This way if there are multiple implementation they can share the same package at runtime (assumes constraints, like versions, are met). Also, unless the packages are refreshed, the original exported service API package is still available after update. If there is no change to the service API package, there is no reason to refresh.

> 
> It feels like the motivation for putting them together is to make it easy to
> deploy just one bundle and get a service working.  I'm all for convenience but
> introducing that level of runtime/management coupling to facilitate shorter
> command lines seems counter-productive.  

Feel free to ignore this bug. I am just relaying input from the trenches. But I am seeing the OSGi thought leaders (who are not Eclipse committers) moving to recommend Felix for some of the reasons outlined here. I just want Equinox to be the preferred (or at least equal) choice.

> Perhaps we just need better ways of
> manually installing services.  Then OSGi itself could supply the relevant API
> bundles, one for each service interface, and everyone can consume them and
> supply implementations.

OSGi supplies the source code and compiled class files for the service package. OSGi does not supply them packaged for runtime use. That is for others (like Equinox or Felix) to do. I don't expect this to change at OSGi. But someone can raise the discussion there.
Comment 6 Eclipse Genie CLA 2019-08-27 08:25:33 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.