Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » DS ignores service.ranking?
DS ignores service.ranking? [message #890734] Fri, 22 June 2012 23:40 Go to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
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 #891524 is a reply to message #890734] Mon, 25 June 2012 07:17 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Johan,

can you check the definition of the service.ranking property in the
component xml? I remember a similar situation in the past I was
scratching my head on. It turned out that I missed declaring the
property as type "Integer". Thus, it was registered as String which is
the wrong type and thus being ignored as a ranking value.

-Gunnar

--
Gunnar Wagenknecht
gunnar@xxxxxxxx
http://wagenknecht.org/
Re: DS ignores service.ranking? [message #891530 is a reply to message #891524] Mon, 25 June 2012 07:34 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
Hi Gunnar,

Thanks for your suggestion.
I took the typing into account.
This is the xml component definition:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="-correct url-" enabled="true" immediate="true" name="com.acme.a2.MockA2">
   <implementation class="com.acme.a2.MockA2"/>
   <service>
      <provide interface="com.acme.a.A"/>
   </service>
   <property name="service.ranking" type="Integer" value="1"/>
</scr:component>


(Manually changed xmlns:src because posting links wasn't allowed.)
Re: DS ignores service.ranking? [message #891598 is a reply to message #891530] Mon, 25 June 2012 10:29 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
Hmmm strange... After quite some trying, I discovered that the issue is linked to the selection of target bundles that I select for my run.
* Works fine if I select all target bundles (default Eclipse 3.7.2).
Well, since I run it as an OSGi framework, it complains about a lot, but at least DS behaves normally.
* Works incorrectly when I limit my target bundles to (see below):
org.eclipse.equinox.ds (1.3.1)
org.eclipse.equinox.util (1.0.300)
org.eclipse.osgi (3.7.2)
org.eclipse.osgi.services (3.3.0)

With the second selection, it behaves strange:
* DS seems to work fine for a first run in an empty workspace.
It correctly respects the service.ranking.
* If you subsequently change your service.ranking, every change is ignored.
Cleaning the workspace (-clean or the checkmark in the run configuration) doesn't help.
Removing the .metadata directory makes it work fine (again only once).

Take a look at the attachment dsTest.zip:
* Just import all projects in a freshly extracted eclipse-modeling-indigo-SR2-win32.zip.
* Runtime/dsTestFull.launch: seems to work fine (full target selected)
* Runtime/dsTestLimited.launch: fails as indicated.

Just look for the first line appearing in the console. It shows the service that gets bound in BImpl. It will be A1 or A2 depending on their service.ranking.

Anybody who can explain this behavior?
Am I missing some bundles that take care of .metadata cleanup between runs? Don't know about such a thing.
For me it looks a lot like a bug...

Johan
  • Attachment: dsTest.zip
    (Size: 23.30KB, Downloaded 384 times)
Re: DS ignores service.ranking? [message #891936 is a reply to message #891598] Tue, 26 June 2012 15:57 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
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 #892189 is a reply to message #891936] Wed, 27 June 2012 11:07 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Am 26.06.2012 17:57, schrieb Johan Van Noten:
> 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).

It may be a result of activation order. I noticed that you use policy
"static" in the dependency with cardinality "1..". I think that in this
case the component is not re-bound to a newer service as long as the old
is still available.

Did you try with a dynamic policy?

-Gunnar

--
Gunnar Wagenknecht
gunnar@xxxxxxxx
http://wagenknecht.org/
Re: DS ignores service.ranking? [message #892218 is a reply to message #892189] Wed, 27 June 2012 12:33 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
Hi Gunnar,

Once again thanks for your feedback.

Without being an expert on DS, I dare to disagree with you Smile
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 #892220 is a reply to message #892218] Wed, 27 June 2012 12:40 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
This attachment contains the Juno version of the launch (other required bundles).
Re: DS ignores service.ranking? [message #892289 is a reply to message #892218] Wed, 27 June 2012 15:34 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Am 27.06.2012 14:33, schrieb Johan Van Noten:
> Without being an expert on DS, I dare to disagree with you

Well, DS (the implementation as well as the tooling) still surprises me
once in a while... and I haven't memorized the spec. I usually fall back
to a trial and error mode when analyzing DS problems.
> 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...

So the start-level doesn't say anything about activation order within
the same level. Timing issues are possible. For example, it is possible
that the bundle providing the service with the lower ranking is
activated before the other bundle. The DS implementation listens for
events and might immediately start creating the component when the first
bundle was activated because all dependencies are satisfied. The DS
implementation can't predict the future and doesn't know anything about
bundles with services yet to be activated.

Here is another thing you can try. Instead of activating all bundles and
components right away you could use lazy activation for bundles A1 and
A2. This might help. But I really wonder why dynamic doesn't do the
trick. Maybe even a "dynamic 1..1" won't change an already established
binding.

BTW, I use multiple service implementations with service ranking in my
RT tutorial. But I haven't encountered the issue so far.

https://github.com/eclipseguru/eclipsert-tutorial

provider: hello.service and hello.preferences
consumer: hello.job

-Gunnar

--
Gunnar Wagenknecht
gunnar@xxxxxxxx
http://wagenknecht.org/
Re: DS ignores service.ranking? [message #1563977 is a reply to message #891524] Wed, 14 January 2015 14:27 Go to previous messageGo to next message
Sebastian Geedot is currently offline Sebastian GeedotFriend
Messages: 7
Registered: October 2014
Junior Member
Ouh, thank you so much. This solved my "ranking problem" I experienced using osgi 3.10.
I did not get rid of that new ExtendedLogService for using my own. Thanks to ranking, I have kicked it out, now.

Integer - that's it!

Grrrüße aus Deutschland! Rolling Eyes
Re: DS ignores service.ranking? [message #1587192 is a reply to message #891524] Tue, 27 January 2015 07:35 Go to previous messageGo to next message
Martin Neubig is currently offline Martin NeubigFriend
Messages: 1
Registered: January 2015
Junior Member
Hi Gunnar,

thx for this information. I had same problem, now i could solve!

Martin
Re: DS ignores service.ranking? [message #1785391 is a reply to message #890734] Fri, 13 April 2018 12:26 Go to previous message
P Palm is currently offline P PalmFriend
Messages: 1
Registered: April 2018
Junior Member
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.
Previous Topic:Problem importing mysql JDBC driver
Next Topic:HTTP Status 404 - ProxyServlet: /app
Goto Forum:
  


Current Time: Wed Apr 24 19:54:15 GMT 2024

Powered by FUDForum. Page generated in 0.03795 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top