下面列出了怎么用com.google.inject.multibindings.MapBinder的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void configure(Binder binder)
{
binder.bind(PortBinder.class);
binder.bind(EnvironmentFactory.class);
binder.bind(Standard.class);
binder.bind(Hadoop.class);
binder.bind(Kerberos.class);
binder.bind(KerberosKms.class);
binder.bind(Kafka.class);
MapBinder<String, EnvironmentProvider> environments = newMapBinder(binder, String.class, EnvironmentProvider.class);
Environments.findByBasePackage(BASE_PACKAGE).forEach(clazz -> environments.addBinding(Environments.nameForClass(clazz)).to(clazz));
binder.install(additionalEnvironments);
}
@Override
protected void configure() {
// No Session Listeners
Multibinder<SessionListener> slBindings = Multibinder.newSetBinder(binder(), SessionListener.class);
// Bind Http Handlers
Multibinder<RequestHandler> rhBindings = Multibinder.newSetBinder(binder(), RequestHandler.class);
rhBindings.addBinding().to(RootRedirect.class);
rhBindings.addBinding().to(IndexPage.class);
rhBindings.addBinding().to(CheckPage.class);
rhBindings.addBinding().to(RecurlyCallbackHttpHandler.class);
bind(RequestAuthorizer.class)
.annotatedWith(Names.named("SessionAuthorizer"))
.to(AlwaysAllow.class);
MapBinder<String,WebhookHandler<? extends Object>> actionBinder = MapBinder.newMapBinder(binder(),new TypeLiteral<String>(){},new TypeLiteral<WebhookHandler<? extends Object>>(){});
actionBinder.addBinding(RecurlyCallbackHttpHandler.TRANS_TYPE_CLOSED_INVOICE_NOTIFICATION).to(ClosedInvoiceWebhookHandler.class);
// use the BaseHandler because it isn't abstract as the name implies, its just doesn't fully support websockets
bind(ChannelInboundHandler.class).toProvider(BaseWebSocketServerHandlerProvider.class);
// TODO bind this up into a WebSocket / NoWebSocket module...
bind(RequestMatcher.class).annotatedWith(Names.named("WebSocketUpgradeMatcher")).to(NeverMatcher.class);
}
@Override
protected void configure() {
bind(CompilerRegistry.class);
bind(CompilerUtils.class);
bind(MarkdownProcessor.class).to(PegDownMarkdownProcessor.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder()
.implement(ProtoCompiler.class, StCompiler.class)
.build(StCompilerFactory.class));
install(new FactoryModuleBuilder()
.implement(ProtoCompiler.class, ExtensibleStCompiler.class)
.build(ExtensibleStCompilerFactory.class));
Multibinder<HtmlCompiler> htmlCompilerBinder = Multibinder.newSetBinder(binder(), HtmlCompiler.class);
htmlCompilerBinder.addBinding().to(JsonIndexGenerator.class);
htmlCompilerBinder.addBinding().to(JsonEnumGenerator.class);
htmlCompilerBinder.addBinding().to(JsonMessageGenerator.class);
htmlCompilerBinder.addBinding().to(JsonServiceGenerator.class);
htmlCompilerBinder.addBinding().to(JsonProtoGenerator.class);
htmlCompilerBinder.addBinding().to(JsonPagesIndexGenerator.class);
htmlCompilerBinder.addBinding().to(JsonPageGenerator.class);
MapBinder<String, ProtoCompiler> compilers = newMapBinder(binder(), String.class, ProtoCompiler.class);
compilers.addBinding(HTML_COMPILER).to(HtmlGenerator.class);
compilers.addBinding(JAVA_COMPILER).toProvider(JavaCompilerProvider.class);
compilers.addBinding(ST4_COMPILER).toProvider(St4CompilerProvider.class);
compilers.addBinding(DUMMY_COMPILER).to(DummyGenerator.class).in(Scopes.SINGLETON);
}
private void configureJwtProxySecureProvisioner(String infrastructure) {
install(new FactoryModuleBuilder().build(JwtProxyProvisionerFactory.class));
if (KubernetesInfrastructure.NAME.equals(infrastructure)) {
install(
new FactoryModuleBuilder()
.build(
new TypeLiteral<JwtProxySecureServerExposerFactory<KubernetesEnvironment>>() {}));
MapBinder.newMapBinder(
binder(),
new TypeLiteral<String>() {},
new TypeLiteral<SecureServerExposerFactory<KubernetesEnvironment>>() {})
.addBinding("jwtproxy")
.to(new TypeLiteral<JwtProxySecureServerExposerFactory<KubernetesEnvironment>>() {});
} else {
install(
new FactoryModuleBuilder()
.build(
new TypeLiteral<JwtProxySecureServerExposerFactory<OpenShiftEnvironment>>() {}));
MapBinder.newMapBinder(
binder(),
new TypeLiteral<String>() {},
new TypeLiteral<SecureServerExposerFactory<OpenShiftEnvironment>>() {})
.addBinding("jwtproxy")
.to(new TypeLiteral<JwtProxySecureServerExposerFactory<OpenShiftEnvironment>>() {});
}
}
private void initNormalizerPlugins() {
MapBinder<String, INormalizerProvider> parserNormalizerPlugins
= MapBinder.newMapBinder(binder(), String.class, INormalizerProvider.class);
parserNormalizerPlugins
.addBinding(PunctuationNormalizerProvider.ID)
.to(PunctuationNormalizerProvider.class);
parserNormalizerPlugins
.addBinding(ConvertSpecialCharacterNormalizerProvider.ID)
.to(ConvertSpecialCharacterNormalizerProvider.class);
parserNormalizerPlugins
.addBinding(ContractedWordNormalizerProvider.ID)
.to(ContractedWordNormalizerProvider.class);
parserNormalizerPlugins
.addBinding(RemoveUndefinedCharacterNormalizerProvider.ID)
.to(RemoveUndefinedCharacterNormalizerProvider.class);
}
private void initDictionaryPlugins() {
MapBinder<String, IDictionaryProvider> parserDictionaryPlugins
= MapBinder.newMapBinder(binder(), String.class, IDictionaryProvider.class);
parserDictionaryPlugins
.addBinding(IntegerDictionaryProvider.ID)
.to(IntegerDictionaryProvider.class);
parserDictionaryPlugins
.addBinding(DecimalDictionaryProvider.ID)
.to(DecimalDictionaryProvider.class);
parserDictionaryPlugins
.addBinding(OrdinalNumbersDictionaryProvider.ID)
.to(OrdinalNumbersDictionaryProvider.class);
parserDictionaryPlugins
.addBinding(PunctuationDictionaryProvider.ID)
.to(PunctuationDictionaryProvider.class);
parserDictionaryPlugins
.addBinding(TimeExpressionDictionaryProvider.ID)
.to(TimeExpressionDictionaryProvider.class);
parserDictionaryPlugins
.addBinding(EmailDictionaryProvider.ID)
.to(EmailDictionaryProvider.class);
parserDictionaryPlugins
.addBinding(RegularDictionaryProvider.ID)
.to(RegularDictionaryProvider.class);
}
/**
* Tests that a warning message is given when the actual type of an adapter
* could be precisely inferred from the binding, and the binding provides a
* type key as well.
*/
@Test
public void ensureSuperfluousKeyDetected() throws Exception {
Module module = new AbstractModule() {
@Override
protected void configure() {
install(new AdapterInjectionSupport());
// create map bindings for AdapterStore, which is an IAdaptable
MapBinder<AdapterKey<?>, Object> adapterMapBinder = AdapterMaps
.getAdapterMapBinder(binder(), AdapterStore.class);
// use raw type as key and target
adapterMapBinder.addBinding(AdapterKey.get(RawType.class))
.to(RawType.class);
}
};
AdapterStore adaptable = new AdapterStore();
List<String> issues = performInjection(adaptable, module);
assertEquals(1, issues.size());
// System.out.println(issues.get(0));
assertTrue(issues.get(0).contains("INFO"));
assertTrue(issues.get(0).contains(
"The redundant type key org.eclipse.gef.common.tests.AdapterInjectorTests$RawType may be omitted in the adapter key of the binding, using AdapterKey.defaultRole() instead."));
}
private static <T extends Statement> void bindDataDefinitionTask(
Binder binder,
MapBinder<Class<? extends Statement>, QueryExecutionFactory<?>> executionBinder,
Class<T> statement,
Class<? extends DataDefinitionTask<T>> task)
{
checkArgument(getAllQueryTypes().get(statement) == QueryType.DATA_DEFINITION);
var taskBinder = newMapBinder(binder, new TypeLiteral<Class<? extends Statement>>() {}, new TypeLiteral<DataDefinitionTask<?>>() {});
taskBinder.addBinding(statement).to(task).in(Scopes.SINGLETON);
executionBinder.addBinding(statement).to(DataDefinitionExecutionFactory.class).in(Scopes.SINGLETON);
}
@Override
public void configure(Binder binder)
{
MapBinder<String, RowDecoderFactory> decoderFactoriesByName = MapBinder.newMapBinder(binder, String.class, RowDecoderFactory.class);
decoderFactoriesByName.addBinding(DummyRowDecoder.NAME).to(DummyRowDecoderFactory.class).in(SINGLETON);
decoderFactoriesByName.addBinding(CsvRowDecoder.NAME).to(CsvRowDecoderFactory.class).in(SINGLETON);
decoderFactoriesByName.addBinding(JsonRowDecoder.NAME).to(JsonRowDecoderFactory.class).in(SINGLETON);
decoderFactoriesByName.addBinding(RawRowDecoder.NAME).to(RawRowDecoderFactory.class).in(SINGLETON);
decoderFactoriesByName.addBinding(AvroRowDecoder.NAME).to(AvroRowDecoderFactory.class).in(SINGLETON);
binder.bind(DispatchingRowDecoderFactory.class).in(SINGLETON);
}
@Override
protected void configure() {
install(new FactoryModuleBuilder().build(PropertiesPanelFactory.class));
install(new FactoryModuleBuilder().build(CellEditorFactory.class));
install(new FactoryModuleBuilder().build(PropertiesComponentsFactory.class));
MapBinder<Class<? extends AbstractComplexProperty>, DetailsDialogContent> dialogContentMapBinder
= MapBinder.newMapBinder(binder(),
new TypeLiteral<Class<? extends AbstractComplexProperty>>() {
},
new TypeLiteral<DetailsDialogContent>() {
});
dialogContentMapBinder
.addBinding(KeyValueProperty.class)
.to(KeyValuePropertyEditorPanel.class);
dialogContentMapBinder
.addBinding(KeyValueSetProperty.class)
.to(KeyValueSetPropertyEditorPanel.class);
dialogContentMapBinder
.addBinding(LocationTypeActionsProperty.class)
.to(LocationTypeActionsEditorPanel.class);
dialogContentMapBinder
.addBinding(LinkActionsProperty.class)
.to(LinkActionsEditorPanel.class);
dialogContentMapBinder
.addBinding(SymbolProperty.class)
.to(SymbolPropertyEditorPanel.class);
dialogContentMapBinder
.addBinding(OrderCategoriesProperty.class)
.to(OrderCategoriesPropertyEditorPanel.class);
bind(SelectionPropertiesComponent.class)
.in(Singleton.class);
}
@Override
protected void configure() {
MapBinder<String, ILoadBalancer> loadBalancers = MapBinder.newMapBinder(binder(), String.class, ILoadBalancer.class);
loadBalancers.addBinding("eureka").to(EurekaLoadBalancer.class);
loadBalancers.addBinding("static").to(StaticLoadBalancer.class);
MapBinder<String, ISuroClient> clientImpls = MapBinder.newMapBinder(binder(), String.class, ISuroClient.class);
clientImpls.addBinding("async").to(AsyncSuroClient.class).in(LazySingletonScope.get());
clientImpls.addBinding("sync").to(SyncSuroClient.class).in(LazySingletonScope.get());
bind(ISuroClient.class).toProvider(ConfigBasedSuroClientProvider.class);
bind(ILoadBalancer.class).toProvider(ConfigBasedLoadBalancerProvider.class);
}
@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);
}
/**
* Binds {@link DefaultHandlerResolver} as a domain adapter.
*
* @param adapterMapBinder
* The {@link MapBinder} that is used to add the binding.
*/
protected void bindIHandlerResolverAsIDomainAdapter(
MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
adapterMapBinder.addBinding(AdapterKey.defaultRole())
.to(IHandlerResolver.class)
.in(AdaptableScopes.typed(IDomain.class));
}
/**
* Adds (default) {@link AdapterMap} bindings for {@link IViewer} and all
* sub-classes. May be overwritten by sub-classes to change the default
* bindings.
*
* @param adapterMapBinder
* The {@link MapBinder} to be used for the binding registration.
* In this case, will be obtained from
* {@link AdapterMaps#getAdapterMapBinder(Binder, Class)} using
* {@link IViewer} as a key.
*
* @see AdapterMaps#getAdapterMapBinder(Binder, Class)
*/
protected void bindPaletteViewerAdapters(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
// viewer models
bindFocusModelAsPaletteViewerAdapter(adapterMapBinder);
bindHoverModelAsPaletteViewerAdapter(adapterMapBinder);
bindSelectionModelAsPaletteViewerAdapter(adapterMapBinder);
// root part
bindPaletteRootPartAsPaletteViewerAdapter(adapterMapBinder);
// feedback and handles factories
bindSelectionFeedbackFactoryAsPaletteViewerAdapter(adapterMapBinder);
bindFocusFeedbackFactoryAsPaletteViewerAdapter(adapterMapBinder);
bindHoverFeedbackFactoryAsPaletteViewerAdapter(adapterMapBinder);
bindSelectionHandleFactoryAsPaletteViewerAdapter(adapterMapBinder);
bindHoverHandleFactoryAsPaletteViewerAdapter(adapterMapBinder);
// content part factory and content part pool
bindContentPartPoolAsPaletteViewerAdapter(adapterMapBinder);
bindIContentPartFactoryAsPaletteViewerAdapter(adapterMapBinder);
// change hover feedback color by binding a respective provider
adapterMapBinder.addBinding(AdapterKey.role(DefaultHoverFeedbackPartFactory.HOVER_FEEDBACK_COLOR_PROVIDER))
.toInstance(new Provider<Color>() {
@Override
public Color get() {
return Color.WHITE;
}
});
}
/**
* Adds (default) adapter map bindings for {@link NodeLabelPart} and all
* sub-classes. May be overwritten by sub-classes to change the default
* bindings.
*
* @param adapterMapBinder
* The {@link MapBinder} to be used for the binding registration.
* In this case, will be obtained from
* {@link AdapterMaps#getAdapterMapBinder(Binder, Class)} using
* {@link NodeLabelPart} as a key.
*
* @see AdapterMaps#getAdapterMapBinder(Binder, Class)
*/
protected void bindNodeLabelPartAdapters(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
// selection link feedback provider
adapterMapBinder
.addBinding(
AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_LINK_FEEDBACK_GEOMETRY_PROVIDER))
.to(ShapeBoundsProvider.class);
// selection feedback provider
adapterMapBinder
.addBinding(AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_FEEDBACK_GEOMETRY_PROVIDER))
.to(ShapeBoundsProvider.class);
// hover feedback provider
adapterMapBinder.addBinding(AdapterKey.role(DefaultHoverFeedbackPartFactory.HOVER_FEEDBACK_GEOMETRY_PROVIDER))
.to(ShapeBoundsProvider.class);
// transform policy
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TransformLabelPolicy.class);
// hover on-hover policy
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(HoverOnHoverHandler.class);
// translate on drag
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TranslateSelectedOnDragHandler.class);
}
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())));
}
@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);
}
@Override
protected void configure() {
LOG.debug("Configuring Bobcat module: {}", getClass().getSimpleName());
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);
}
@Override
protected void configure() {
MapBinder<String, DiagnosticInfoCollector> diagnosticInfoCollectorMapBinder = MapBinder.newMapBinder(binder(),
String.class, DiagnosticInfoCollector.class);
for (Map.Entry<String, Class<? extends DiagnosticInfoCollector>> diagnosticInfoCollectorEntry :
diagnosticInfoCollectorClasses.entrySet()) {
diagnosticInfoCollectorMapBinder.addBinding(diagnosticInfoCollectorEntry.getKey()).to(
diagnosticInfoCollectorEntry.getValue());
}
bind(DiagnosticManager.class).toInstance(diagnosticManager);
}
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())));
}
@SuppressWarnings("unchecked")
@Override
protected void configure() {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
try {
cfg = mapper.readValue(Thread.currentThread().getContextClassLoader().getResource("myriad-config-test-default.yml"),
MyriadConfiguration.class);
} catch (IOException e1) {
LOGGER.error("IOException", e1);
return;
}
if (cfg == null) {
return;
}
bind(MyriadConfiguration.class).toInstance(cfg);
MapBinder<String, TaskFactory> mapBinder = MapBinder.newMapBinder(binder(), String.class, TaskFactory.class);
mapBinder.addBinding(NodeManagerConfiguration.DEFAULT_NM_TASK_PREFIX).to(NMTaskFactory.class).in(Scopes.SINGLETON);
Map<String, ServiceConfiguration> auxServicesConfigs = cfg.getServiceConfigurations();
for (Map.Entry<String, ServiceConfiguration> entry : auxServicesConfigs.entrySet()) {
String taskFactoryClass = entry.getValue().getTaskFactoryImplName().orNull();
if (taskFactoryClass != null) {
try {
Class<? extends TaskFactory> implClass = (Class<? extends TaskFactory>) Class.forName(taskFactoryClass);
mapBinder.addBinding(entry.getKey()).to(implClass).in(Scopes.SINGLETON);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
} else {
mapBinder.addBinding(entry.getKey()).to(ServiceTaskFactory.class).in(Scopes.SINGLETON);
}
}
}
@Override
protected void bindIViewerAdaptersForContentViewer(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
super.bindIViewerAdaptersForContentViewer(adapterMapBinder);
bindNavigationModelAsContentViewerAdapter(adapterMapBinder);
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(HidingModel.class);
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(LabelOffsetSupport.class);
}
@Override
protected void configure() {
MapBinder<String, ActionWithData> slingPageActions =
MapBinder.newMapBinder(binder(), String.class, ActionWithData.class);
slingPageActions.addBinding(AemActions.CREATE_PAGE_VIA_SLING).to(CreatePage.class);
slingPageActions.addBinding(AemActions.DELETE_PAGE_VIA_SLING).to(DeletePage.class);
}
/**
* Adds (default) adapter map bindings for {@link EdgeLabelPart} and all
* sub-classes. May be overwritten by sub-classes to change the default
* bindings.
*
* @param adapterMapBinder
* The {@link MapBinder} to be used for the binding registration.
* In this case, will be obtained from
* {@link AdapterMaps#getAdapterMapBinder(Binder, Class)} using
* {@link EdgeLabelPart} as a key.
*
* @see AdapterMaps#getAdapterMapBinder(Binder, Class)
*/
protected void bindEdgeLabelPartAdapters(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
// selection link feedback provider
adapterMapBinder
.addBinding(
AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_LINK_FEEDBACK_GEOMETRY_PROVIDER))
.to(ShapeBoundsProvider.class);
// selection feedback provider
adapterMapBinder
.addBinding(AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_FEEDBACK_GEOMETRY_PROVIDER))
.to(ShapeBoundsProvider.class);
// hover feedback provider
adapterMapBinder.addBinding(AdapterKey.role(DefaultHoverFeedbackPartFactory.HOVER_FEEDBACK_GEOMETRY_PROVIDER))
.to(ShapeBoundsProvider.class);
// transform policy
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TransformLabelPolicy.class);
// hiding behavior
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(EdgeLabelHidingBehavior.class);
// hover on-hover policy
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(HoverOnHoverHandler.class);
// translate on drag
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TranslateSelectedOnDragHandler.class);
}
protected void bindAnchorageAdapters(final MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
// transform policy
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TransformPolicy.class);
// relocate on drag
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TranslateSelectedOnDragHandler.class);
// bind dynamic anchor provider
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TestAnchorProvider.class);
}
public <T> void addMapBinding(final Class<T> valueClass, final Object key, final Class<? extends T> to)
{
if (null == key || null == to)
throw new NullPointerException();
this.bindings.add(new BindingAction()
{
@Override
public void bind(Binder b)
{
MapBinder mapBinder = MapBinder.newMapBinder(b, key.getClass(), valueClass);
mapBinder.addBinding(key).to(to);
}
});
}
@Override
protected void configure() {
MapBinder<String, ModuleType> prefixModuleBindings = MapBinder.newMapBinder(binder(), String.class, ModuleType.class);
prefixModuleBindings.addBinding("yql.sequences").to(SequenceBuiltinsModule.class);
prefixModuleBindings.addBinding("yql.conditionals").to(ConditionalsBuiltinsModule.class);
prefixModuleBindings.addBinding("yql.records").to(RecordsBuiltinsModule.class);
}
@Override
protected void configure() {
MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
MapBinder<String, Exports> exportsBindings = MapBinder.newMapBinder(binder(), String.class, Exports.class);
Multibinder<SourceNamespace> sourceNamespaceMultibinder = Multibinder.newSetBinder(binder(), SourceNamespace.class);
Multibinder<ModuleNamespace> moduleNamespaceMultibinder = Multibinder.newSetBinder(binder(), ModuleNamespace.class);
sourceNamespaceMultibinder.addBinding().to(MultibinderPlannerNamespace.class);
moduleNamespaceMultibinder.addBinding().to(MultibinderPlannerNamespace.class);
}
@Override
protected void configure() {
install(new JavaEngineModule());
install(metricModule);
MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
sourceBindings.addBinding("minions").toInstance(new MinionSource(ImmutableList.of(new Minion("1", "2"), new Minion("1", "3"))));
sourceBindings.addBinding("people").toInstance(new PersonSource(ImmutableList.of(new Person("1", "bob", 0), new Person("2", "joe", 1), new Person("3", "smith", 2))));
sourceBindings.addBinding("citizen").toInstance(new CitizenSource(ImmutableList.of(new Citizen("1", "German"), new Citizen("2", "Italian"), new Citizen("3", "U.S. American"))));
sourceBindings.addBinding("peopleWithNullId").toInstance(new PersonSource(ImmutableList.of(new Person(null, "bob", 0), new Person("2", "joe", 1), new Person("3", "smith", 2))));
sourceBindings.addBinding("peopleWithEmptyId").toInstance(new PersonSource(ImmutableList.of(new Person("", "bob", 0), new Person("2", "joe", 1), new Person("3", "smith", 2))));
sourceBindings.addBinding("moreMinions").toInstance(new MinionSource(ImmutableList.of(new Minion("1", "2"), new Minion("1", "3"), new Minion("2", "1"))));
sourceBindings.addBinding("minionsWithSkipNullSetToFalse").toInstance(new MinionSourceWithSkipNullSetToFalse(ImmutableList.of(new Minion(null, "2"), new Minion("1", "3"), new Minion("2", "1"))));
sourceBindings.addBinding("noMatchMinions").toInstance(new MinionSource(ImmutableList.of(new Minion("4", "2"), new Minion("4", "3"), new Minion("5", "1"))));
sourceBindings.addBinding("images").toInstance(new ImageSource(ImmutableList.of(new Image("1", "1.jpg"), new Image("3", "3.jpg"))));
sourceBindings.addBinding("innersource").to(InnerSource.class);
sourceBindings.addBinding("asyncsource").to(AsyncSource.class);
sourceBindings.addBinding("trace").to(TracingSource.class);
sourceBindings.addBinding("mapsource").to(MapSource.class);
sourceBindings.addBinding("mapArgumentSource").to(MapArgumentSource.class);
sourceBindings.addBinding("personList").toInstance(new PersonListMakeSource());
bind(ViewRegistry.class).toInstance(new ViewRegistry() {
@Override
public OperatorNode<SequenceOperator> getView(List<String> name) {
return null;
}
});
}
@Override
protected void configure() {
bind(IBehaviorDeserialization.class).to(BehaviorDeserialization.class).in(Scopes.SINGLETON);
MapBinder<String, ILifecycleTask> lifecycleTaskPlugins
= MapBinder.newMapBinder(binder(), String.class, ILifecycleTask.class);
lifecycleTaskPlugins.addBinding("ai.labs.behavior").to(BehaviorRulesEvaluationTask.class);
MapBinder<String, IBehaviorCondition> behaviorConditionPlugins
= MapBinder.newMapBinder(binder(), String.class, IBehaviorCondition.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.inputmatcher").
to(InputMatcher.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.actionmatcher").
to(ActionMatcher.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.contextmatcher").
to(ContextMatcher.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.dynamicvaluematcher").
to(DynamicValueMatcher.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.connector").
to(Connector.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.dependency").
to(Dependency.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.negation").
to(Negation.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.occurrence").
to(Occurrence.class);
behaviorConditionPlugins.addBinding("ai.labs.behavior.conditions.sizematcher").
to(SizeMatcher.class);
}