public void serviceChanged(final ServiceEvent event) {
if (event.getType() == ServiceEvent.UNREGISTERING) {
final ServiceReference ref = event.getServiceReference();
if (ref == serviceRegistration.getReference()) {
// Flush all resources that might have been missed
final DisposableContainer facade =
(DisposableContainer) bundleContext.getService(ref);
facade.releaseResources();
}
}
}
});