TRUNK-6651: Make @OpenmrsProfile self-enforcing via @Component + @Conditional#6189
Open
solomonfortune wants to merge 1 commit into
Open
TRUNK-6651: Make @OpenmrsProfile self-enforcing via @Component + @Conditional#6189solomonfortune wants to merge 1 commit into
solomonfortune wants to merge 1 commit into
Conversation
7ea836f to
8269398
Compare
8269398 to
d1e2d55
Compare
|
jwnasambu
reviewed
Jun 14, 2026
| * stereotype annotation with a non-empty value, the two names must agree; a conflict will cause a | ||
| * Spring startup exception. | ||
| * | ||
| * @since 2.8 |
Contributor
There was a problem hiding this comment.
Given that the current project version is 3.0.0-SNAPSHOT, ensure this is the intended version for this feature. If it's not being backported to a 2.x release, it should be
@SInCE 3.0.0.
| profile.put("openmrsPlatformVersion", annotationAttributes.getOrDefault("openmrsPlatformVersion", "")); | ||
| profile.put("modules", annotationAttributes.getOrDefault("modules", new String[0])); | ||
|
|
||
| return new OpenmrsProfileExcludeFilter().matchOpenmrsProfileAttributes(profile); |
Contributor
There was a problem hiding this comment.
Suggested change
| return new OpenmrsProfileExcludeFilter().matchOpenmrsProfileAttributes(profile); | |
| return OpenmrsProfileExcludeFilter.matchOpenmrsProfileAttributes(profile); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



TRUNK-6651: Make @OpenmrsProfile self-enforcing via @component + @conditional
Description of what I changed
@OpenmrsProfilewas previously enforced only by twoTypeFilters (OpenmrsProfileIncludeFilter/OpenmrsProfileExcludeFilter) wired into core's<context:component-scan base-package="org.openmrs">. BecauseTypeFilters are scan-local, a module declaring its own<context:component-scan>overorg.openmrs.module.*(with default filters and no OpenMRS-specific filters) would register a@Component @OpenmrsProfile(...)bean even when its profile did notmatch — the scan sees
@Componentand has nothing to exclude it.To fix this,
@OpenmrsProfileis now meta-annotated with:@Component— makes any@OpenmrsProfile-annotated class a scan candidate under default filters, replacing the role ofOpenmrsProfileIncludeFilter.@Conditional(OpenmrsProfileCondition.class)— gates bean registration on profile match in every component-scan,@Beanmethod, and@Import, replacing the role ofOpenmrsProfileExcludeFilter.Specific changes:
api/src/main/java/org/openmrs/annotation/OpenmrsProfile.java@Componentand@Conditional(OpenmrsProfileCondition.class)meta-annotations
value()attribute (default"") so callers can name the bean asthey would with
@Component("name")api/src/main/java/org/openmrs/annotation/OpenmrsProfileCondition.java(new)Conditionimplementation that reusesOpenmrsProfileExcludeFilter.matchOpenmrsProfileAttributes(...)soplatform-version / required-module matching logic stays centralized and
unchanged
api/src/main/resources/applicationContext-service.xmlOpenmrsProfileIncludeFilterandOpenmrsProfileExcludeFilterentries from theorg.openmrscomponent-scanBehavioral changes (release-note worthy):
@Component @OpenmrsProfilebean whose profile does not match will no longer load via any component-scan, including module scans that previously lacked the OpenMRS TypeFilters.@OpenmrsProfilepurely as a non-bean marker will now be registered as a bean when its profile matches, since@OpenmrsProfileis now a stereotype annotation itself.Issue I worked on
see https://issues.openmrs.org/browse/TRUNK-6651
Checklist: I completed these to help reviewers :)
mvn clean packageright before creating this pull request and added all formatting changes to my commit.