當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。