If you have two bundles exporting the same package you should be using PackageAdmin's refreshPackages API to refresh bundles that have been resolved against the bundle that was uninstalled. Without doing this, bundles that have been resolved against an uninstalled bundle will continue to reference its exported packages, even after it appears to be gone. Such a bundle is known as a zombie.
Also, why do you have a cardinality of "1..1" and a policy of "dynamic". This is an unusual pairing. Typically when using a cardinality of "1..1" you'd use a policy of "static" (these are the defaults in fact). And when using a policy of "dynamic" you'd use a cardinality of "0..1" or "0..n". For in depth coverage of how Declarative Services works I recommend the following book: http://equinoxosgi.org/ Good luck, Simon From: Sandra Krneta <[email protected]> To: [email protected] Date: 09/27/2010 02:42 AM Subject: [osgi-dev] Problem with service replacement using declarative services Sent by: [email protected] 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
