Skip to content

Allow properties as parameter of filter method #246

@charphi

Description

@charphi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions