Thanks, Ok I understand, yes tried this too. I created 2 services (A and B) both implementation of Dictionary (which is the interface the DS service descriptor below is listening to).
I tried to replace bundle A (same version & different version) but I still get the bundle A stop (which I assume is correct) plus the unset method called first on the DictionaryServiceImpl . Then I can see the Bundle start and the set/bind method invoked: (34)) Servicea: stop (34)) BROKER Service was unset. (34)) SERVLIST: (34)) SERV:en_ME --> this is showing only Dictonary en_ME is available (service B). So service A is removed. (34)) Servicea new: start (34)) BROKER Service was set. Th (34)) SERVLIST: (34)) SERV:en_ME (34)) SERV:en_US --> Now en_UK is again in the list and therefore added. I tried with different cardinality as mentioned as below (1..n and 0..n). Question: Why during a replace we want to ever call unbind first ? Isn’t the purpose of replace to give a change to the listening service to see the new instance and then old so that it can be transparently replaced ? Even in the case only 1 service is available. I am new to OSGi though I have been playing with it for sometime. Is it the assumption that in a x..n configuration each service provides same functionality therefore the requesting service can choose any of the available one ? In the dictionary example for example I don’t want another language (e.g. US) to be chosen if the one I am requesting is UK. Therefore if I am updating the UK service I still would like to use UK (latest version). I though OSGi can provide this capability too. Am I using the wrong pattern ? Regards, Giuseppe. From: osgi-dev-boun...@mail.osgi.org [mailto:osgi-dev-boun...@mail.osgi.org] On Behalf Of Neil Bartlett Sent: 26 October 2011 16:09 To: OSGi Developer Mail List Subject: Re: [osgi-dev] Bind and unbind sequence is DS service update. Giuseppe, Bear in mind that it's also important what the target service is doing. If there is one target service and it goes away very briefly (e.g. for its bundle to be updated) then the component binding to it will of course have to be unbound first and then rebound later. The dynamic replacement, with bind followed by unbind, will only happen if the replacement service is *already* available when the bound service goes away... i.e. there will be at least 2 service instances for some time. Regards, Neil On Wednesday, 26 October 2011 at 15:58, Giuseppe Sarno wrote: Hi, Sorry I reread my post... http://community.jboss.org/thread/174057 the title is correct but the text in the message is wrong. Sorry for the confusion. The issue I am experiencing now with the new prototype is that unbind is called before bind (on JBOSS OSGi). In a previous prototype on equinox (slightly different code) the bind method was called before unbind which is what I am expecting. Giuseppe. -----Original Message----- From: osgi-dev-boun...@mail.osgi.org [mailto:osgi-dev-boun...@mail.osgi.org] On Behalf Of David Bosschaert Sent: 26 October 2011 15:10 To: OSGi Developer Mail List Subject: Re: [osgi-dev] Bind and unbind sequence is DS service update. Hi Guiseppe, I'm a little bit confused. In http://community.jboss.org/thread/174057 you mention as the issue is that 'the unbind method is called after bind' but here you say that your original prototype called bind() before unbind(). Isn't that the same? Cheers, David On 26 October 2011 14:58, Giuseppe Sarno <giuseppe.sa...@genband.com<mailto:giuseppe.sa...@genband.com>> wrote: Hello, I was playing with JBOSS 7.0 and trying to implement a prototype of a DS service which automatically (dynamically) binds other DS services. I had done similar prototype some time ago but using the equinox container. With the original prototype I believe the container did call the "bind" method before the "unbind" upon update. I think this is what I read through the line of the OSGI spec and the OSGI in practise book from Neil B.. This way I had the chance to automatically and transparently replace a service without affecting the run time processing. I did not have similar behaviour using the JBOSS container (code is slightly different so the change might have triggered the different behaviour). The post is at http://community.jboss.org/thread/174057. My goal is to replace a service while the system is running and there are calls to the service. Can anybody please help to understand correct behaviour and anything I should do to achieve the goal ? Thanks for your help. Attached below is the xml descriptor of the DS service. Should the setDictionary method on DictionaryService implementation be called before unsetDictionary upon update? <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="osgi.example.service.broker"> <implementation class="osgi.example.service.broker.DictionaryServiceImpl"/> <service> <provide interface="osgi.example.service.broker.interf.DictionaryService"/> </service> <reference bind="setDictionary" cardinality="1..n" interface="osgi.example.service.Dictionary" name="Dictionary" policy="dynamic" unbind="unsetDictionary"/> </scr:component> _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org<mailto:osgi-dev@mail.osgi.org> https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org<mailto:osgi-dev@mail.osgi.org> https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org<mailto:osgi-dev@mail.osgi.org> https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev