Skip to content

Commit

Permalink
RC-40: Register listeners via @handler annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoodrich committed Jan 3, 2025
1 parent de1bad9 commit 5992442
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.openmrs.api.APIException;
import org.openmrs.api.PatientService;
import org.openmrs.api.context.Daemon;
import org.openmrs.event.Event;
import org.openmrs.event.SubscribableEventListener;
import org.openmrs.module.DaemonToken;

Expand Down Expand Up @@ -47,14 +46,6 @@ public void setDaemonToken(DaemonToken daemonToken) {
this.daemonToken = daemonToken;
}

/**
* Subscribes for Class - Patient and specified Actions event.
*/
public void init() {
Event event = new Event();
event.setSubscription(this);
}

/**
* Performs action based on messaged received.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import org.openmrs.Patient;
import org.openmrs.PatientIdentifier;
import org.openmrs.PatientIdentifierType;
import org.openmrs.annotation.Handler;
import org.openmrs.event.Event;
import org.openmrs.module.registrationcore.api.errorhandling.ErrorHandlingService;
import org.openmrs.module.registrationcore.api.errorhandling.PixErrorHandlingService;
import org.openmrs.module.registrationcore.api.mpi.common.MpiException;
import org.openmrs.module.registrationcore.api.mpi.common.MpiProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -21,6 +23,8 @@
* This class listens for patient CREATED events. If MPI is enabled, it exports patient to MPI, and
* updates the local patient with the new patient identifier generated by the MPI.
*/
@Handler
@Component("registrationcore.patientCreatedListener")
public class PatientCreatedListener extends PatientActionListener {

private static final Logger LOGGER = LoggerFactory.getLogger(PatientCreatedListener.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.commons.lang.exception.ExceptionUtils;
import org.openmrs.Patient;
import org.openmrs.annotation.Handler;
import org.openmrs.event.Event;

import javax.jms.Message;
Expand All @@ -10,13 +11,16 @@
import org.openmrs.module.registrationcore.api.mpi.common.MpiException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
* This class listens for patient UPDATED events. If MPI is enabled it updates patient in MPI.
*/
@Handler
@Component("registrationcore.patientUpdatedListener")
public class PatientUpdatedListener extends PatientActionListener {

private static final Logger LOGGER = LoggerFactory.getLogger(PatientUpdatedListener.class);
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/resources/moduleApplicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
</bean>

<bean id="registrationcore.patientCreatedListener"
class="org.openmrs.module.registrationcore.api.impl.PatientCreatedListener" init-method="init">
class="org.openmrs.module.registrationcore.api.impl.PatientCreatedListener">
<property name="coreProperties" ref="registrationcore.coreProperties"/>
<property name="patientService" ref="patientService"/>
<property name="mpiProperties" ref="registrationcore.mpiProperties"/>
<property name="identifierBuilder" ref="registrationcore.identifierBuilder"/>
</bean>

<bean id="registrationcore.patientUpdatedListener"
class="org.openmrs.module.registrationcore.api.impl.PatientUpdatedListener" init-method="init">
class="org.openmrs.module.registrationcore.api.impl.PatientUpdatedListener">
<property name="coreProperties" ref="registrationcore.coreProperties"/>
<property name="patientService" ref="patientService"/>
</bean>
Expand Down

0 comments on commit 5992442

Please sign in to comment.