本文整理汇总了Java中org.elasticsearch.plugins.ActionPlugin类的典型用法代码示例。如果您正苦于以下问题:Java ActionPlugin类的具体用法?Java ActionPlugin怎么用?Java ActionPlugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionPlugin类属于org.elasticsearch.plugins包,在下文中一共展示了ActionPlugin类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPluginCantOverwriteBuiltinAction
import org.elasticsearch.plugins.ActionPlugin; //导入依赖的package包/类
public void testPluginCantOverwriteBuiltinAction() {
ActionPlugin dupsMainAction = new ActionPlugin() {
@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return singletonList(new ActionHandler<>(MainAction.INSTANCE, TransportMainAction.class));
}
};
Exception e = expectThrows(IllegalArgumentException.class, () -> ActionModule.setupActions(singletonList(dupsMainAction)));
assertEquals("action for name [" + MainAction.NAME + "] already registered", e.getMessage());
}
示例2: testPluginCanRegisterAction
import org.elasticsearch.plugins.ActionPlugin; //导入依赖的package包/类
public void testPluginCanRegisterAction() {
class FakeRequest extends ActionRequest {
@Override
public ActionRequestValidationException validate() {
return null;
}
}
class FakeTransportAction extends TransportAction<FakeRequest, ActionResponse> {
protected FakeTransportAction(Settings settings, String actionName, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, TaskManager taskManager) {
super(settings, actionName, threadPool, actionFilters, indexNameExpressionResolver, taskManager);
}
@Override
protected void doExecute(FakeRequest request, ActionListener<ActionResponse> listener) {
}
}
class FakeAction extends GenericAction<FakeRequest, ActionResponse> {
protected FakeAction() {
super("fake");
}
@Override
public ActionResponse newResponse() {
return null;
}
}
FakeAction action = new FakeAction();
ActionPlugin registersFakeAction = new ActionPlugin() {
@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return singletonList(new ActionHandler<>(action, FakeTransportAction.class));
}
};
assertThat(ActionModule.setupActions(singletonList(registersFakeAction)),
hasEntry("fake", new ActionHandler<>(action, FakeTransportAction.class)));
}
示例3: setupActionFilters
import org.elasticsearch.plugins.ActionPlugin; //导入依赖的package包/类
private List<Class<? extends ActionFilter>> setupActionFilters(List<ActionPlugin> actionPlugins) {
return unmodifiableList(actionPlugins.stream().flatMap(p -> p.getActionFilters().stream()).collect(Collectors.toList()));
}