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

BAH-3223 - Appointment module logs errors at startup if atom feed mod… #129

Merged
merged 8 commits into from
Mar 5, 2024

Conversation

mseaton
Copy link
Contributor

@mseaton mseaton commented Sep 15, 2023

…ule is not installed

@CLAassistant
Copy link

CLAassistant commented Sep 15, 2023

CLA assistant check
All committers have signed the CLA.

@rahu1ramesh rahu1ramesh marked this pull request as ready for review September 18, 2023 12:28
* Registers AOP advice when the context starts up.
* This is done instead of declaring advice in config.xml in order to allow it to be conditionally loaded
*/
public class AtomFeedAdviceProvider implements ApplicationContextAware {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this wired up? through component scan?
Also should the advices be wired up conditionally, since the intention is to work without the atomfeed module? should @conditional annotation be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angshu - most likely this needs to have a @component annotation added to it. In my initial testing I was going to see if just implementing the interface was enough, but it's likely it needs to be a registered component. Because this is in the atom-feed maven sub-module, which is itself already conditionally loaded, I assumed that this didn't also need conditional loading associated with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a preferred approach to implementing such conditional loading? I was hoping this had been resolved so that i learn from it

Copy link
Contributor Author

@mseaton mseaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angshu / @gsluthra - see my comments here and on the ticket. Would be good if you could have a look over this.

@@ -1,5 +1,6 @@
package org.openmrs.module.appointments.web.controller;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file are not for this PR, but pending in another PR (see BAH-3222). I need these in place to successfully build and test.

@@ -31,6 +32,7 @@

@RunWith(PowerMockRunner.class)
@PrepareForTest(Context.class)
@PowerMockIgnore( {"javax.*", "org.apache.*", "org.slf4j.*"} )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just an incidental fix- this was throwing stack traces in the logs during the build, and adding this ignore line fixes that.

@@ -27,18 +30,34 @@ public class AppointmentsActivator extends BaseModuleActivator {
private Log log = LogFactory.getLog(this.getClass());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved away from the original approach of using ApplicationContextAware, in favor of a more generally understood approach of using the module activator and iterating over registered components. I made this generalized as it is not specific to advice, but could be utilized for other reasons if needed.

One of the main reasons I moved to this approach is to make an attempt to also clean up / remove advice if the module is stopped like is done with standard advice in the ModuleFactory. This is just an additional precaution, though OpenMRS doesn't really function properly anyway (or I wouldn't trust it to) if modules are started/stopped via the legacy admin interface, and this isn't really a huge concern.


private static final Log log = LogFactory.getLog(AtomFeedAdviceActivatorComponent.class);

private final AppointmentServiceDefinitionAdvice appointmentServiceDefinitionAdvice;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to use these properties and two different constructors just so that I could properly mock in unit tests.

@mseaton mseaton requested a review from angshu February 28, 2024 22:59
@rahu1ramesh rahu1ramesh merged commit 3b7fbc1 into Bahmni:master Mar 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants