Skip to content

Support for Profiles #2

@hjohn

Description

@hjohn

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions