TRUNK-4988: Convenience method to allow us to change the configuration more easily#5934
TRUNK-4988: Convenience method to allow us to change the configuration more easily#5934shivvani-r wants to merge 3 commits intoopenmrs:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5934 +/- ##
============================================
- Coverage 59.31% 59.29% -0.02%
- Complexity 9252 9254 +2
============================================
Files 686 686
Lines 37123 37136 +13
Branches 5452 5457 +5
============================================
+ Hits 22018 22019 +1
- Misses 13141 13150 +9
- Partials 1964 1967 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jwnasambu
left a comment
There was a problem hiding this comment.
Kindly we need to verify that the system correctly falls back to the default implementations MailMessageSender, VelocityMessagePreparator when no beans are registered.
In addition, MessageService is a singleton, modifying it in a test can break other tests if the state isn't perfectly restored. I would recommend adding this test case using a try-finally block to guarantee cleanup. Otherwise, Great work!
Thanks for the feedback, @jwnasambu! I've extracted the duplicate logic into a |
|



Description of what I changed
I have implemented dynamic Spring dependency injection for
MessageServiceinContext.javato allow easier configuration of message senders and preparators.Why the change was needed:
Previously, the
MessageServicedependencies (MessageSenderandMessagePreparator) were strictly hardcoded to instantiateMailMessageSenderandVelocityMessagePreparator. This rigid coupling prevented hospitals or developers from easily swapping in custom modules (such as an SMS sender) without modifying and recompiling the core Java code.Specific changes include:
Context.getMessageService()with dynamic Spring bean lookups usinggetRegisteredComponents().MailMessageSenderandVelocityMessagePreparator.ContextTest.javato verify that dynamically registeredMessageSenderandMessagePreparatorbeans are successfully discovered and loaded from theApplicationContext.Issue I worked on
see https://issues.openmrs.org/browse/TRUNK-4988
Checklist: I completed these to help reviewers :)
mvn clean packageright before creating this pull request and added all formatting changes to my commit.