It's possible that you're confused between package dependencies and service dependencies.
Services providers can come and go, and consumers of those services can dynamically rebind at will. Both the provider and the consumer bundle import the package which contains the service API. It seems like you are uninstalling the bundle that contains the API. Also it seems like you have multiple bundles exporting different versions of the same API? Neither the consumer nor the producer of a service will automatically rebind to a different API version; as Simon and Richard pointed that, that requires a "refresh packages" operation. "Two services with the same name" presumably means two services with the same *interface*. The implementation class of those services can come from any package and any bundle. Regards Neil On Mon, Sep 27, 2010 at 3:16 PM, Sandra Krneta <[email protected]> wrote: > But my service is inside some package that some bundle exports, > so if I stop bundle serice is gone and also package is gone, > I don't understand how service can go without package. > and how can I have two services with same name that don't come > from two different packages. > Can you tell me if you know some good example for this on the web? > > ________________________________ > > Services are more dynamic than packages; they can come and go at will, > package wiring cannot. Once a bundle is wired to a given package, it > will not wire to another provider until the framework is refreshed. > Performing an update is not sufficient. You must always refresh the > framework to cause any rewiring. > > -> richard > > On 9/27/10 2:33, Sandra Krneta wrote: >> >> I have component consuming MusicPlayer service, that service is >> declarative service and its component.xml >> >> Looks like this >> >> <implementation class="playercoreimpl.MusicPlayerServiceImpl"/> >> >> <service> >> >> <provide interface="playercore.MusicPlayerService"/> >> >> </service> >> >> Component that consumes it imports player core service >> >> *Import-Package*: >> >> org.osgi.framework;/version/="1.3.0", >> >> playercore;/version/="[1.0.0,2.0.3)", >> >> and has component.xml like this >> >> <implementation class="testbundle.Activator"/> >> >> <reference bind="setMusicPlayer" cardinality="1..1" >> interface="playercore.MusicPlayerService" name="MusicPlayerService" >> policy="dynamic" unbind="unsetMusicPlayer"/> >> >> And bind and unbind methods look like this >> >> * private* AtomicReference<MusicPlayerService> musicPlayerRef = *new* >> AtomicReference<MusicPlayerService>(); >> >> * public* *void* setMusicPlayer(MusicPlayerService musicPlayer) { >> >> musicPlayerRef.set(musicPlayer); >> >> setMusicPlayerToPlayer(musicPlayer); >> >> } >> >> *public* *void* unsetMusicPlayer(MusicPlayerService musicPlayer) { >> >> musicPlayerRef.compareAndSet(musicPlayer, *null*); >> >> } >> >> The problem is, when I have two bundles that export playercore package >> (different versions)started in framework >> >> and I stop one of them, just unbind method is called and consuming >> bundle stops, it doesn’t start using other version >> >> of service. Update of consuming bundle doesn’t help. >> >> One more thing is confusing, if bundle that exports playercore with >> lower version is started and consumer bundle is started, >> >> But then I stop player corebundle, consuming bundle stops, then after >> installation and starting of playercore component >> >> with higher version and update of consuming component, component is >> started, but vice versa it is not case. >> >> I am using Equinox. >> >> If anyone has solution for this, please let me know it is urgent >> >> >> >> _______________________________________________ >> OSGi Developer Mail List >> [email protected] >> https://mail.osgi.org/mailman/listinfo/osgi-dev > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev > > > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev > _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
