本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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());
}
});
}