当前位置: 首页>>代码示例>>Java>>正文


Java AbstractModule类代码示例

本文整理汇总了Java中org.elasticsearch.common.inject.AbstractModule的典型用法代码示例。如果您正苦于以下问题:Java AbstractModule类的具体用法?Java AbstractModule怎么用?Java AbstractModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbstractModule类属于org.elasticsearch.common.inject包,在下文中一共展示了AbstractModule类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RecordingBinder

import org.elasticsearch.common.inject.AbstractModule; //导入依赖的package包/类
private RecordingBinder(Stage stage) {
    this.stage = stage;
    this.modules = new HashSet<>();
    this.elements = new ArrayList<>();
    this.source = null;
    this.sourceProvider = new SourceProvider().plusSkippedClasses(
            Elements.class, RecordingBinder.class, AbstractModule.class,
            ConstantBindingBuilderImpl.class, AbstractBindingBuilder.class, BindingBuilder.class);
    this.parent = null;
    this.privateElements = null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:Elements.java

示例2: RecordingBinder

import org.elasticsearch.common.inject.AbstractModule; //导入依赖的package包/类
private RecordingBinder(Stage stage) {
    this.stage = stage;
    this.modules = Sets.newHashSet();
    this.elements = new ArrayList<>();
    this.source = null;
    this.sourceProvider = new SourceProvider().plusSkippedClasses(
            Elements.class, RecordingBinder.class, AbstractModule.class,
            ConstantBindingBuilderImpl.class, AbstractBindingBuilder.class, BindingBuilder.class);
    this.parent = null;
    this.privateElements = null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:Elements.java

示例3: getBindingFromNewInjector

import org.elasticsearch.common.inject.AbstractModule; //导入依赖的package包/类
/**
 * Creates a child injector that binds the args, and returns the binding for the method's result.
 */
public Binding<?> getBindingFromNewInjector(final Method method, final Object[] args) {
    checkState(injector != null,
            "Factories.create() factories cannot be used until they're initialized by Guice.");

    final Key<?> returnType = returnTypesByMethod.get(method);

    Module assistedModule = new AbstractModule() {
        @Override
        @SuppressWarnings("unchecked") // raw keys are necessary for the args array and return value
        protected void configure() {
            Binder binder = binder().withSource(method);

            int p = 0;
            for (Key<?> paramKey : paramTypes.get(method)) {
                // Wrap in a Provider to cover null, and to prevent Guice from injecting the parameter
                binder.bind((Key) paramKey).toProvider(Providers.of(args[p++]));
            }

            if (producedType != null && !returnType.equals(producedType)) {
                binder.bind(returnType).to((Key) producedType);
            } else {
                binder.bind(returnType);
            }
        }
    };

    Injector forCreate = injector.createChildInjector(assistedModule);
    return forCreate.getBinding(returnType);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:FactoryProvider2.java

示例4: createGuiceModules

import org.elasticsearch.common.inject.AbstractModule; //导入依赖的package包/类
@Override
public Collection<Module> createGuiceModules() {
    LOGGER.info("Registering new scalar function using MapBinder");
    return Collections.singletonList(new AbstractModule() {
        @Override
        protected void configure() {
            MapBinder<FunctionIdent, FunctionImplementation> functionBinder =
                    MapBinder.newMapBinder(binder(), FunctionIdent.class, FunctionImplementation.class);
            functionBinder.addBinding(new FunctionIdent(
                                              IsEvenScalarFunction.NAME,
                                              Collections.singletonList(DataTypes.LONG))
                                     ).toInstance(new IsEvenScalarFunction());
        }
    });
}
 
开发者ID:crate,项目名称:crate-example-plugin,代码行数:16,代码来源:ExamplePlugin.java


注:本文中的org.elasticsearch.common.inject.AbstractModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。