Added support to define rest actions in plugins

This commit is contained in:
Alberto Paro 2011-02-10 17:23:49 +01:00 committed by kimchy
parent 35c339f5f3
commit 7bbf69b194
2 changed files with 23 additions and 1 deletions

View File

@ -19,23 +19,32 @@
package org.elasticsearch.rest; package org.elasticsearch.rest;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.action.RestActionModule; import org.elasticsearch.rest.action.RestActionModule;
import java.util.List;
/** /**
* @author kimchy (Shay Banon) * @author kimchy (Shay Banon)
*/ */
public class RestModule extends AbstractModule { public class RestModule extends AbstractModule {
private final Settings settings; private final Settings settings;
private List<Class<? extends BaseRestHandler>> restPluginsActions = Lists.newArrayList();
public void addRestAction(Class<? extends BaseRestHandler> restAction) {
restPluginsActions.add(restAction);
}
public RestModule(Settings settings) { public RestModule(Settings settings) {
this.settings = settings; this.settings = settings;
} }
@Override protected void configure() { @Override protected void configure() {
bind(RestController.class).asEagerSingleton(); bind(RestController.class).asEagerSingleton();
new RestActionModule().configure(binder()); new RestActionModule(restPluginsActions).configure(binder());
} }
} }

View File

@ -19,7 +19,9 @@
package org.elasticsearch.rest.action; package org.elasticsearch.rest.action;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.AbstractModule; 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.health.RestClusterHealthAction;
import org.elasticsearch.rest.action.admin.cluster.node.info.RestNodesInfoAction; import org.elasticsearch.rest.action.admin.cluster.node.info.RestNodesInfoAction;
import org.elasticsearch.rest.action.admin.cluster.node.restart.RestNodesRestartAction; 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.RestSearchAction;
import org.elasticsearch.rest.action.search.RestSearchScrollAction; import org.elasticsearch.rest.action.search.RestSearchScrollAction;
import java.util.List;
/** /**
* @author kimchy (Shay Banon) * @author kimchy (Shay Banon)
*/ */
public class RestActionModule extends AbstractModule { public class RestActionModule extends AbstractModule {
private List<Class<? extends BaseRestHandler>> restPluginsActions = Lists.newArrayList();
public RestActionModule(List<Class<? extends BaseRestHandler>> restPluginsActions){
this.restPluginsActions=restPluginsActions;
}
@Override protected void configure() { @Override protected void configure() {
for (Class<? extends BaseRestHandler> restAction : restPluginsActions) {
bind(restAction).asEagerSingleton();
}
bind(RestMainAction.class).asEagerSingleton(); bind(RestMainAction.class).asEagerSingleton();
bind(RestNodesInfoAction.class).asEagerSingleton(); bind(RestNodesInfoAction.class).asEagerSingleton();