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"));
  }
  @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 #3
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("")

  }
  @Override
  public void setup(Binder binder) {
    bindConfig(binder).to(DiscoveryConfig.class);
    jaxrsBinder(binder).bind(ServiceResource.class).withApplicationPrefix();
    binder.bind(InitializationTracker.class).in(Scopes.SINGLETON);

    discoveryBinder(binder).bindHttpAnnouncement("discovery");

    // dynamic announcements
    jaxrsBinder(binder).bind(DynamicAnnouncementResource.class).withApplicationPrefix();
    binder.bind(DynamicStore.class).to(ReplicatedDynamicStore.class).in(Scopes.SINGLETON);
    binder.install(
        new ReplicatedStoreModule("dynamic", ForDynamicStore.class, InMemoryStore.class));

    // static announcements
    jaxrsBinder(binder).bind(StaticAnnouncementResource.class).withApplicationPrefix();
    binder.bind(StaticStore.class).to(ReplicatedStaticStore.class).in(Scopes.SINGLETON);
    binder.install(
        new ReplicatedStoreModule("static", ForStaticStore.class, PersistentStore.class));
    bindConfig(binder).prefixedWith("static").to(PersistentStoreConfig.class);

    // config-based static announcements
    binder.bind(ConfigStore.class).in(Scopes.SINGLETON);
    bindConfig(binder).to(ConfigStoreConfig.class);

    // proxy announcements
    DiscoveryConfig discoveryConfig = buildConfigObject(DiscoveryConfig.class);
    if (!discoveryConfig.getProxyUris().isEmpty()) {
      httpClientBinder(binder)
          .bindBalancingHttpClient(
              "discovery.proxy", ForProxyStore.class, discoveryConfig.getProxyUris());
    }
    binder.bind(ProxyStore.class).in(Scopes.SINGLETON);
  }
  @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?");
    }
  }
Example #6
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);
 }
Example #7
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 #8
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 #9
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 #10
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));
 }
 @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 #12
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));
 }
Example #13
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);
 }
 // 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);
   }
   ;
 }
Example #15
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 #16
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);
  }
  @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 #19
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");
  }
Example #20
0
 @Override
 public void configureHighlightingTokenDefProvider(Binder binder) {
   binder
       .bind(ITokenDefProvider.class)
       .annotatedWith(Names.named(LexerIdeBindings.HIGHLIGHTING))
       .to(TemplatesTokenDefProvider.class);
 }
 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 #26
0
 // 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.lowcoupling.mdpm.lng.plan.parser.antlr.internal.InternalPlanLexer.class);
 }
Example #27
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));
 }
 // 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(org.xtext.example.mydsl.extensions.parser.antlr.internal.InternalMyDslLexer.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(net.certware.argument.sfp.parser.antlr.internal.InternalSemiFormalProofLexer.class);
 }
Example #30
0
 @Override
 public void configureLanguageSpecificURIEditorOpener(Binder binder) {
   binder
       .bind(IURIEditorOpener.class)
       .annotatedWith(LanguageSpecific.class)
       .to(ViewsEditorOpener.class);
 }