Esempio n. 1
0
  @Override
  public void configure(Binder binder) {
    binder.disableCircularProxies();

    bindConfig(binder).to(LifeCycleConfig.class);

    binder.bindListener(
        any(),
        new TypeListener() {
          @Override
          public <T> void hear(TypeLiteral<T> type, TypeEncounter<T> encounter) {
            encounter.register(
                (InjectionListener<T>)
                    obj -> {
                      if (isLifeCycleClass(obj.getClass())) {
                        LifeCycleManager lifeCycleManager = lifeCycleManagerRef.get();
                        if (lifeCycleManager != null) {
                          try {
                            lifeCycleManager.addInstance(obj);
                          } catch (Exception e) {
                            throw new RuntimeException(e);
                          }
                        } else {
                          injectedInstances.add(obj);
                        }
                      }
                    });
          }
        });
  }
 @Override
 public void configure(final Binder binder) {
   // When a @I18NLocalized annotated type is injected, all members of the types are inspected to
   // find
   // the ones of I18NService type and @I18NMessageBundleService annotated; if it's the case, the
   // member is injected
   // with the bundle
   binder.bindListener(
       new I18NLocalizedTypeAnnotationMatcher(),
       new I18NMessageAnnotationGuiceHandler()); // @I18NMessageBundle annotation handling
 }
Esempio n. 3
0
 @Override
 public void bindListener(
     Matcher<? super Binding<?>> bindingMatcher, ProvisionListener... listeners) {
   binder.bindListener(bindingMatcher, listeners);
 }