KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > timer > LocalWorkflowJob


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow.timer;
6
7 import com.opensymphony.workflow.Workflow;
8 import com.opensymphony.workflow.WorkflowException;
9 import com.opensymphony.workflow.basic.BasicWorkflow;
10
11 import org.quartz.Job;
12 import org.quartz.JobDataMap;
13 import org.quartz.JobExecutionContext;
14 import org.quartz.JobExecutionException;
15
16
17 /**
18  * DOCUMENT ME!
19  *
20  * @author $author$
21  * @version $Revision: 1.4 $
22  */

23 public class LocalWorkflowJob implements Job {
24     //~ Methods ////////////////////////////////////////////////////////////////
25

26     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
27         JobDataMap data = jobExecutionContext.getJobDetail().getJobDataMap();
28         long id = data.getLong("entryId");
29         int triggerId = data.getInt("triggerId");
30         String JavaDoc username = data.getString("username");
31         Workflow wf = new BasicWorkflow(username);
32
33         try {
34             wf.executeTriggerFunction(id, triggerId);
35         } catch (WorkflowException e) {
36             //this cast is a fairly horrible hack, but it's more due to the fact that quartz is stupid enough to have wrapped exceptions
37
//wrap Exception, instead of Throwable.
38
throw new JobExecutionException("Error Executing local job", (e.getRootCause() != null) ? (Exception JavaDoc) e.getRootCause() : e, true);
39         }
40     }
41 }
42
Popular Tags