1 5 11 package com.opensymphony.workflow.timer; 12 13 import com.opensymphony.workflow.Workflow; 14 import com.opensymphony.workflow.WorkflowException; 15 16 import electric.registry.Registry; 17 import electric.registry.RegistryException; 18 19 import electric.util.Context; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 24 import org.quartz.Job; 25 import org.quartz.JobDataMap; 26 import org.quartz.JobExecutionContext; 27 import org.quartz.JobExecutionException; 28 29 30 36 public class WorkflowJob implements Job { 37 39 private static final Log log = LogFactory.getLog(WorkflowJob.class); 40 41 43 public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { 44 try { 45 JobDataMap data = jobExecutionContext.getJobDetail().getJobDataMap(); 46 long id = data.getLong("entryId"); 47 int triggerId = data.getInt("triggerId"); 48 String username = data.getString("username"); 49 String password = data.getString("password"); 50 Context context = new Context(); 51 context.setProperty("authUser", username); 52 context.setProperty("authPassword", password); 53 54 Workflow wf = (Workflow) Registry.bind(System.getProperty("osworkflow.soap.url", "http://localhost/example/glue/oswf.wsdl"), Workflow.class, context); 55 wf.executeTriggerFunction(id, triggerId); 56 } catch (RegistryException e) { 57 log.error("Error using GLUE to make remote call", e); 58 throw new JobExecutionException("Error using GLUE to make remote call", e, true); 59 } catch (WorkflowException e) { 60 log.error("Error Executing trigger", e); 61 62 throw new JobExecutionException("Error Executing trigger", (e.getRootCause() != null) ? (Exception ) e.getRootCause() : e, true); 65 } 66 } 67 } 68 | Popular Tags |