questions about multithreading and aop calls

classic Classic list List threaded Threaded
1 message Options
Tammy Dugan Tammy Dugan
Reply | Threaded
Open this post in threaded view
|

questions about multithreading and aop calls

I have the following AOP method:

public void afterReturning(Object returnValue, Method method,
            Object[] args, Object target) throws Throwable
    {
        if (method.getName().equals("messageProcessed"))
        {
            try
            {
                if (method.getParameterTypes()[0].getName().compareTo(
                        "org.openmrs.Encounter") == 0)
                {
                    org.openmrs.Encounter encounter =
(org.openmrs.Encounter) args[0];
                    Thread thread = new Thread(new
CheckinPatient(encounter));
                    thread.start();
                }
            } catch (Exception e)
            {
                log.error(e.getMessage());
               
log.error(org.openmrs.module.dss.util.Util.getStackTrace(e));
            }
        }

        if (method.getName().equals("fileProcessed"))
        {
            TeleformFileState tfState = (TeleformFileState) args[0];
            Thread thread = new Thread(new ProcessFile(tfState));
            thread.start();
        }
    }

This method is failing because the thread that I create appears to die
when I return from the AOP call. I want each of these AOP calls to
execute in a separate threads. One idea I had was to have a static
thread manager class that just keeps a handle on the thread objects I
create so they are not killed when the AOP call returns. The static
class would then periodically purge any threads that are no longer
running. Is this a viable solution or is there a better way to do this?

Thanks,

Tammy

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]