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

Implementation of #113 Plugin Facility for Sputnik Processors #131

Merged
merged 5 commits into from
Feb 23, 2016
Merged

Implementation of #113 Plugin Facility for Sputnik Processors #131

merged 5 commits into from
Feb 23, 2016

Conversation

mirkosertic
Copy link
Contributor

First shot for an implementation based on the Java ServiceLoader mechanism.

@codecov-io
Copy link

Current coverage is 77.85%

Merging #131 into master will increase coverage by +0.61% as of 250c42b

Powered by Codecov. Updated on successful CI builds.

if (Boolean.valueOf(configuration.getProperty(GeneralOption.SONAR_ENABLED))) {
processors.add(new SonarProcessor(configuration));

ServiceLoader<ReviewProcessorFactory> theLoader = ServiceLoader.load(ReviewProcessorFactory.class);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd change variable names to match other variables style, so: serviceLoader instead of theLoader, iterator instead of theIterator, reviewProcessorFactory instead of theFactory etc.

@SpOOnman
Copy link
Collaborator

Can you elaborate on this? As I understand your work you want to use ServiceLoader to locate all classes that implement interface ReviewProcessorFactory and are enabled in properties file? This way you can write external plugins that are not included in Sputnik codebase. Is this correct?

It's hard to unit test your change. Do you have an idea how to do this?

@mirkosertic
Copy link
Contributor Author

Yes, you are right. Now custom ReviewProcessor can be added using the standard Java ServiceLoader API and extending the Classpath. This enables user to implement custom ReviewProcessors without affecting the codebase and adding unwanted dependencies to the core project.

UnitTesting this change is quite easy. Just call the ProcessorBuilder and see it if returns more than zero ReviewProcessor instances(with the right configuration).

import pl.touk.sputnik.configuration.Configuration;
import pl.touk.sputnik.configuration.GeneralOption;
import pl.touk.sputnik.processor.ReviewProcessorFactory;
import pl.touk.sputnik.processor.checkstyle.CheckstyleReviewProcessorFactory;
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Checkstyle] ERROR: Unused import - pl.touk.sputnik.processor.checkstyle.CheckstyleReviewProcessorFactory.

@mirkosertic
Copy link
Contributor Author

Fixed the codestyle issues and added some tests.

@mirkosertic
Copy link
Contributor Author

Any news on this?

SpOOnman added a commit that referenced this pull request Feb 23, 2016
Implementation of #113 Plugin Facility for Sputnik Processors
@SpOOnman SpOOnman merged commit 96da183 into TouK:master Feb 23, 2016
@SpOOnman
Copy link
Collaborator

Thank you! Merged!

rufuslevi pushed a commit to rufuslevi/sputnik that referenced this pull request Mar 12, 2024
Implementation of TouK#113 Plugin Facility for Sputnik Processors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants