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");
}
}
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.