Example #1
0
  @Override
  public void configure(final Env env, final Config config, final Binder binder) {
    super.configure(env, config, binder);

    if (scan) {
      pkgs.add(config.getString("application.ns"));
    }

    HbmUnitDescriptor descriptor =
        new HbmUnitDescriptor(getClass().getClassLoader(), dataSource(), config, pkgs);

    Map<Object, Object> integration = config(env, config, classes);
    emf = new HbmProvider(descriptor, integration);
    keys(EntityManagerFactory.class, key -> binder.bind(key).toProvider(emf).asEagerSingleton());

    List<Key<EntityManager>> emkeys = new ArrayList<>();

    keys(
        EntityManager.class,
        key -> {
          binder.bind(key).toProvider(Providers.outOfScope(key)).in(RequestScoped.class);
          emkeys.add(key);
        });

    Multibinder<Route.Definition> routes = Multibinder.newSetBinder(binder, Route.Definition.class);
    routes
        .addBinding()
        .toInstance(new Route.Definition("*", "*", new OpenSessionInView(emf, emkeys)).name("hbm"));
  }
Example #2
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);
                        }
                      }
                    });
          }
        });
  }
Example #3
0
 /**
  * Binds providers of resource specific information (e.g. resource metadata, scoped preferences,
  * workspace etc.)
  */
 public void configureResourceSpecificProviders(com.google.inject.Binder binder) {
   binder.bind(ILineSeparatorInformation.class).toProvider(ResourceILineSeparatorProvider.class);
   // binder.bind(IIndentationInformation.class).toProvider(ResourceIIndentationInformationProvider.class);
   binder
       .bind(IPreferredMaxWidthInformation.class)
       .toProvider(ResourceIPreferredWidthInformationProvider.class);
 }
  @Override
  public void configure(Binder binder) {
    // Instantiate eagerly so that we get everything registered and put into the Lifecycle
    // This makes the shutdown run pretty darn near last.

    try {
      // Reflection to try and allow non Log4j2 stuff to run. This acts as a gateway to stop errors
      // in the next few lines
      final Class<?> logManagerClazz = Class.forName("org.apache.logging.log4j.LogManager");

      final LoggerContextFactory contextFactory = LogManager.getFactory();
      if (!(contextFactory instanceof Log4jContextFactory)) {
        log.warn(
            "Expected [%s] found [%s]. Unknown class for context factory. Not logging shutdown",
            Log4jContextFactory.class.getCanonicalName(),
            contextFactory.getClass().getCanonicalName());
        return;
      }
      final ShutdownCallbackRegistry registry =
          ((Log4jContextFactory) contextFactory).getShutdownCallbackRegistry();
      if (!(registry instanceof Log4jShutdown)) {
        log.warn(
            "Shutdown callback registry expected class [%s] found [%s]. Skipping shutdown registry",
            Log4jShutdown.class.getCanonicalName(), registry.getClass().getCanonicalName());
        return;
      }
      binder.bind(Log4jShutdown.class).toInstance((Log4jShutdown) registry);
      binder
          .bind(Key.get(Log4jShutterDowner.class, Names.named("ForTheEagerness")))
          .to(Log4jShutterDowner.class)
          .asEagerSingleton();
    } catch (ClassNotFoundException | ClassCastException | LinkageError e) {
      log.warn(e, "Not registering log4j shutdown hooks. Not using log4j?");
    }
  }
  @Override
  public void configure(Binder binder) {
    Multibinder<SystemTable> globalTableBinder =
        Multibinder.newSetBinder(binder, SystemTable.class);
    globalTableBinder.addBinding().to(NodeSystemTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(QuerySystemTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(TaskSystemTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(CatalogSystemTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(TablePropertiesSystemTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(TransactionsSystemTable.class).in(Scopes.SINGLETON);

    globalTableBinder.addBinding().to(AttributeJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(CatalogJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(ColumnJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(ProcedureColumnJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(ProcedureJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(PseudoColumnJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(SchemaJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(SuperTableJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(SuperTypeJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(TableJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(TableTypeJdbcTable.class).in(Scopes.SINGLETON);
    globalTableBinder.addBinding().to(UdtJdbcTable.class).in(Scopes.SINGLETON);

    binder.bind(GlobalSystemConnectorFactory.class).in(Scopes.SINGLETON);
    binder.bind(SystemTablesRegistrar.class).asEagerSingleton();
  }
Example #6
0
  public void configure(Binder binder) {

    // ~ 相关业务实现类
    // 登陆服务
    binder.bind(IBaseService.class).to(LoginServiceImpl.class).in(Scopes.SINGLETON);
    // SSO核心Model
    binder.bind(SSOCoreModel.class).to(SSOServerModel.class).in(Scopes.SINGLETON);
    // 配置文件映射类,单例模式
    binder.bind(Config.class).in(Scopes.SINGLETON);

    binder
        .bindConstant()
        .annotatedWith(Names.named("service_interface_name"))
        .to("sunland.passport.core.service.IBaseService");
    //
    // binder.bindConstant().annotatedWith(Names.named("service_impl")).to(LoginServiceImpl.class);

    /*        MapBinder<String, IBaseService> mapbinder = MapBinder.newMapBinder(binder, String.class, IBaseService.class);
    mapbinder.addBinding("login_service").to(LoginServiceImpl.class);
    mapbinder.addBinding("logout_service").to(LogoutServiceImpl.class);*/
    testMapbinderModules();

    //        mapbinder.addBinding("")

  }
Example #7
0
  @Override
  public void configure(Binder binder) {
    binder.bind(ScheduledExecutorService.class).toInstance(svc);
    binder.bind(HashGenerator.class).toInstance(generator);

    binder.bind(Config.class).toInstance(config);
    binder.bind(CurrentTime.class).toInstance(time);
  }
Example #8
0
  @VisibleForTesting
  static void bindThriftDecorator(
      Binder binder, Matcher<? super Class<?>> classMatcher, MethodInterceptor interceptor) {

    binder.bindInterceptor(
        classMatcher, Matchers.returns(Matchers.subclassesOf(Response.class)), interceptor);
    binder.requestInjection(interceptor);
  }
Example #9
0
 public void configure(final Binder binder) {
   binder
       .bind(OutputManager1.class)
       .toInstance(new OutputManager1(new OutputHelper(new SystemOutOutput())));
   binder
       .bind(OutputManager2.class)
       .toInstance(new OutputManager2(new OutputHelper(new LoggerOutput())));
 }
Example #10
0
 // contributed by org.eclipse.xtext.xtext.generator.xbase.XbaseGeneratorFragment2
 public void configureLanguageSpecificURIEditorOpener(Binder binder) {
   if (PlatformUI.isWorkbenchRunning()) {
     binder
         .bind(IURIEditorOpener.class)
         .annotatedWith(LanguageSpecific.class)
         .to(DerivedMemberAwareEditorOpener.class);
     binder.bind(IDerivedMemberAwareEditorOpener.class).to(DerivedMemberAwareEditorOpener.class);
   }
 }
Example #11
0
  @Override
  public void configure(Binder binder) {
    binder.requireExplicitBindings();
    binder.disableCircularProxies();

    binder.bind(NodeInfo.class).in(Scopes.SINGLETON);
    ConfigurationModule.bindConfig(binder).to(NodeConfig.class);
    MBeanModule.newExporter(binder).export(NodeInfo.class).withGeneratedName();
  }
Example #12
0
 @Override
 public void configureContentAssistLexerProvider(Binder binder) {
   binder
       .bind(InternalXtendLexer.class)
       .toProvider(LexerProvider.create(DisabledInternalLexer.class));
   binder
       .bind(DisabledInternalLexer.class)
       .toProvider(LexerProvider.create(DisabledInternalLexer.class));
 }
Example #13
0
  @Override
  public void configure(Binder binder) {
    String emitterType = props.getProperty(EMITTER_PROPERTY, "");

    binder.install(new LogEmitterModule());
    binder.install(new HttpEmitterModule());

    binder.bind(Emitter.class).toProvider(new EmitterProvider(emitterType)).in(LazySingleton.class);
  }
Example #14
0
 public void configureDebugMode(Binder binder) {
   if (Boolean.getBoolean("org.eclipse.xtext.xtend.debug")) {
     binder.bindConstant().annotatedWith(Names.named(AbstractEditStrategy.DEBUG)).to(true);
   }
   // matches ID of org.eclipse.ui.contexts extension registered in plugin.xml
   binder
       .bindConstant()
       .annotatedWith(Names.named(XtextEditor.KEY_BINDING_SCOPE))
       .to("org.eclipse.xtend.ide.XtendEditorScope");
 }
Example #15
0
 public void configureDebugTracing(com.google.inject.Binder binder) {
   binder
       .bind(ITracer.class)
       .annotatedWith(Names.named(PPUiConstants.DEBUG_OPTION_MODULEFILE))
       .toInstance(new DefaultTracer(PPUiConstants.DEBUG_OPTION_MODULEFILE));
   binder
       .bind(ITracer.class)
       .annotatedWith(Names.named(PPUiConstants.DEBUG_OPTION_PARSER))
       .toInstance(new DefaultTracer(PPUiConstants.DEBUG_OPTION_PARSER));
 }
 @Override
 public void configure(Binder binder) {
   final Class<? extends Provider<MemcachedClientIF>> provider = MemcacheClientProvider.class;
   binder.bind(MemcacheClientProvider.class).in(Singleton.class);
   binder
       .bind(MemcachedClientIF.class)
       .annotatedWith(Current.class)
       .toProvider(provider)
       .in(UnitOfWork.class);
 }
Example #17
0
 public void configureOverrideIndicatorSupport(Binder binder) {
   binder
       .bind(IXtextEditorCallback.class)
       .annotatedWith(Names.named("OverrideIndicatorModelListener")) // $NON-NLS-1$
       .to(OverrideIndicatorModelListener.class);
   binder
       .bind(IActionContributor.class)
       .annotatedWith(Names.named("OverrideIndicatorRulerAction"))
       .to( //$NON-NLS-1$
           OverrideIndicatorRulerAction.class);
 }
Example #18
0
  @Override
  public void configure(Binder binder) {
    bindConfig(binder).to(ThriftClientManagerConfig.class);

    binder.bind(NiftyClient.class).toProvider(NiftyClientProvider.class).in(Scopes.SINGLETON);

    // Bind single shared ThriftClientManager
    binder.bind(ThriftClientManager.class).in(Scopes.SINGLETON);

    // Create a multibinder for global event handlers
    clientEventHandlersBinder(binder);
  }
Example #19
0
 public void configureResourceLocator(com.google.inject.Binder binder) {
   binder.bind(org.eclipse.emf.common.util.ResourceLocator.class).toInstance(MESPPlugin.INSTANCE);
   binder
       .bind(es.uah.aut.srg.micobs.util.IMICOBSUtil.class)
       .toInstance(MESPUtilProvider.getMICOBSUtil());
   binder
       .bind(es.uah.aut.srg.micobs.pdl.util.IPDLUtil.class)
       .toInstance(MESPUtilProvider.getPDLUtil());
   binder
       .bind(es.uah.aut.srg.micobs.mesp.util.IMESPUtil.class)
       .toInstance(MESPUtilProvider.getMESPUtil());
 }
Example #20
0
 private static <T> void bind(Binder binder, Class<T> type) {
   ImmutableMap.Builder<Method, Call> methods = ImmutableMap.builder();
   for (Method method : type.getMethods()) {
     try {
       Call call = new Call(method, binder.getProvider(Storage.class));
       methods.put(method, call);
     } catch (ParseException e) {
       binder.addError("%s\n%s", method, e.getMessage());
     }
   }
   binder.bind(type).toInstance(proxy(type, methods.build()));
 }
 // contributed by org.eclipse.xtext.generator.xbase.XbaseGeneratorFragment
 public void configureLanguageSpecificURIEditorOpener(com.google.inject.Binder binder) {
   if (org.eclipse.ui.PlatformUI.isWorkbenchRunning()) {
     binder
         .bind(org.eclipse.xtext.ui.editor.IURIEditorOpener.class)
         .annotatedWith(org.eclipse.xtext.ui.LanguageSpecific.class)
         .to(org.eclipse.xtext.xbase.ui.jvmmodel.navigation.DerivedMemberAwareEditorOpener.class);
     binder
         .bind(org.eclipse.xtext.common.types.ui.navigation.IDerivedMemberAwareEditorOpener.class)
         .to(org.eclipse.xtext.xbase.ui.jvmmodel.navigation.DerivedMemberAwareEditorOpener.class);
   }
   ;
 }
  @Override
  public void configure(Binder binder) {
    super.configure(binder);

    binder
        .bind(ISemanticHighlightingCalculator.class)
        .to(MechDbSemanticHighlightingCalculator.class);
    binder.bind(MechanoidLibClasspathUiValidationHelper.class);
    //		binder.bind(String.class)
    //		.annotatedWith(com.google.inject.name.Names.named(
    //		(XtextContentAssistProcessor.COMPLETION_AUTO_ACTIVATION_CHARS)))
    //		.toInstance(".");

  }
  @Override
  public void configure(Binder binder) {
    PolyBind.createChoice(
        binder, "druid.indexer.logs.type", Key.get(TaskLogs.class), Key.get(FileTaskLogs.class));
    JsonConfigProvider.bind(binder, "druid.indexer.logs", FileTaskLogsConfig.class);

    final MapBinder<String, TaskLogs> taskLogBinder = Binders.taskLogsBinder(binder);
    taskLogBinder.addBinding("noop").to(NoopTaskLogs.class).in(LazySingleton.class);
    taskLogBinder.addBinding("file").to(FileTaskLogs.class).in(LazySingleton.class);
    binder.bind(NoopTaskLogs.class).in(LazySingleton.class);
    binder.bind(FileTaskLogs.class).in(LazySingleton.class);

    binder.bind(TaskLogPusher.class).to(TaskLogs.class);
  }
Example #24
0
  public void configure(Binder binder) {
    binder.requireExplicitBindings();
    binder.disableCircularProxies();

    binder.bind(PersonStore.class).in(Scopes.SINGLETON);
    newExporter(binder).export(PersonStore.class).withGeneratedName();

    binder.bind(PersonsResource.class).in(Scopes.SINGLETON);
    binder.bind(PersonResource.class).in(Scopes.SINGLETON);

    bindConfig(binder).to(StoreConfig.class);
    eventBinder(binder).bindEventClient(PersonEvent.class);

    discoveryBinder(binder).bindHttpAnnouncement("person");
  }
 public void configureFileExtensions(Binder binder) {
   if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null)
     binder
         .bind(String.class)
         .annotatedWith(Names.named(Constants.FILE_EXTENSIONS))
         .toInstance("keywordstestlanguage");
 }
 // contributed by org.eclipse.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment
 public void configureHighlightingTokenDefProvider(com.google.inject.Binder binder) {
   binder
       .bind(org.eclipse.xtext.parser.antlr.ITokenDefProvider.class)
       .annotatedWith(
           com.google.inject.name.Names.named(org.eclipse.xtext.ui.LexerUIBindings.HIGHLIGHTING))
       .to(org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.class);
 }
 // contributed by org.eclipse.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment
 public void configureHighlightingLexer(com.google.inject.Binder binder) {
   binder
       .bind(org.eclipse.xtext.parser.antlr.Lexer.class)
       .annotatedWith(
           com.google.inject.name.Names.named(org.eclipse.xtext.ui.LexerUIBindings.HIGHLIGHTING))
       .to(com.concur.babel.parser.antlr.internal.InternalBabelIdlLexer.class);
 }
 // contributed by org.eclipse.xtext.generator.parser.antlr.XtextAntlrUiGeneratorFragment
 public void configureContentAssistLexer(com.google.inject.Binder binder) {
   binder
       .bind(org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.class)
       .annotatedWith(
           com.google.inject.name.Names.named(org.eclipse.xtext.ui.LexerUIBindings.CONTENT_ASSIST))
       .to(com.concur.babel.ui.contentassist.antlr.internal.InternalBabelIdlLexer.class);
 }
 // contributed by org.eclipse.xtext.generator.parser.antlr.XtextAntlrUiGeneratorFragment
 public void configureContentAssistLexerProvider(com.google.inject.Binder binder) {
   binder
       .bind(com.concur.babel.ui.contentassist.antlr.internal.InternalBabelIdlLexer.class)
       .toProvider(
           org.eclipse.xtext.parser.antlr.LexerProvider.create(
               com.concur.babel.ui.contentassist.antlr.internal.InternalBabelIdlLexer.class));
 }
Example #30
0
 // contributed by org.eclipse.xtext.generator.parser.antlr.XtextAntlrUiGeneratorFragment
 public void configureContentAssistLexerProvider(com.google.inject.Binder binder) {
   binder
       .bind(org.xtext.editor.yang.ui.contentassist.antlr.internal.InternalYangLexer.class)
       .toProvider(
           org.eclipse.xtext.parser.antlr.LexerProvider.create(
               org.xtext.editor.yang.ui.contentassist.antlr.internal.InternalYangLexer.class));
 }