Java Code Examples for com.google.inject.multibindings.MapBinder#newMapBinder()

The following examples show how to use com.google.inject.multibindings.MapBinder#newMapBinder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventModule.java    From linstor-server with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void configure()
{
    bind(WatchStore.class).to(WatchStoreImpl.class);

    MapBinder<String, EventSerializer> eventSerializerBinder =
        MapBinder.newMapBinder(binder(), String.class, EventSerializer.class);
    MapBinder<String, EventSerializerDescriptor> eventSerializerDescriptorBinder =
        MapBinder.newMapBinder(binder(), String.class, EventSerializerDescriptor.class);
    for (Class<? extends EventSerializer> eventSerializer : eventSerializers)
    {
        EventSerializerDescriptor descriptor = new EventSerializerDescriptor(eventSerializer);
        eventSerializerBinder.addBinding(descriptor.getEventName()).to(eventSerializer);
        eventSerializerDescriptorBinder.addBinding(descriptor.getEventName()).toInstance(descriptor);
    }

    MapBinder<String, EventHandler> eventHandlerBinder =
        MapBinder.newMapBinder(binder(), String.class, EventHandler.class);
    for (Class<? extends EventHandler> eventHandler : eventHandlers)
    {
        eventHandlerBinder.addBinding(eventHandler.getAnnotation(ProtobufEventHandler.class).eventName())
            .to(eventHandler);
    }
}
 
Example 2
Source File: SpoofaxModule.java    From spoofax with Apache License 2.0 6 votes vote down vote up
@Override protected void configure() {
    super.configure();

    parserBinder = MapBinder.newMapBinder(binder(), new TypeLiteral<String>() {},
            new TypeLiteral<IParser<ISpoofaxInputUnit, ISpoofaxParseUnit>>() {});
    spoofaxParserBinder = MapBinder.newMapBinder(binder(), String.class, ISpoofaxParser.class);
    analyzerBinder = MapBinder.newMapBinder(binder(), new TypeLiteral<String>() {},
            new TypeLiteral<IAnalyzer<ISpoofaxParseUnit, ISpoofaxAnalyzeUnit, ISpoofaxAnalyzeUnitUpdate>>() {});
    spoofaxAnalyzerBinder = MapBinder.newMapBinder(binder(), String.class, ISpoofaxAnalyzer.class);

    Multibinder.newSetBinder(binder(), ClassLoader.class).permitDuplicates();

    bindUnit();
    bindSyntax();
    bindParsers(parserBinder, spoofaxParserBinder);
    bindAnalyzers(analyzerBinder, spoofaxAnalyzerBinder);
    bindCompletion();
    bindAction();
    bindTransformer();
    bindCategorizer();
    bindStyler();
    bindTracing();
    bindOutline();
    bindMenu();
    bindDialog();
}
 
Example 3
Source File: SemanticParserModule.java    From EDDI with Apache License 2.0 6 votes vote down vote up
private void initCorrectionPlugins() {
    MapBinder<String, ICorrectionProvider> parserCorrectionPlugins
            = MapBinder.newMapBinder(binder(), String.class, ICorrectionProvider.class);
    parserCorrectionPlugins
            .addBinding(DamerauLevenshteinCorrectionProvider.ID)
            .to(DamerauLevenshteinCorrectionProvider.class);
    parserCorrectionPlugins
            .addBinding(StemmingCorrectionProvider.ID)
            .to(StemmingCorrectionProvider.class);
    parserCorrectionPlugins
            .addBinding(PhoneticCorrectionProvider.ID)
            .to(PhoneticCorrectionProvider.class);
    parserCorrectionPlugins
            .addBinding(MergedTermsCorrectionProvider.ID)
            .to(MergedTermsCorrectionProvider.class);
}
 
Example 4
Source File: AemComponentModule.java    From bobcat with Apache License 2.0 5 votes vote down vote up
private void bindCommonToolbarOptions() {
  MapBinder<String, ToolbarOption> toolbarOptions =
      MapBinder.newMapBinder(binder(), String.class, ToolbarOption.class);
  Arrays.stream(CommonToolbarOptions.values()).forEach(
      option -> toolbarOptions.addBinding(option.getTitle())
          .toInstance(new CommonToolbarOption(option.getTitle())));
}
 
Example 5
Source File: OutputGenerationModule.java    From EDDI with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(IOutputGeneration.class).to(OutputGeneration.class);

    MapBinder<String, ILifecycleTask> lifecycleTaskPlugins
            = MapBinder.newMapBinder(binder(), String.class, ILifecycleTask.class);
    lifecycleTaskPlugins.addBinding("ai.labs.output").to(OutputGenerationTask.class);
}
 
Example 6
Source File: AemSitesAdminModule.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  bind(SiteToolbar.class).to(SiteToolbarImpl.class);
  bind(TemplateList.class).to(TemplateListImpl.class);
  bind(CreatePageWizard.class).to(CreatePageWizardImpl.class);
  bind(CreatePageProperties.class).to(CreatePagePropertiesImpl.class);

  MapBinder<String, ActionWithData> siteAdminActions =
      MapBinder.newMapBinder(binder(), String.class, ActionWithData.class);
  siteAdminActions.addBinding(AemActions.CREATE_PAGE_VIA_SITEADMIN).to(CreatePageAction.class);
}
 
Example 7
Source File: AemLoginModule.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  bind(AemAuthCookieFactory.class).to(AemAuthCookieFactoryImpl.class);

  MapBinder<String, Action> siteAdminActions =
      MapBinder.newMapBinder(binder(), String.class, Action.class);
  siteAdminActions.addBinding(AemActions.LOG_IN).to(LogIn.class);
  siteAdminActions.addBinding(AemActions.LOG_OUT).to(LogOut.class);
}
 
Example 8
Source File: AlexaModule.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
   MapBinder<String, ProactiveReportHandler> handlers = MapBinder.newMapBinder(binder(), KEY_LITERAL, VALUE_LITERAL);
   handlers.addBinding(VoiceService.StartPlaceRequest.ASSISTANT_ALEXA).to(AlexaProactiveReportHandler.class);

   Multibinder<VoiceProvider> providerMultibinder = bindSetOf(VoiceProvider.class);
   providerMultibinder.addBinding().to(AlexaService.class);
}
 
Example 9
Source File: DefaultKernelInjectionModule.java    From openAGV with Apache License 2.0 5 votes vote down vote up
private void configureKernelStatesDependencies() {
  // A map for KernelState instances to be provided at runtime.
  MapBinder<Kernel.State, KernelState> stateMapBinder
      = MapBinder.newMapBinder(binder(), Kernel.State.class, KernelState.class);
  stateMapBinder.addBinding(Kernel.State.SHUTDOWN).to(KernelStateShutdown.class);
  stateMapBinder.addBinding(Kernel.State.MODELLING).to(KernelStateModelling.class);
  stateMapBinder.addBinding(Kernel.State.OPERATING).to(KernelStateOperating.class);

  bind(OrderPoolConfiguration.class)
      .toInstance(getConfigBindingProvider().get(OrderPoolConfiguration.PREFIX,
                                                 OrderPoolConfiguration.class));

  transportOrderCleanupApprovalBinder();
  orderSequenceCleanupApprovalBinder();
}
 
Example 10
Source File: AemSitesAdminModule.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  LOG.debug("Configuring Bobcat module: {}", getClass().getSimpleName());

  bind(SiteToolbar.class).to(SiteToolbarImpl.class);
  bind(TemplateList.class).to(TemplateListImpl.class);
  bind(CreatePageWizard.class).to(CreatePageWizardImpl.class);
  bind(CreatePageProperties.class).to(CreatePagePropertiesImpl.class);

  MapBinder<String, ActionWithData> siteAdminActions =
      MapBinder.newMapBinder(binder(), String.class, ActionWithData.class);
  siteAdminActions.addBinding(AemActions.CREATE_PAGE_VIA_SITEADMIN).to(CreatePageAction.class);
}
 
Example 11
Source File: JeeJoynrIntegrationModule.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(JoynrRuntime.class).to(ClusterControllerRuntime.class).in(Singleton.class);
    bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_DISCOVERY_GLOBAL_ADD_AND_REMOVE_TTL_MS))
                    .toInstance(jeeGlobalAddAndRemoveTtlMs);

    bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL))
                                        .toInstance(scheduledExecutorService);
    bind(ScheduledExecutorService.class).annotatedWith(Names.named(JoynrInjectionConstants.JOYNR_SCHEDULER_CLEANUP))
                                        .toInstance(scheduledExecutorService);
    bind(ScheduledExecutorService.class).annotatedWith(Names.named(LocalCapabilitiesDirectory.JOYNR_SCHEDULER_CAPABILITIES_FRESHNESS))
                                        .toInstance(scheduledExecutorService);
    bind(ExecutorService.class).toInstance(scheduledExecutorService);

    MapBinder<Class<? extends Address>, IMessagingSkeletonFactory> messagingSkeletonFactory;
    messagingSkeletonFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
    }, new TypeLiteral<IMessagingSkeletonFactory>() {
    }, Names.named(MessagingSkeletonFactory.MIDDLEWARE_MESSAGING_SKELETON_FACTORIES));

    MapBinder<Class<? extends Address>, AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>> messagingStubFactory;
    messagingStubFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
    }, new TypeLiteral<AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>>() {
    }, Names.named(MessagingStubFactory.MIDDLEWARE_MESSAGING_STUB_FACTORIES));

    Multibinder.newSetBinder(binder(), JoynrMessageProcessor.class);

    install(new JeeHttpMessagingModule(messagingSkeletonFactory, messagingStubFactory));
    install(new HttpBridgeEndpointRegistryClientModule());
    install(new JeeMqttMessageSendingModule(messagingSkeletonFactory, messagingStubFactory));
}
 
Example 12
Source File: MultibindingsModule.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Override
protected void configure() {
    final Multibinder<Plugin> pluginMultibinder = Multibinder.newSetBinder(binder(), Plugin.class);
    pluginMultibinder.addBinding().to(MyPlugin.class);
    pluginMultibinder.addBinding().toInstance(new MyPlugin2());

    final MapBinder<String, KeyedPlugin> keyedPluginMapBinder =
            MapBinder.newMapBinder(binder(), String.class, KeyedPlugin.class);
    keyedPluginMapBinder.addBinding("foo").to(MyKeyedPlugin.class);
    keyedPluginMapBinder.addBinding("bar").toInstance(new MyKeyedPlugin2());
    
    OptionalBinder.newOptionalBinder(binder(), OptService.class).setDefault().to(DefImpl.class);
    install(new OverideModule());
}
 
Example 13
Source File: SourceModule1.java    From yql-plus with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
    sourceBindings.addBinding("simple").to(SimpleSource.class);
}
 
Example 14
Source File: NotificationModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    bind(Dispatcher.class).to(NotificationDispatcher.class);
    bind(NotificationAuditor.class).to(CassandraAuditor.class);
    bind(RetryManager.class).to(BackoffRetryManager.class);
    bind(RetryProcessor.class).to(ScheduledRetryProcessor.class);
    bind(NotificationMessageRenderer.class).to(TemplateMessageRenderer.class);
    bind(NotificationProviderRegistry.class).to(MapNotificationProviderRegistry.class);

    switch (apnsSender) {
    default:
       logger.warn("unknown apns sender implementation {}: using default instead");
       // fall through
       
    case "default":
    case "pushy":
       logger.info("using pushy apns sender");
       bind(ApnsSender.class).to(PushyApnsSender.class);
       break;

    case "noop":
       logger.warn("using noop apns sender");
       bind(ApnsSender.class).to(NoopApnsSender.class);
       break;
    }

    switch (gcmSender) {
    default:
       logger.warn("unknown gcm sender implementation {}: using default instead");
       // fall through
       
    case "default":
    case "smack":
       logger.info("using smack gcm sender");
       bind(GcmSender.class).to(SmackGcmSender.class);
       break;

    case "noop":
       logger.warn("using noop gcm sender");
       bind(GcmSender.class).to(NoopGcmSender.class);
       break;
    }

    bind(UpstreamNotificationResponder.class).to(IrisUpstreamNotificationResponder.class);
    bind(NotificationService.class).asEagerSingleton();

    MapBinder<String, NotificationProvider> registryBinder = MapBinder.newMapBinder(binder(), String.class, NotificationProvider.class);
    registryBinder.addBinding("LOG").to(LogProvider.class);
    registryBinder.addBinding("GCM").to(GCMProvider.class);
    registryBinder.addBinding("APNS").to(ApnsProvider.class);
    registryBinder.addBinding("EMAIL").to(EmailProvider.class);
    registryBinder.addBinding("IVR").to(IVRProvider.class);
    registryBinder.addBinding("WEBHOOK").to(WebhookProvider.class);
}
 
Example 15
Source File: DeviceBrokerModule.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Override
public void configure() {

  bindConstant()
      .annotatedWith(ResourceDexdumpName.class)
  .to("/com/google/android/apps/common/testing/broker/dexdump_annotations");

  bindConstant()
      .annotatedWith(TestServicesApkResourceName.class)
      .to(
              "/services/test_services.apk");

  bindConstant()
      .annotatedWith(OdoApkResourceName.class)
      .to(
              "/runner/android_test_orchestrator/stubapp/stubapp.apk");

  bind(AdbController.AdbControllerFactory.class).to(AdbController.FullControlAdbControllerFactory.class);

  bind(String.class)
      .annotatedWith(ExecutorLocation.class)
      .toProvider(
          new ResourceProvider(
              Providers.of("/com/google/android/apps/common/testing/broker/executor.sh")))
      .in(Scopes.SINGLETON);

  bind(String.class).annotatedWith(OdoApkLocation.class).toProvider(
      new ResourceProvider(getProvider(Key.get(String.class, OdoApkResourceName.class))))
      .in(Scopes.SINGLETON);

  bind(String.class)
      .annotatedWith(TestServicesApkLocation.class)
      .toProvider(
          new ResourceProvider(
              getProvider(Key.get(String.class, TestServicesApkResourceName.class))))
      .in(Scopes.SINGLETON);

  bind(String.class).annotatedWith(ResourceDexdumpPath.class).toProvider(
      new ResourceProvider(getProvider(Key.get(String.class, ResourceDexdumpName.class))))
      .in(Scopes.SINGLETON);

  Multibinder.newSetBinder(binder(), DeviceBrokerDecorator.class);
  MapBinder.newMapBinder(binder(), DeviceBrokerType.class, DeviceBroker.class);

  MapBinder<String, String> adbEnv =
      MapBinder.newMapBinder(binder(), String.class, String.class, AdbEnvironment.class);
  adbEnv.addBinding(ENVIRONMENT_KEY_ANDROID_ADB).to(Key.get(String.class, AdbPath.class));
}
 
Example 16
Source File: ScoreKBPAgainstERE.java    From tac-kbp-eal with MIT License 4 votes vote down vote up
public static MapBinder<String, ScoringEventObserver<DocLevelEventArg, DocLevelEventArg>> docLevelEventArgObserverBindingSite(final Binder binder) {
  return MapBinder.newMapBinder(binder, TypeLiteral.get(String.class),
      new TypeLiteral<ScoringEventObserver<DocLevelEventArg, DocLevelEventArg>>() {
      });
}
 
Example 17
Source File: AbstractIrisModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected <K, V> MapBinder<K, V> bindMapOf(TypeLiteral<K> keyType, TypeLiteral<V> valueType) {
	return MapBinder.newMapBinder(binder(), keyType, valueType);
}
 
Example 18
Source File: DateTimeTest.java    From yql-plus with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    MapBinder<String, Exports> exportsBindings = MapBinder.newMapBinder(binder(), String.class, Exports.class);
    exportsBindings.addBinding("mydummymodule").to(MyDummyExport.class);
}
 
Example 19
Source File: WrappedBrokerModule.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
  MapBinder<DeviceBrokerType, DeviceBroker> mapbinder =
      MapBinder.newMapBinder(binder(), DeviceBrokerType.class, DeviceBroker.class);
  mapbinder.addBinding(DeviceBrokerType.WRAPPED_EMULATOR).to(WrappedEmulatedDeviceBroker.class);
}
 
Example 20
Source File: ProtocolModule.java    From bt with Apache License 2.0 3 votes vote down vote up
/**
 * Contribute a message handler for some extended message type.
 * <p>See BEP-10 for details on protocol extensions.
 * <p>Binding key is a unique message type ID, that will be communicated to a peer
 * during the extended handshake procedure in the 'm' dictionary of an extended handshake message.
 *
 * @since 1.0
 * @deprecated since 1.5 in favor of {@link ProtocolModuleExtender#addExtendedMessageHandler(String, Class)}
 *             and its' overloaded versions
 */
@Deprecated
public static MapBinder<String, MessageHandler<? extends ExtendedMessage>> contributeExtendedMessageHandler(Binder binder) {
    return MapBinder.newMapBinder(
            binder,
            new TypeLiteral<String>(){},
            new TypeLiteral<MessageHandler<? extends ExtendedMessage>>(){},
            ExtendedMessageHandlers.class);
}