From 7bbf69b194742cf47af287be2ffce742e80fbe07 Mon Sep 17 00:00:00 2001 From: Alberto Paro Date: Thu, 10 Feb 2011 17:23:49 +0100 Subject: [PATCH] Added support to define rest actions in plugins --- .../java/org/elasticsearch/rest/RestModule.java | 11 ++++++++++- .../elasticsearch/rest/action/RestActionModule.java | 13 +++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/RestModule.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/RestModule.java index b5e70defd77..1e586dfc7ec 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/RestModule.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/RestModule.java @@ -19,23 +19,32 @@ package org.elasticsearch.rest; +import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.action.RestActionModule; +import java.util.List; + /** * @author kimchy (Shay Banon) */ public class RestModule extends AbstractModule { private final Settings settings; + private List> restPluginsActions = Lists.newArrayList(); + + public void addRestAction(Class restAction) { + restPluginsActions.add(restAction); + } public RestModule(Settings settings) { this.settings = settings; } + @Override protected void configure() { bind(RestController.class).asEagerSingleton(); - new RestActionModule().configure(binder()); + new RestActionModule(restPluginsActions).configure(binder()); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java index 9172fa3b822..1eb5335663e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java @@ -19,7 +19,9 @@ package org.elasticsearch.rest.action; +import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.action.admin.cluster.health.RestClusterHealthAction; import org.elasticsearch.rest.action.admin.cluster.node.info.RestNodesInfoAction; import org.elasticsearch.rest.action.admin.cluster.node.restart.RestNodesRestartAction; @@ -60,12 +62,23 @@ import org.elasticsearch.rest.action.percolate.RestPercolateAction; import org.elasticsearch.rest.action.search.RestSearchAction; import org.elasticsearch.rest.action.search.RestSearchScrollAction; +import java.util.List; + /** * @author kimchy (Shay Banon) */ public class RestActionModule extends AbstractModule { + private List> restPluginsActions = Lists.newArrayList(); + + public RestActionModule(List> restPluginsActions){ + this.restPluginsActions=restPluginsActions; + } @Override protected void configure() { + for (Class restAction : restPluginsActions) { + bind(restAction).asEagerSingleton(); + } + bind(RestMainAction.class).asEagerSingleton(); bind(RestNodesInfoAction.class).asEagerSingleton();