I want to have an extension and use another extension.
For example, I want to create a new plugin that will use the AwsCredentialsSupplier class which is provided by the AWS Plugin extension.
public class NewExtensionsPlugin implements ExtensionPlugin {
@DataPrepperPluginConstructor
public NewExtensionsPlugin(AwsCredentialsSupplier awsCredentialsSupplier) {
}
Currently, this is not supported.
See the following code where this is not yet allowed:
|
private static class NoArgumentsArgumentsContext implements PluginArgumentsContext { |
|
@Override |
|
public Object[] createArguments(final Class<?>[] parameterTypes) { |
|
if(parameterTypes.length != 0) { |
|
throw new InvalidPluginDefinitionException("No arguments are permitted for extensions constructors."); |
|
} |
|
return new Object[0]; |
|
} |
|
} |
Proposed solution:
Allow ExtensionPlugin classes to add an annotation which defines what components the provide. This can allow the plugin framework to create a dependency tree.
@ExtensionProvides(value = {ClassSuppliedOne.class, ClassSuppliedTwo.class})
For example, in the AwsPlugin:
@ExtensionProvides(value = {AwsCredentialsSupplier.class})
public class AwsPlugin implements ExtensionPlugin {
...
@Override
public void apply(final ExtensionPoints extensionPoints) {
extensionPoints.addExtensionProvider(new AwsExtensionProvider(defaultAwsCredentialsSupplier));
}
}
What needs to happen:
I want to have an extension and use another extension.
For example, I want to create a new plugin that will use the
AwsCredentialsSupplierclass which is provided by the AWS Plugin extension.Currently, this is not supported.
See the following code where this is not yet allowed:
data-prepper/data-prepper-core/src/main/java/org/opensearch/dataprepper/plugin/ExtensionLoader.java
Lines 54 to 62 in affe0b2
Proposed solution:
Allow
ExtensionPluginclasses to add an annotation which defines what components the provide. This can allow the plugin framework to create a dependency tree.For example, in the
AwsPlugin:What needs to happen: