Example #1
0
 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;
 }
Example #2
0
  @Inject
  BindingWatcher(final BeanLocator beanLocator, final List<BindingProcessor> processors) {
    logger = LoggerFactory.getLogger(this.getClass());

    this.beanLocator = beanLocator;
    this.processors = processors;
    commands = new HashMap<BeanEntry<Annotation, Object>, Holder>();
    beanLocator.watch(
        Key.get(Object.class),
        new Mediator<Annotation, Object, BindingWatcher>() {
          public void add(
              final BeanEntry<Annotation, Object> beanEntry, final BindingWatcher watcher)
              throws Exception {
            watcher.registerFunction(beanEntry);
          }

          public void remove(
              final BeanEntry<Annotation, Object> beanEntry, final BindingWatcher watcher)
              throws Exception {
            watcher.unregisterFunction(beanEntry);
          }
        },
        this);
  }