Search code examples
javaosgiequinox

remove service from bundle


in osgi, i have this setup: Bundle A has Service S registered. Bundle B processes Bundle A and should remove Service S from it. can it be done? or is it conceptually nonsense? i didnot find any method for removing the service as i did not registered it (and therefore does not have the serviceRegistration object).

To make it more complicated: Service S actually stems from Bundle B. The goal is to remove S after a restart from B and add a new instance of S. So i could also implement a S.removeYourself() method... is this possible?


Solution

  • You must use the ServiceRegistration object to unregister the service. So you would need some means for Bundle B to inform Bundle A to unregister the service when it is no longer necessary.