light_303 light_303 - 8 days ago 5
Java Question

deactivate/disable OSGI component by name from external bundle

Is there a way to deactivate a given OSGI component by its name?

There is the

componentContext.disableComponent(componentName)
method - but it only works on components of the same bundle.

What is the best practice solution to do this without adding a new service to the given bundle to deactivate the component?

Answer

You can use the ServiceComponentRuntime service. It allows to introspect and manage any component.