Home » Eclipse Projects » Equinox » DS ignores service.ranking?
DS ignores service.ranking? [message #890734] |
Fri, 22 June 2012 19:40  |
Eclipse User |
|
|
|
Scenario: three components
* A1 - component providing service for interface A - no service.ranking specified
* A2 - component providing service for interface A - service.ranking=1
* B - component referencing A (static, 1..1)
Now start the framework... (all three bundles on the same startlevel).
Expected behaviour: Since there are two implementations for A available, I would guess that A2 gets bound to B since it has the higher service.ranking.
Observed behaviour: A1 is assigned to B.
Already tried:
* Explicitely assign service.ranking=0 to A1 (the default value).
No change.
* Put A1 on enabled=false.
This correctly causes B to be bound to A2.
* Change start-level of bundle containing A2 to be lower (sooner) than A1.
This 'fixes' the issue: B now gets bound to A2 instead of A1.
? This is not what I expect !
Looks as if service.ranking is ignored and lowest service PID is being used.
Potentially involved additional settings:
* I added the service.ranking on the component's properties.
I guessed (didn't find it in the doc) that this automatically forwards the service.ranking to the service's properties. Verified it using 'services' on console and it seems to be ok.
* All components are on 'immediate=true' and 'enabled=true'.
Would this 'immediate' cause the DS to assign the first service that it already has available in active bundles? This is not the behaviour that I would expect from reading the spec...
Thanks,
Johan
|
|
| | | |
Re: DS ignores service.ranking? [message #891936 is a reply to message #891598] |
Tue, 26 June 2012 11:57   |
Eclipse User |
|
|
|
Hi all,
I tried today with the new Eclipse Juno, hoping that this would behave differently.
Unfortunately, I don't see a better behaviour.
Anybody who can explain the following console session?
The first line is printed by the bindA method of my service B that required an implementation for A.
You see that A2 (ranking 2) gets bound instead of A1 (ranking 3).
I must be missing something, cause DS is used extensively...
[BImpl] Bound to com.acme.a2.A2@eca36e
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.8.0.v20120529-1548
1 ACTIVE org.apache.felix.gogo.shell_0.8.0.v201110170705
2 ACTIVE org.apache.felix.gogo.runtime_0.8.0.v201108120515
3 ACTIVE com.acme.a2_1.0.0.qualifier
4 ACTIVE org.eclipse.equinox.ds_1.4.0.v20120522-1841
5 ACTIVE org.apache.felix.gogo.command_0.8.0.v201108120515
6 ACTIVE org.eclipse.osgi.util_3.2.300.v20120522-1822
7 ACTIVE com.acme.a_1.0.0.qualifier
8 ACTIVE org.eclipse.osgi.services_3.3.100.v20120522-1822
9 ACTIVE com.acme.b_1.0.0.qualifier
10 ACTIVE org.eclipse.equinox.util_1.0.400.v20120522-2049
11 ACTIVE com.acme.a1_1.0.0.qualifier
12 ACTIVE org.eclipse.equinox.console_1.0.0.v20120522-1841
osgi> services
{org.osgi.service.packageadmin.PackageAdmin}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.framework.internal.core.PackageAdminImpl, service.vendor=Eclipse.org - Equinox, service.id=2}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.osgi_3.8.0.v20120529-1548 [0]
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.osgi.service.permissionadmin.PermissionAdmin, org.osgi.service.condpermadmin.ConditionalPermissionAdmin}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.internal.permadmin.SecurityAdmin, service.vendor=Eclipse.org - Equinox, service.id=3}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.osgi.service.startlevel.StartLevel}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.framework.internal.core.StartLevelManager, service.vendor=Eclipse.org - Equinox, service.id=4}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.eclipse.osgi.service.debug.DebugOptions}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.framework.debug.FrameworkDebugOptions, service.vendor=Eclipse.org - Equinox, service.id=5}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{java.lang.ClassLoader}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.ContextFinder, service.vendor=Eclipse.org - Equinox, equinox.classloader.type=contextClassLoader, service.id=6}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.framework.log.FrameworkLog}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory, service.vendor=Eclipse.org - Equinox, service.id=9}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
{org.eclipse.osgi.service.environment.EnvironmentInfo}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.EclipseEnvironmentInfo, service.vendor=Eclipse.org - Equinox, service.id=19}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.resolver.PlatformAdmin}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.internal.baseadaptor.StateManager, service.vendor=Eclipse.org - Equinox, service.id=20}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.eclipse.osgi.service.pluginconversion.PluginConverter}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.PluginConverterImpl, service.vendor=Eclipse.org - Equinox, service.id=21}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.localization.BundleLocalization}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.BundleLocalizationImpl, service.vendor=Eclipse.org - Equinox, service.id=22}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.framework.console.CommandProvider}={service.ranking=2147483647, service.id=28}
"Registered by bundle:" org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.eclipse.equinox.console.commands.EquinoxCommandProvider}={service.ranking=2147483647, osgi.command.function=[exit,shutdown,sta,start,sto,stop,i,install,up,up,up,update,update,update,un,uninstall,s,status,se,services,p,p,packages,packages,bundles,b,bundle,gc,init,close,r,refresh,exec,fork,h,headers,pr,props,setp,setprop,ss,t,threads,sl,setfwsl,setbsl,setibsl,requiredBundles,classSpaces,profilelog,getPackages,getprop,diag,enableBundle,disableBundle,disabledBundles], osgi.command.scope=equinox, service.id=48}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.eclipse.equinox.console.commands.HelpCommand}={service.ranking=2147483647, osgi.command.function=[help], osgi.command.scope=equinox, service.id=49}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{com.acme.a.A}={service.ranking=3, component.name=com.acme.a1.A1, component.id=2, service.id=44}
"Registered by bundle:" com.acme.a1_1.0.0.qualifier [11]
"No bundles using service."
{com.acme.a.A}={service.ranking=2, component.name=com.acme.a2.A2, component.id=0, service.id=40}
"Registered by bundle:" com.acme.a2_1.0.0.qualifier [3]
"Bundles using service"
com.acme.b_1.0.0.qualifier [9]
{org.osgi.service.log.LogReaderService, org.eclipse.equinox.log.ExtendedLogReaderService}={service.id=7}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.osgi.service.log.LogService, org.eclipse.equinox.log.ExtendedLogService}={service.id=8}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{javax.xml.parsers.SAXParserFactory}={service.id=11}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{javax.xml.parsers.DocumentBuilderFactory}={service.id=12}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.user.area, service.id=13}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.instance.area, service.id=14}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.configuration.area, service.id=15}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.install.area, service.id=16}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=eclipse.home.location, service.id=17}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.urlconversion.URLConverter}={protocol=[bundleentry,bundleresource], service.id=18}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.signedcontent.SignedContentFactory}={service.id=24}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.osgi_3.8.0.v20120529-1548 [0]
{org.eclipse.osgi.internal.provisional.verifier.CertificateVerifierFactory}={service.id=25}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.osgi.service.framework.CompositeBundleFactory}={service.id=26}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.osgi.service.cm.ConfigurationListener}={service.id=27}
"Registered by bundle:" org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
"No bundles using service."
{org.apache.felix.scr.ScrService}={service.id=29}
"Registered by bundle:" org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
"No bundles using service."
{org.apache.felix.service.threadio.ThreadIO}={service.id=30}
"Registered by bundle:" org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
"No bundles using service."
{org.apache.felix.service.command.CommandProcessor}={service.id=31}
"Registered by bundle:" org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
"Bundles using service"
org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.apache.felix.service.command.Converter}={service.id=32}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.apache.felix.gogo.shell.Builtin}={osgi.command.function=[format,getopt,new,set,tac,type], osgi.command.scope=gogo, service.id=33}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Procedural}={osgi.command.function=[each,if,not,throw,try,until,while], osgi.command.scope=gogo, service.id=34}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Posix}={osgi.command.function=[cat,echo,grep], osgi.command.scope=gogo, service.id=35}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Telnet}={osgi.command.function=[telnetd], osgi.command.scope=gogo, service.id=36}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Shell}={osgi.command.function=[gosh,sh,source], osgi.command.scope=gogo, service.id=37}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.eclipse.equinox.internal.util.threadpool.ThreadPoolManager, org.eclipse.equinox.internal.util.threadpool.ThreadPoolFactory}={service.id=38}
"Registered by bundle:" org.eclipse.equinox.util_1.0.400.v20120522-2049 [10]
"Bundles using service"
org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
{org.eclipse.equinox.internal.util.timer.Timer}={service.id=39}
"Registered by bundle:" org.eclipse.equinox.util_1.0.400.v20120522-2049 [10]
"No bundles using service."
{org.apache.felix.gogo.command.Basic}={osgi.command.function=[bundlelevel,frameworklevel,headers,help,install,inspect,lb,log,refresh,resolve,start,stop,uninstall,update,which], osgi.command.scope=felix, service.id=41}
"Registered by bundle:" org.apache.felix.gogo.command_0.8.0.v201108120515 [5]
"No bundles using service."
{org.apache.felix.gogo.command.Files}={osgi.command.function=[cd,ls], osgi.command.scope=felix, service.id=42}
"Registered by bundle:" org.apache.felix.gogo.command_0.8.0.v201108120515 [5]
"No bundles using service."
{org.apache.felix.gogo.command.OBR}={osgi.command.function=[deploy,info,javadoc,list,repos,source], osgi.command.scope=obr, service.id=43}
"Registered by bundle:" org.apache.felix.gogo.command_0.8.0.v201108120515 [5]
"No bundles using service."
{java.lang.Object}={osgi.command.function=[comp,component,dis,disAll,disable,disableAll,en,enAll,enable,enableAll,list,ls], osgi.command.scope=equinox, service.id=45}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.eclipse.equinox.console.telnet.TelnetCommand}={osgi.command.function=[telnet], osgi.command.scope=equinox, service.id=46}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.apache.felix.service.command.Converter}={service.id=47}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.eclipse.equinox.console.commands.ManCommand}={osgi.command.function=[man], osgi.command.scope=equinox, service.id=50}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.eclipse.equinox.console.commands.DisconnectCommand}={osgi.command.function=[disconnect], osgi.command.scope=equinox, service.id=51}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.eclipse.osgi.service.runnable.StartupMonitor}={service.ranking=-2147483648, service.id=1}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.framework.log.FrameworkLog}={service.ranking=-2147483648, performance=true, service.pid=46org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory$1, service.vendor=Eclipse.org - Equinox, service.id=10}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.security.TrustEngine}={service.ranking=-2147483648, osgi.signedcontent.trust.engine=org.eclipse.osgi, service.id=23}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
osgi> list -c
All Components:
ID Component details
1 Component[
name = com.acme.a2.A2
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = com.acme.a2.A2
state = Unsatisfied
properties = {service.ranking=2}
serviceFactory = false
serviceInterface = [com.acme.a.A]
references = null
located in bundle = com.acme.a2_1.0.0.qualifier [3]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
objectClass = String[com.acme.a.A]
service.ranking = 2
component.name = com.acme.a2.A2
component.id = 0
Instances:
org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@e8a0cd
2 Component[
name = com.acme.b.BImpl
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = com.acme.b.BImpl
state = Unsatisfied
properties =
serviceFactory = false
serviceInterface = null
references = {
Reference[name = A, interface = com.acme.a.A, policy = static, cardinality = 1..1, target = null, bind = bindA, unbind = unbindA]
}
located in bundle = com.acme.b_1.0.0.qualifier [9]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
component.name = com.acme.b.BImpl
component.id = 1
Instances:
org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@95215b
Bound References:
String[com.acme.a.A]
-> com.acme.a2.A2@eca36e
3 Component[
name = com.acme.a1.A1
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = com.acme.a1.A1
state = Unsatisfied
properties = {service.ranking=3}
serviceFactory = false
serviceInterface = [com.acme.a.A]
references = null
located in bundle = com.acme.a1_1.0.0.qualifier [11]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
objectClass = String[com.acme.a.A]
service.ranking = 3
component.name = com.acme.a1.A1
component.id = 2
Instances:
org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@c10de0
|
|
| |
Re: DS ignores service.ranking? [message #892218 is a reply to message #892189] |
Wed, 27 June 2012 08:33   |
Eclipse User |
|
|
|
Hi Gunnar,
Once again thanks for your feedback.
Without being an expert on DS, I dare to disagree with you 
I agree that mentioning "static" causes my component B not to be re-bound unless the original binding becomes invalid (e.g. service disappeared).
Registering a service with a higher service.ranking afterwards, will not break the previous binding.
To my understanding, the original binding should be respecting the service.ranking, though.
On one and the same start-level, I have two service-candidates with specific service.ranking.
The DS should then make a choice according to the spec and not just chose the first one that accidently is encountered...
To validate this, I tried your suggestion by making the binding in B dynamic.
Unfortunately, this didn't change the behaviour.
Based on my experiments, I'm convinced by now that it is just a very annoying tooling issue.
Maybe someone could try and follow these steps below, see whether you encounter the same:
* Use Eclipse Juno (I use the modeling 32-bit version).
* Start it in an empty workspace.
* Import the projects from my dsTestJuno.zip except for com.acme.A2.
* Now right-click on Runtime/dsTestRun.launch and run it in debugging.
* The first line in the console should state that B is bound to A1 (of course, there is no A2).
* Then also import the A2 project.
* Run again in the same way.
* Using the settings in the archive (A1 and A2 on service.ranking 6 and 5 respectively), A1 should remain the chosen one.
* If it does, try playing a bit with the rankings of A1 and A2 and every time run again.
* I don't see any regularity: sometimes works, sometimes not.
* Restarting Eclipse can suddenly produce another result.
If you would have a clue...
Johan
|
|
| | | | |
Re: DS ignores service.ranking? [message #1785391 is a reply to message #890734] |
Fri, 13 April 2018 08:26  |
Eclipse User |
|
|
|
I solved this issue by specifiying ReferencePolicyOption.Greedy
e.g.:
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY, policyOption = ReferencePolicyOption.GREEDY)
The greedy policy option is a valid policy option for both static and dynamic reference policies. When a new target service for a reference becomes available, references having the greedy policy option will bind the new target service.
|
|
|
Goto Forum:
Current Time: Mon Mar 10 17:57:55 EDT 2025
Powered by FUDForum. Page generated in 0.04137 seconds
|