Skip to content

Allow extensions to depend upon other extensions #2825

Description

@dlvenable

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:

  • Load extensions in the necessary order. If Extension B depends on Extension A, then Extension A must load first.
  • Update the ExtensionLoader to get extensions and inject them.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions