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

Integrated Service Loading #7

Merged
merged 4 commits into from
Jan 20, 2022
Merged

Conversation

overheadhunter
Copy link
Member

This improves service loading by adding an IntegrationsLoader that uses annotations to sort and filter implementation candidates.

Furthermore static "factory" methods have been added to all current services.

Sorting

Using the @Priority(42) annotation, we can make a certain service implementation take precedence over others, allowing us to implement fallback mechanisms easily.

Filtering

This allows us (to a certain degree) to check whether a certain service implementation is suited for e.g. the current operating system (using the @OperatingSystem(Value.Windows) annotation) without actually creating an instance of said service. Further discriminators may be added on demand eventually.

WINDOWS,
UNKNOWN;

private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
Copy link

Choose a reason for hiding this comment

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

NULL_DEREFERENCE: object returned by getProperty("os.name") could be null and is dereferenced at line 33.
(at-me in a reply with help or ignore)

@overheadhunter overheadhunter requested a review from infeo January 19, 2022 15:02
Copy link
Member

@infeo infeo left a comment

Choose a reason for hiding this comment

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

Looks cool.

Imhp the static factory methods are a good improvment regarding code readability.

@overheadhunter overheadhunter merged commit d575f5d into develop Jan 20, 2022
@overheadhunter overheadhunter deleted the feature/service-loading branch January 20, 2022 11:46
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.

2 participants