Since some of the rest handlers depend on components constructed
in `createComponents` we use `SetOnce` to save a reference to
the components at the class level and reuse the reference in
`initRestHandlers`. This does require that `initRestHandlers`
is called after `createComponents` but I think that is fairly
reasonable.

Original commit: elastic/x-pack-elasticsearch@4fd87ad911
This commit is contained in:
Nik Everett 2017-01-20 11:49:20 -05:00 committed by GitHub
parent 8f70653233
commit d690c5f789
34 changed files with 112 additions and 138 deletions

View File

@ -8,21 +8,27 @@ package org.elasticsearch.license;
import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.NamedDiff; import org.elasticsearch.cluster.NamedDiff;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestHandler;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
import static java.util.Collections.emptyList;
import static org.elasticsearch.xpack.XPackPlugin.isTribeNode; import static org.elasticsearch.xpack.XPackPlugin.isTribeNode;
import static org.elasticsearch.xpack.XPackPlugin.transportClientMode; import static org.elasticsearch.xpack.XPackPlugin.transportClientMode;
@ -64,13 +70,16 @@ public class Licensing implements ActionPlugin {
} }
@Override @Override
public List<Class<? extends RestHandler>> getRestHandlers() { public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
if (isTribeNode) { IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
return Collections.singletonList(RestGetLicenseAction.class); Supplier<DiscoveryNodes> nodesInCluster) {
List<RestHandler> handlers = new ArrayList<>();
handlers.add(new RestGetLicenseAction(settings, restController));
if (false == isTribeNode) {
handlers.add(new RestPutLicenseAction(settings, restController));
handlers.add(new RestDeleteLicenseAction(settings, restController));
} }
return Arrays.asList(RestPutLicenseAction.class, return handlers;
RestGetLicenseAction.class,
RestDeleteLicenseAction.class);
} }
public List<Setting<?>> getSettings() { public List<Setting<?>> getSettings() {

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.license; package org.elasticsearch.license;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
@ -18,8 +17,6 @@ import java.io.IOException;
import static org.elasticsearch.rest.RestRequest.Method.DELETE; import static org.elasticsearch.rest.RestRequest.Method.DELETE;
public class RestDeleteLicenseAction extends XPackRestHandler { public class RestDeleteLicenseAction extends XPackRestHandler {
@Inject
public RestDeleteLicenseAction(Settings settings, RestController controller) { public RestDeleteLicenseAction(Settings settings, RestController controller) {
super(settings); super(settings);
// @deprecated Remove deprecations in 6.0 // @deprecated Remove deprecations in 6.0

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.license; package org.elasticsearch.license;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -24,8 +23,6 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.rest.RestRequest.Method.PUT;
public class RestPutLicenseAction extends XPackRestHandler { public class RestPutLicenseAction extends XPackRestHandler {
@Inject
public RestPutLicenseAction(Settings settings, RestController controller) { public RestPutLicenseAction(Settings settings, RestController controller) {
super(settings); super(settings);
// @deprecated Remove deprecations in 6.0 // @deprecated Remove deprecations in 6.0

View File

@ -11,6 +11,8 @@ import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.support.ActionFilter; import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Module;
@ -19,8 +21,10 @@ import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@ -37,6 +41,7 @@ import org.elasticsearch.plugins.IngestPlugin;
import org.elasticsearch.plugins.NetworkPlugin; import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptService;
@ -387,15 +392,22 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
} }
@Override @Override
public List<Class<? extends RestHandler>> getRestHandlers() { public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
List<Class<? extends RestHandler>> handlers = new ArrayList<>(); IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
handlers.add(RestXPackInfoAction.class); Supplier<DiscoveryNodes> nodesInCluster) {
handlers.add(RestXPackUsageAction.class); List<RestHandler> handlers = new ArrayList<>();
handlers.addAll(licensing.getRestHandlers()); handlers.add(new RestXPackInfoAction(settings, restController));
handlers.addAll(monitoring.getRestHandlers()); handlers.add(new RestXPackUsageAction(settings, restController));
handlers.addAll(security.getRestHandlers()); handlers.addAll(licensing.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter,
handlers.addAll(watcher.getRestHandlers()); indexNameExpressionResolver, nodesInCluster));
handlers.addAll(graph.getRestHandlers()); handlers.addAll(monitoring.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter,
indexNameExpressionResolver, nodesInCluster));
handlers.addAll(security.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter,
indexNameExpressionResolver, nodesInCluster));
handlers.addAll(watcher.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter,
indexNameExpressionResolver, nodesInCluster));
handlers.addAll(graph.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter,
indexNameExpressionResolver, nodesInCluster));
return handlers; return handlers;
} }

View File

@ -7,10 +7,16 @@ package org.elasticsearch.xpack.graph;
import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.XPackSettings;
@ -21,6 +27,7 @@ import org.elasticsearch.xpack.graph.rest.action.RestGraphAction;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
@ -50,10 +57,12 @@ public class Graph extends Plugin implements ActionPlugin {
} }
@Override @Override
public List<Class<? extends RestHandler>> getRestHandlers() { public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) {
if (false == enabled) { if (false == enabled) {
return emptyList(); return emptyList();
} }
return singletonList(RestGraphAction.class); return singletonList(new RestGraphAction(settings, restController));
} }
} }

View File

@ -9,7 +9,6 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
@ -56,7 +55,6 @@ public class RestGraphAction extends XPackRestHandler {
public static final ParseField BOOST_FIELD = new ParseField("boost"); public static final ParseField BOOST_FIELD = new ParseField("boost");
public static final ParseField TERM_FIELD = new ParseField("term"); public static final ParseField TERM_FIELD = new ParseField("term");
@Inject
public RestGraphAction(Settings settings, RestController controller) { public RestGraphAction(Settings settings, RestController controller) {
super(settings); super(settings);

View File

@ -7,18 +7,26 @@ package org.elasticsearch.xpack.monitoring;
import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.util.Providers; import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.license.LicenseService; import org.elasticsearch.license.LicenseService;
import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.XPackSettings;
import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction; import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction;
import org.elasticsearch.xpack.monitoring.action.TransportMonitoringBulkAction; import org.elasticsearch.xpack.monitoring.action.TransportMonitoringBulkAction;
import org.elasticsearch.xpack.monitoring.cleaner.CleanerService;
import org.elasticsearch.xpack.monitoring.collector.Collector; import org.elasticsearch.xpack.monitoring.collector.Collector;
import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStateCollector; import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStateCollector;
import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStatsCollector; import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStatsCollector;
@ -31,14 +39,10 @@ import org.elasticsearch.xpack.monitoring.exporter.Exporter;
import org.elasticsearch.xpack.monitoring.exporter.Exporters; import org.elasticsearch.xpack.monitoring.exporter.Exporters;
import org.elasticsearch.xpack.monitoring.exporter.http.HttpExporter; import org.elasticsearch.xpack.monitoring.exporter.http.HttpExporter;
import org.elasticsearch.xpack.monitoring.exporter.local.LocalExporter; import org.elasticsearch.xpack.monitoring.exporter.local.LocalExporter;
import org.elasticsearch.xpack.monitoring.cleaner.CleanerService;
import org.elasticsearch.xpack.monitoring.rest.action.RestMonitoringBulkAction; import org.elasticsearch.xpack.monitoring.rest.action.RestMonitoringBulkAction;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.xpack.security.InternalClient; import org.elasticsearch.xpack.security.InternalClient;
import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.ssl.SSLService;
import java.time.Clock;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -48,6 +52,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Supplier;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
@ -135,10 +140,12 @@ public class Monitoring implements ActionPlugin {
} }
@Override @Override
public List<Class<? extends RestHandler>> getRestHandlers() { public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) {
if (false == enabled || tribeNode) { if (false == enabled || tribeNode) {
return emptyList(); return emptyList();
} }
return singletonList(RestMonitoringBulkAction.class); return singletonList(new RestMonitoringBulkAction(settings, restController));
} }
} }

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.monitoring.rest.action;
import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.BytesRestResponse;
@ -31,7 +30,6 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler {
public static final String MONITORING_VERSION = "system_api_version"; public static final String MONITORING_VERSION = "system_api_version";
public static final String INTERVAL = "interval"; public static final String INTERVAL = "interval";
@Inject
public RestMonitoringBulkAction(Settings settings, RestController controller) { public RestMonitoringBulkAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(POST, URI_BASE + "/_bulk", this); controller.registerHandler(POST, URI_BASE + "/_bulk", this);

View File

@ -5,12 +5,9 @@
*/ */
package org.elasticsearch.xpack.rest.action; package org.elasticsearch.xpack.rest.action;
import java.io.IOException;
import java.util.EnumSet;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.license.XPackInfoResponse;
import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
@ -18,16 +15,16 @@ import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.action.RestBuilderListener; import org.elasticsearch.rest.action.RestBuilderListener;
import org.elasticsearch.xpack.XPackClient; import org.elasticsearch.xpack.XPackClient;
import org.elasticsearch.xpack.action.XPackInfoRequest; import org.elasticsearch.xpack.action.XPackInfoRequest;
import org.elasticsearch.license.XPackInfoResponse;
import org.elasticsearch.xpack.rest.XPackRestHandler; import org.elasticsearch.xpack.rest.XPackRestHandler;
import java.io.IOException;
import java.util.EnumSet;
import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.HEAD; import static org.elasticsearch.rest.RestRequest.Method.HEAD;
import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.RestStatus.OK;
public class RestXPackInfoAction extends XPackRestHandler { public class RestXPackInfoAction extends XPackRestHandler {
@Inject
public RestXPackInfoAction(Settings settings, RestController controller) { public RestXPackInfoAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(HEAD, URI_BASE, this); controller.registerHandler(HEAD, URI_BASE, this);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.rest.action; package org.elasticsearch.xpack.rest.action;
import org.elasticsearch.action.support.master.MasterNodeRequest; import org.elasticsearch.action.support.master.MasterNodeRequest;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -27,8 +26,6 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.RestStatus.OK;
public class RestXPackUsageAction extends XPackRestHandler { public class RestXPackUsageAction extends XPackRestHandler {
@Inject
public RestXPackUsageAction(Settings settings, RestController controller) { public RestXPackUsageAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(GET, URI_BASE + "/usage", this); controller.registerHandler(GET, URI_BASE + "/usage", this);

View File

@ -11,6 +11,8 @@ import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.support.ActionFilter; import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.action.support.DestructiveOperations;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Nullable;
@ -23,9 +25,12 @@ import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@ -38,6 +43,7 @@ import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.IngestPlugin; import org.elasticsearch.plugins.IngestPlugin;
import org.elasticsearch.plugins.NetworkPlugin; import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.Transport;
@ -169,6 +175,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin {
private final SetOnce<TransportInterceptor> securityInterceptor = new SetOnce<>(); private final SetOnce<TransportInterceptor> securityInterceptor = new SetOnce<>();
private final SetOnce<IPFilter> ipFilter = new SetOnce<>(); private final SetOnce<IPFilter> ipFilter = new SetOnce<>();
private final SetOnce<AuthenticationService> authcService = new SetOnce<>(); private final SetOnce<AuthenticationService> authcService = new SetOnce<>();
private final SetOnce<SecurityContext> securityContext = new SetOnce<>();
public Security(Settings settings, Environment env, XPackLicenseState licenseState, SSLService sslService) throws IOException { public Security(Settings settings, Environment env, XPackLicenseState licenseState, SSLService sslService) throws IOException {
this.settings = settings; this.settings = settings;
@ -241,8 +248,8 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin {
} }
List<Object> components = new ArrayList<>(); List<Object> components = new ArrayList<>();
final SecurityContext securityContext = new SecurityContext(settings, threadPool.getThreadContext(), cryptoService); securityContext.set(new SecurityContext(settings, threadPool.getThreadContext(), cryptoService));
components.add(securityContext); components.add(securityContext.get());
// realms construction // realms construction
final NativeUsersStore nativeUsersStore = new NativeUsersStore(settings, client); final NativeUsersStore nativeUsersStore = new NativeUsersStore(settings, client);
@ -335,7 +342,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin {
components.add(ipFilter.get()); components.add(ipFilter.get());
DestructiveOperations destructiveOperations = new DestructiveOperations(settings, clusterService.getClusterSettings()); DestructiveOperations destructiveOperations = new DestructiveOperations(settings, clusterService.getClusterSettings());
securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(), authzService, licenseState, securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(), authzService, licenseState,
sslService, securityContext, destructiveOperations)); sslService, securityContext.get(), destructiveOperations));
return components; return components;
} }
@ -500,21 +507,24 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin {
} }
@Override @Override
public List<Class<? extends RestHandler>> getRestHandlers() { public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) {
if (enabled == false) { if (enabled == false) {
return emptyList(); return emptyList();
} }
return Arrays.asList(RestAuthenticateAction.class, return Arrays.asList(
RestClearRealmCacheAction.class, new RestAuthenticateAction(settings, restController, securityContext.get(), licenseState),
RestClearRolesCacheAction.class, new RestClearRealmCacheAction(settings, restController),
RestGetUsersAction.class, new RestClearRolesCacheAction(settings, restController),
RestPutUserAction.class, new RestGetUsersAction(settings, restController),
RestDeleteUserAction.class, new RestPutUserAction(settings, restController),
RestGetRolesAction.class, new RestDeleteUserAction(settings, restController),
RestPutRoleAction.class, new RestGetRolesAction(settings, restController),
RestDeleteRoleAction.class, new RestPutRoleAction(settings, restController),
RestChangePasswordAction.class, new RestDeleteRoleAction(settings, restController),
RestSetEnabledAction.class); new RestChangePasswordAction(settings, restController, securityContext.get()),
new RestSetEnabledAction(settings, restController));
} }
@Override @Override

View File

@ -11,7 +11,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.util.concurrent.ThreadContext.StoredContext; import org.elasticsearch.common.util.concurrent.ThreadContext.StoredContext;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.security.authc.Authentication; import org.elasticsearch.xpack.security.authc.Authentication;
import org.elasticsearch.xpack.security.authc.AuthenticationService; import org.elasticsearch.xpack.security.authc.AuthenticationService;
import org.elasticsearch.xpack.security.crypto.CryptoService; import org.elasticsearch.xpack.security.crypto.CryptoService;

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action; package org.elasticsearch.xpack.security.rest.action;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -35,7 +34,6 @@ public class RestAuthenticateAction extends BaseRestHandler {
private final SecurityContext securityContext; private final SecurityContext securityContext;
private final XPackLicenseState licenseState; private final XPackLicenseState licenseState;
@Inject
public RestAuthenticateAction(Settings settings, RestController controller, SecurityContext securityContext, public RestAuthenticateAction(Settings settings, RestController controller, SecurityContext securityContext,
XPackLicenseState licenseState) { XPackLicenseState licenseState) {
super(settings); super(settings);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.realm; package org.elasticsearch.xpack.security.rest.action.realm;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestController;
@ -20,8 +19,6 @@ import java.io.IOException;
import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.POST;
public class RestClearRealmCacheAction extends BaseRestHandler { public class RestClearRealmCacheAction extends BaseRestHandler {
@Inject
public RestClearRealmCacheAction(Settings settings, RestController controller) { public RestClearRealmCacheAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(POST, "/_xpack/security/realm/{realms}/_clear_cache", this); controller.registerHandler(POST, "/_xpack/security/realm/{realms}/_clear_cache", this);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.role; package org.elasticsearch.xpack.security.rest.action.role;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestController;
@ -20,8 +19,6 @@ import java.io.IOException;
import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.POST;
public class RestClearRolesCacheAction extends BaseRestHandler { public class RestClearRolesCacheAction extends BaseRestHandler {
@Inject
public RestClearRolesCacheAction(Settings settings, RestController controller) { public RestClearRolesCacheAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(POST, "/_xpack/security/role/{name}/_clear_cache", this); controller.registerHandler(POST, "/_xpack/security/role/{name}/_clear_cache", this);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.role; package org.elasticsearch.xpack.security.rest.action.role;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -27,8 +26,6 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE;
* Rest endpoint to delete a Role from the security index * Rest endpoint to delete a Role from the security index
*/ */
public class RestDeleteRoleAction extends BaseRestHandler { public class RestDeleteRoleAction extends BaseRestHandler {
@Inject
public RestDeleteRoleAction(Settings settings, RestController controller) { public RestDeleteRoleAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(DELETE, "/_xpack/security/role/{name}", this); controller.registerHandler(DELETE, "/_xpack/security/role/{name}", this);

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.security.rest.action.role;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -29,8 +28,6 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
* Rest endpoint to retrieve a Role from the security index * Rest endpoint to retrieve a Role from the security index
*/ */
public class RestGetRolesAction extends BaseRestHandler { public class RestGetRolesAction extends BaseRestHandler {
@Inject
public RestGetRolesAction(Settings settings, RestController controller) { public RestGetRolesAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(GET, "/_xpack/security/role/", this); controller.registerHandler(GET, "/_xpack/security/role/", this);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.role; package org.elasticsearch.xpack.security.rest.action.role;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -29,8 +28,6 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
* Rest endpoint to add a Role to the security index * Rest endpoint to add a Role to the security index
*/ */
public class RestPutRoleAction extends BaseRestHandler { public class RestPutRoleAction extends BaseRestHandler {
@Inject
public RestPutRoleAction(Settings settings, RestController controller) { public RestPutRoleAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(POST, "/_xpack/security/role/{name}", this); controller.registerHandler(POST, "/_xpack/security/role/{name}", this);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.user; package org.elasticsearch.xpack.security.rest.action.user;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -30,7 +29,6 @@ public class RestChangePasswordAction extends BaseRestHandler {
private final SecurityContext securityContext; private final SecurityContext securityContext;
@Inject
public RestChangePasswordAction(Settings settings, RestController controller, SecurityContext securityContext) { public RestChangePasswordAction(Settings settings, RestController controller, SecurityContext securityContext) {
super(settings); super(settings);
this.securityContext = securityContext; this.securityContext = securityContext;

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.user; package org.elasticsearch.xpack.security.rest.action.user;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -27,8 +26,6 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE;
* Rest action to delete a user from the security index * Rest action to delete a user from the security index
*/ */
public class RestDeleteUserAction extends BaseRestHandler { public class RestDeleteUserAction extends BaseRestHandler {
@Inject
public RestDeleteUserAction(Settings settings, RestController controller) { public RestDeleteUserAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(DELETE, "/_xpack/security/user/{username}", this); controller.registerHandler(DELETE, "/_xpack/security/user/{username}", this);

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.security.rest.action.user;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -29,8 +28,6 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
* Rest action to retrieve a user from the security index * Rest action to retrieve a user from the security index
*/ */
public class RestGetUsersAction extends BaseRestHandler { public class RestGetUsersAction extends BaseRestHandler {
@Inject
public RestGetUsersAction(Settings settings, RestController controller) { public RestGetUsersAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(GET, "/_xpack/security/user/", this); controller.registerHandler(GET, "/_xpack/security/user/", this);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.user; package org.elasticsearch.xpack.security.rest.action.user;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -29,8 +28,6 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
* Rest endpoint to add a User to the security index * Rest endpoint to add a User to the security index
*/ */
public class RestPutUserAction extends BaseRestHandler { public class RestPutUserAction extends BaseRestHandler {
@Inject
public RestPutUserAction(Settings settings, RestController controller) { public RestPutUserAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(POST, "/_xpack/security/user/{username}", this); controller.registerHandler(POST, "/_xpack/security/user/{username}", this);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.security.rest.action.user; package org.elasticsearch.xpack.security.rest.action.user;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -29,8 +28,6 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
* enabled or disabled. * enabled or disabled.
*/ */
public class RestSetEnabledAction extends BaseRestHandler { public class RestSetEnabledAction extends BaseRestHandler {
@Inject
public RestSetEnabledAction(Settings settings, RestController controller) { public RestSetEnabledAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(POST, "/_xpack/security/user/{username}/_enable", this); controller.registerHandler(POST, "/_xpack/security/user/{username}/_enable", this);

View File

@ -10,7 +10,9 @@ import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.NamedDiff; import org.elasticsearch.cluster.NamedDiff;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
@ -21,14 +23,18 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.logging.LoggerMessageFormat; import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptService;
@ -157,6 +163,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
@ -419,19 +426,22 @@ public class Watcher implements ActionPlugin, ScriptPlugin {
} }
@Override @Override
public List<Class<? extends RestHandler>> getRestHandlers() { public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) {
if (false == enabled) { if (false == enabled) {
return emptyList(); return emptyList();
} }
return Arrays.asList(RestPutWatchAction.class, return Arrays.asList(
RestDeleteWatchAction.class, new RestPutWatchAction(settings, restController),
RestWatcherStatsAction.class, new RestDeleteWatchAction(settings, restController),
RestGetWatchAction.class, new RestWatcherStatsAction(settings, restController),
RestWatchServiceAction.class, new RestGetWatchAction(settings, restController),
RestAckWatchAction.class, new RestWatchServiceAction(settings, restController),
RestActivateWatchAction.class, new RestAckWatchAction(settings, restController),
RestExecuteWatchAction.class, new RestActivateWatchAction(settings, restController),
RestHijackOperationAction.class); new RestExecuteWatchAction(settings, restController),
new RestHijackOperationAction(settings, restController));
} }
@Override @Override

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.BytesRestResponse;
@ -30,8 +29,6 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
* The rest action to ack a watch * The rest action to ack a watch
*/ */
public class RestAckWatchAction extends WatcherRestHandler { public class RestAckWatchAction extends WatcherRestHandler {
@Inject
public RestAckWatchAction(Settings settings, RestController controller) { public RestAckWatchAction(Settings settings, RestController controller) {
super(settings); super(settings);
// @deprecated Remove deprecations in 6.0 // @deprecated Remove deprecations in 6.0

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.BytesRestResponse;
@ -30,8 +29,6 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
* The rest action to de/activate a watch * The rest action to de/activate a watch
*/ */
public class RestActivateWatchAction extends WatcherRestHandler { public class RestActivateWatchAction extends WatcherRestHandler {
@Inject
public RestActivateWatchAction(Settings settings, RestController controller) { public RestActivateWatchAction(Settings settings, RestController controller) {
super(settings); super(settings);

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.BytesRestResponse;
@ -26,8 +25,6 @@ import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.RestStatus.OK;
public class RestDeleteWatchAction extends WatcherRestHandler { public class RestDeleteWatchAction extends WatcherRestHandler {
@Inject
public RestDeleteWatchAction(Settings settings, RestController controller) { public RestDeleteWatchAction(Settings settings, RestController controller) {
super(settings); super(settings);
// @deprecated Remove deprecations in 6.0 // @deprecated Remove deprecations in 6.0

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentHelper;
@ -25,7 +24,6 @@ import org.elasticsearch.xpack.watcher.support.xcontent.WatcherParams;
import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchRequest; import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchRequest;
import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchRequestBuilder; import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchRequestBuilder;
import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchResponse; import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchResponse;
import org.elasticsearch.xpack.watcher.trigger.TriggerService;
import java.io.IOException; import java.io.IOException;
@ -35,13 +33,8 @@ import static org.elasticsearch.xpack.watcher.rest.action.RestExecuteWatchAction
import static org.elasticsearch.xpack.watcher.rest.action.RestExecuteWatchAction.Field.RECORD_EXECUTION; import static org.elasticsearch.xpack.watcher.rest.action.RestExecuteWatchAction.Field.RECORD_EXECUTION;
public class RestExecuteWatchAction extends WatcherRestHandler { public class RestExecuteWatchAction extends WatcherRestHandler {
public RestExecuteWatchAction(Settings settings, RestController controller) {
final TriggerService triggerService;
@Inject
public RestExecuteWatchAction(Settings settings, RestController controller, TriggerService triggerService) {
super(settings); super(settings);
this.triggerService = triggerService;
// @deprecated Remove deprecations in 6.0 // @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_execute", this, controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_execute", this,

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -27,8 +26,6 @@ import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.RestStatus.OK;
public class RestGetWatchAction extends WatcherRestHandler { public class RestGetWatchAction extends WatcherRestHandler {
@Inject
public RestGetWatchAction(Settings settings, RestController controller) { public RestGetWatchAction(Settings settings, RestController controller) {
super(settings); super(settings);

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
@ -28,7 +27,6 @@ public class RestHijackOperationAction extends WatcherRestHandler {
private static final String ALLOW_DIRECT_ACCESS_TO_WATCH_INDEX_SETTING = "xpack.watcher.index.rest.direct_access"; private static final String ALLOW_DIRECT_ACCESS_TO_WATCH_INDEX_SETTING = "xpack.watcher.index.rest.direct_access";
@Inject
public RestHijackOperationAction(Settings settings, RestController controller) { public RestHijackOperationAction(Settings settings, RestController controller) {
super(settings); super(settings);
if (!settings.getAsBoolean(ALLOW_DIRECT_ACCESS_TO_WATCH_INDEX_SETTING, false)) { if (!settings.getAsBoolean(ALLOW_DIRECT_ACCESS_TO_WATCH_INDEX_SETTING, false)) {

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.BytesRestResponse;
@ -27,8 +26,6 @@ import static org.elasticsearch.rest.RestStatus.CREATED;
import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.RestStatus.OK;
public class RestPutWatchAction extends WatcherRestHandler { public class RestPutWatchAction extends WatcherRestHandler {
@Inject
public RestPutWatchAction(Settings settings, RestController controller) { public RestPutWatchAction(Settings settings, RestController controller) {
super(settings); super(settings);

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
@ -20,8 +19,6 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.rest.RestRequest.Method.PUT;
public class RestWatchServiceAction extends WatcherRestHandler { public class RestWatchServiceAction extends WatcherRestHandler {
@Inject
public RestWatchServiceAction(Settings settings, RestController controller) { public RestWatchServiceAction(Settings settings, RestController controller) {
super(settings); super(settings);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.watcher.rest.action; package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.BytesRestResponse;
@ -26,8 +25,6 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.RestStatus.OK;
public class RestWatcherStatsAction extends WatcherRestHandler { public class RestWatcherStatsAction extends WatcherRestHandler {
@Inject
public RestWatcherStatsAction(Settings settings, RestController controller) { public RestWatcherStatsAction(Settings settings, RestController controller) {
super(settings); super(settings);

View File

@ -9,13 +9,11 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestController;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.xpack.watcher.client.WatcherClient; import org.elasticsearch.xpack.watcher.client.WatcherClient;
import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchRequestBuilder; import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchRequestBuilder;
import org.elasticsearch.xpack.watcher.trigger.TriggerService;
import java.util.Arrays; import java.util.Arrays;
@ -27,8 +25,6 @@ public class RestExecuteWatchActionTests extends ESTestCase {
private RestController restController = mock(RestController.class); private RestController restController = mock(RestController.class);
private Client client = mock(Client.class); private Client client = mock(Client.class);
private TriggerService triggerService = mock(TriggerService.class);
private RestChannel restChannel = mock(RestChannel.class);
private WatcherClient watcherClient = mock(WatcherClient.class); private WatcherClient watcherClient = mock(WatcherClient.class);
public void testThatFlagsCanBeSpecifiedViaParameters() throws Exception { public void testThatFlagsCanBeSpecifiedViaParameters() throws Exception {
@ -39,8 +35,7 @@ public class RestExecuteWatchActionTests extends ESTestCase {
ExecuteWatchRequestBuilder builder = new ExecuteWatchRequestBuilder(client); ExecuteWatchRequestBuilder builder = new ExecuteWatchRequestBuilder(client);
when(watcherClient.prepareExecuteWatch()).thenReturn(builder); when(watcherClient.prepareExecuteWatch()).thenReturn(builder);
RestExecuteWatchAction restExecuteWatchAction = new RestExecuteWatchAction(Settings.EMPTY, restController, RestExecuteWatchAction restExecuteWatchAction = new RestExecuteWatchAction(Settings.EMPTY, restController);
triggerService);
restExecuteWatchAction.doPrepareRequest(createFakeRestRequest(randomId, recordExecution, ignoreCondition, restExecuteWatchAction.doPrepareRequest(createFakeRestRequest(randomId, recordExecution, ignoreCondition,
debugCondition), watcherClient); debugCondition), watcherClient);