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

Support for Profiles #2

Open
hjohn opened this issue May 12, 2022 · 0 comments
Open

Support for Profiles #2

hjohn opened this issue May 12, 2022 · 0 comments

Comments

@hjohn
Copy link
Owner

hjohn commented May 12, 2022

Overriding a type for testing is a very useful feature. A possible way to allow for this is supporting qualifiers for types which act at registration time. They could work in a similar fashion as the meta annotation @Qualifier. Options are a meta annotation @Profile or @ProfileQualifier.

A profile qualifier could then be created similar to Spring as follows:

@ProfileQualifier
@Repeatable
@interface Profile {
  String value();
}

Possible Implementation

An external strategy should be able to determine if a type is allowed to be registered. The external strategy could be configured with the active profiles, and then given an AnnotatedElement determine if a given type is allowed to be registered or not:

 boolean allowRegistration(AnnotatedElement element);

The injector calls this for each type about to be registered and rejects registration if the method returns false. How to reject the registration is still unclear:

  1. Silently skip registration
  2. Throw an exception
  3. Throw an exception only for explicitly registered types (not auto discovered ones)

Externalizing the profile determination allows to create customized implementations of profiles without changes to the core system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant