Skip to content

Commit

Permalink
Remove Plugin.createComponents method that specifies individual servi…
Browse files Browse the repository at this point in the history
…ces (elastic#101457)

This is a breaking change for plugins implementing createComponents. Subclasses should be refactored to implement the method that takes a PluginServices object instead.
  • Loading branch information
thecoop authored and mark-vieira committed Nov 2, 2023
1 parent 6f346f4 commit cb369a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 61 deletions.
14 changes: 14 additions & 0 deletions docs/changelog/101457.yaml
@@ -0,0 +1,14 @@
pr: 101457
summary: "Remove Plugin.createComponents method in favour of overload with a PluginServices object"
area: Infra/Plugins
type: breaking-java
breaking:
area: "Java API"
title: "Plugin.createComponents method has been refactored to take a single PluginServices object"
details: >
Plugin.createComponents currently takes several different service arguments. The signature of this method changes
every time a new service is added. The method has now been modified to take a single interface object
that new services are added to. This will reduce API incompatibility issues when a new service
is introduced in the future.
impact: "Plugins that override createComponents will need to be refactored to override the new method on ES 8.12+"
notable: false
61 changes: 0 additions & 61 deletions server/src/main/java/org/elasticsearch/plugins/Plugin.java
Expand Up @@ -155,67 +155,6 @@ public interface PluginServices {
* @param services Provides access to various Elasticsearch services
*/
public Collection<?> createComponents(PluginServices services) {
return createComponents(
services.client(),
services.clusterService(),
services.threadPool(),
services.resourceWatcherService(),
services.scriptService(),
services.xContentRegistry(),
services.environment(),
services.nodeEnvironment(),
services.namedWriteableRegistry(),
services.indexNameExpressionResolver(),
services.repositoriesServiceSupplier(),
services.telemetryProvider(),
services.allocationService(),
services.indicesService()
);
}

/**
* Returns components added by this plugin. Either this method or {@link #createComponents(PluginServices)}
* should be implemented.
* <p>
* Any components returned that implement {@link LifecycleComponent} will have their lifecycle managed.
* Note: To aid in the migration away from guice, all objects returned as components will be bound in guice
* to themselves.
*
* @param client A client to make requests to the system
* @param clusterService A service to allow watching and updating cluster state
* @param threadPool A service to allow retrieving an executor to run an async action
* @param resourceWatcherService A service to watch for changes to node local files
* @param scriptService A service to allow running scripts on the local node
* @param xContentRegistry The registry for extensible xContent parsing
* @param environment The environment for path and setting configurations
* @param nodeEnvironment The node environment used coordinate access to the data paths
* @param namedWriteableRegistry The registry for {@link NamedWriteable} object parsing
* @param indexNameExpressionResolver A service that resolves expression to index and alias names
* @param repositoriesServiceSupplier A supplier for the service that manages snapshot repositories; will return null when this method
* is called, but will return the repositories service once the node is initialized.
* @param telemetryProvider An interface for distributed tracing
* @param allocationService A service to manage shard allocation in the cluster
* @param indicesService A service to manage indices in the cluster
*
* @deprecated New services will only be added to {@link PluginServices}; this method is maintained for compatibility.
*/
@Deprecated
public Collection<Object> createComponents(
Client client,
ClusterService clusterService,
ThreadPool threadPool,
ResourceWatcherService resourceWatcherService,
ScriptService scriptService,
NamedXContentRegistry xContentRegistry,
Environment environment,
NodeEnvironment nodeEnvironment,
NamedWriteableRegistry namedWriteableRegistry,
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<RepositoriesService> repositoriesServiceSupplier,
TelemetryProvider telemetryProvider,
AllocationService allocationService,
IndicesService indicesService
) {
return Collections.emptyList();
}

Expand Down

0 comments on commit cb369a6

Please sign in to comment.