Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extensions to depend upon other extensions #2825

Open
2 tasks
Tracked by #2588
dlvenable opened this issue Jun 5, 2023 · 0 comments
Open
2 tasks
Tracked by #2588

Allow extensions to depend upon other extensions #2825

dlvenable opened this issue Jun 5, 2023 · 0 comments
Assignees
Milestone

Comments

@dlvenable
Copy link
Member

dlvenable commented Jun 5, 2023

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants