# 6.1.x de-guiced ActionFilter: how to get IndexResolver and TransportService?

**URL:** <https://discuss.elastic.co/t/6-1-x-de-guiced-actionfilter-how-to-get-indexresolver-and-transportservice/112061>\
**Category:** Elasticsearch\
**Created:** [December 16, 2017, 1:14am UTC](https://discuss.elastic.co/t/6-1-x-de-guiced-actionfilter-how-to-get-indexresolver-and-transportservice/112061 "2017-12-16T01:14:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [December 16, 2017, 1:14am UTC](https://discuss.elastic.co/t/6-1-x-de-guiced-actionfilter-how-to-get-indexresolver-and-transportservice/112061/1 "2017-12-16T01:14:05Z")

</div>

Hi,

I saw in 6.1. you have de-guiced the `ActionFilter`s.

How can I now get to get a grip of the things like `IndexResolver` and `TransportService` in my `ActionFilter` implementation?

I used to inject them with Guice in my `ActionFilter` implementation, now I can't. What's the alternative?

I can access a subset of what I used to inject via implementing this method from Plugin.java, but it's not all of the things I need:

```
 public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool,
                                           ResourceWatcherService resourceWatcherService, ScriptService scriptService,
                                           NamedXContentRegistry xContentRegistry, Environment environment,
                                           NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) {

```

For reference, the code I'm trying to port to 6.1.0 is this

> <https://github.com/sscarduzio/elasticsearch-readonlyrest-plugin/blob/master/es60x/src/main/java/tech/beshu/ror/es/IndexLevelActionFilter.java#L72>

Congrats for the new release, and thanks already for your help 🙂

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [December 17, 2017, 8:28pm UTC](https://discuss.elastic.co/t/6-1-x-de-guiced-actionfilter-how-to-get-indexresolver-and-transportservice/112061/2 "2017-12-17T20:28:21Z")

</div>

Action filters should be simple and stateless. This is the reason the `getActionFilters()` method doesn't take any parameters. What do you need all those services for?

---

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [December 17, 2017, 8:46pm UTC](https://discuss.elastic.co/t/6-1-x-de-guiced-actionfilter-how-to-get-indexresolver-and-transportservice/112061/3 "2017-12-17T20:46:31Z")

</div>

Hi @rjernst!

I need that because my plugin implements basic auth and I'd like users to know the taskID associated to each users.  
That enables the admins to associate long standing task to a specific account.

Also I want to log the owner of each task and how long did the task take. So I measure response\_time(taskID) - request\_time(taskID) and associate it to a user name.

This way people can see what users this month requested inefficient queries.

So after all, I'd just be happy to find a way given an ActionRequest, to tell what task id it belongs to. That's all!

---

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [December 19, 2017, 6:17pm UTC](https://discuss.elastic.co/t/6-1-x-de-guiced-actionfilter-how-to-get-indexresolver-and-transportservice/112061/4 "2017-12-19T18:17:58Z")

</div>

Never mind the taskID can be found in the `ActionFilter.handleRequest`method, and I could just instantiate the other like this `new IndexNameExpressionResolver(settings)`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 16, 2018, 6:17pm UTC](https://discuss.elastic.co/t/6-1-x-de-guiced-actionfilter-how-to-get-indexresolver-and-transportservice/112061/5 "2018-01-16T18:17:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
