Added support to define rest actions in plugins
This commit is contained in:
parent
35c339f5f3
commit
7bbf69b194
|
@ -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<Class<? extends BaseRestHandler>> restPluginsActions = Lists.newArrayList();
|
||||
|
||||
public void addRestAction(Class<? extends BaseRestHandler> 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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Class<? extends BaseRestHandler>> restPluginsActions = Lists.newArrayList();
|
||||
|
||||
public RestActionModule(List<Class<? extends BaseRestHandler>> restPluginsActions){
|
||||
this.restPluginsActions=restPluginsActions;
|
||||
}
|
||||
|
||||
@Override protected void configure() {
|
||||
for (Class<? extends BaseRestHandler> restAction : restPluginsActions) {
|
||||
bind(restAction).asEagerSingleton();
|
||||
}
|
||||
|
||||
bind(RestMainAction.class).asEagerSingleton();
|
||||
|
||||
bind(RestNodesInfoAction.class).asEagerSingleton();
|
||||
|
|
Loading…
Reference in New Issue