private BundleContext bundleContextOfCommand(final Class<Object> implementationClass) { for (final BeanEntry<Annotation, Injector> beanEntry : beanLocator.locate(Key.get(Injector.class))) { final Injector injector = beanEntry.getValue(); try { injector.getBinding(implementationClass); // if we passed above it means that injector is the one for the implementation class return injector.getInstance(BundleContext.class); } catch (ConfigurationException ignore) { } } return null; }