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 properties as parameter of filter method #246

Open
charphi opened this issue Jun 26, 2023 · 0 comments
Open

Allow properties as parameter of filter method #246

charphi opened this issue Jun 26, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@charphi
Copy link
Member

charphi commented Jun 26, 2023

Currently, a filter method has no parameter.
It is possible to filter a service provider with a system property but it uses a static global variable. That global variable makes it difficult to test and prevents some use cases.

It could be interesting to allow a sorter method to have one parameter to inject those properties.

@ServiceDefinition
interface MyService {

  @ServiceFilter
  boolean isAvailable(Properties properties);
}

@ServiceProvider 
class Impl implements MyService {

  @Override
  public boolean isAvailable(Properties properties) {
    return Objects.equals(properties.getProperty("os.name"), "Windows 10");
  }
}
@charphi charphi added the enhancement New feature or request label Jun 26, 2023
@charphi charphi changed the title Allow properties as parameter of sorter method Allow properties as parameter of filter method Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant