I'll try and share some of the code to further explain my problems:
Inside my: ExamplePlugin
The old code:
public List<Class<? extends org.elasticsearch.rest.RestHandler>> getRestHandlers() {
List<Class<? extends org.elasticsearch.rest.RestHandler>> restHandlers = new ArrayList<>();
restHandlers.add(MainRestHandler.class);
restHandlers.add(StubRestHandler.class);
restHandlers.add(StubTwoRestHandler.class);
return restHandlers;
}
Since I had an @Inject
on my RestHandlers, the two services I created (one which extends AbstractLifecycleComponent
and one that extends AbstractComponent
) were automatically injected. With the new version, I have to instantiate those services myself but those services are reliant on other AbstractLifecycleComponent
s like ClusterService
My current 5.3 version:
@Override
public List<org.elasticsearch.rest.RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<DiscoveryNodes> nodesInCluster) {
return Arrays.asList(
new MainRestHandler(settings, restController),
new StubRestHandler(settings, restController, null, null),
new StubTwoRestHandler(settings, restController)
);
}
Now I need to add my services on the spots where it currently says null
, but in order to do so, I need to instantiate them myself. They require Client
, ClusterService
but they're not available inside my ExamplePlugin
class and instantiating those myself doesn't seem like the way to go.
I can't disclose much more about the functionality of the plugin, but I hope this gives a better view of what I'm trying to achieve. I'm not sure whether I'm overlooking something