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

Add ExtensionList.lookupFirst convenience method. #8735

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Dec 1, 2023

When introducing an extension point that is meant to allow overriding a default behaviour with another implementation, generally the caller only cares about looking up only one implementation, the one with the highest ordinal.

See JENKINS-XXXXX.

Testing done

Proposed changelog entries

  • developer: A new convenience method ExtensionList.lookupFirst allows to retrieve the first implementation of an extension point

Proposed upgrade guidelines

N/A

Submitter checklist

Preview Give feedback

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

Preview Give feedback

When introducing an extension point that is meant to allow overriding a default behaviour with another implementation,
generally the caller only cares about looking up only one implementation, the one with the highest ordinal.
@Vlatombe Vlatombe added the developer Changes which impact plugin developers label Dec 1, 2023
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of Javadoc nits, but otherwise looks useful. Did you search for other possible usages in core?

Co-authored-by: Jesse Glick <[email protected]>
@Vlatombe
Copy link
Member Author

Vlatombe commented Dec 1, 2023

Surprisingly, I didn't find other usages in core. I think ArtifactManagerFactory could be reworked to use this pattern, as there is a fallback mecanism to StandardArtifactManager if no artifact manager was configured for a given build.

@jglick
Copy link
Member

jglick commented Dec 1, 2023

for (ArtifactManagerFactory f : ArtifactManagerConfiguration.get().getArtifactManagerFactories()) {
ArtifactManager mgr = f.managerFor(this);
if (mgr != null) {
artifactManager = mgr;
save();
return mgr;
}
}
return new StandardArtifactManager(this);
uses a different pattern actually. So does
@DataBoundConstructor
public DefaultConsoleUrlProvider() {
}

@NotMyFault NotMyFault requested a review from a team December 4, 2023 08:20
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/label ready-for-merge


This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Dec 4, 2023
@NotMyFault NotMyFault merged commit 0f0d81b into jenkinsci:master Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer Changes which impact plugin developers ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants