Changeset 4171 for openmrs-modules/xforms/trunk/src/org/openmrs/module/xforms/ProcessXformsQueueTask.java
- Timestamp:
- 05/12/08 12:34:55 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/xforms/trunk/src/org/openmrs/module/xforms/ProcessXformsQueueTask.java
r3226 r4171 4 4 import org.apache.commons.logging.LogFactory; 5 5 import org.openmrs.api.APIException; 6 import org.openmrs.api.AdministrationService;7 6 import org.openmrs.api.context.Context; 8 import org.openmrs.api.context.ContextAuthenticationException; 9 import org.openmrs.module.xforms.bluetooth.XformsBluetoothTask; 10 import org.openmrs.scheduler.TaskConfig; 11 import org.openmrs.scheduler.Schedulable; 12 7 import org.openmrs.scheduler.tasks.AbstractTask; 13 8 14 9 /** … … 18 13 * @version 1.0 19 14 */ 20 public class ProcessXformsQueueTask implements Schedulable{15 public class ProcessXformsQueueTask extends AbstractTask { 21 16 22 //Logger17 // Logger 23 18 private static Log log = LogFactory.getLog(ProcessXformsQueueTask.class); 24 19 25 // Task configuration 26 private TaskConfig taskConfig; 27 28 //Instance of xforms processor. 20 // Instance of xforms processor. 29 21 private XformsQueueProcessor processor = null; 30 22 31 23 /** 32 24 * Default Constructor (Uses SchedulerConstants.username and … … 40 32 41 33 /** 42 * Process the next xform in the queue and then remove the xform 43 * from thequeue.34 * Process the next xform in the queue and then remove the xform from the 35 * queue. 44 36 */ 45 public void run() {37 public void execute() { 46 38 Context.openSession(); 47 39 log.debug("Running xforms queue task... "); … … 49 41 if (Context.isAuthenticated() == false) 50 42 authenticate(); 51 52 43 processor.processXformsQueue(); 53 54 44 } catch (APIException e) { 55 45 log.error("Error running xforms queue task", e); … … 59 49 } 60 50 } 61 51 62 52 /** 63 53 * Clean up any resources here 64 * 54 * 65 55 */ 66 56 public void shutdown() { 67 68 } 69 70 /** 71 * Initialize task. 72 * 73 * @param config 74 */ 75 public void initialize(TaskConfig config) { 76 this.taskConfig = config; 77 } 78 79 private void authenticate() { 80 try { 81 AdministrationService adminService = Context.getAdministrationService(); 82 Context.authenticate(adminService.getGlobalProperty("scheduler.username"), 83 adminService.getGlobalProperty("scheduler.password")); 84 85 } catch (ContextAuthenticationException e) { 86 log.error("Error authenticating user", e); 87 } 57 processor = null; 58 super.shutdown(); 59 log.debug("Shutting down ProcessXformsQueue task ..."); 88 60 } 89 61 }