Query all OSGi Services

Once in a while you may need to query all currently registered services in the OSGi container. This can be achieved by using the BundleContext class.

ServiceReference<?>[] references = bundleContext.getAllServiceReferences(null, null);