KickJava   Java API By Example, From Geeks To Geeks.

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


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

5 /*
6  * Created by IntelliJ IDEA.
7  * User: plightbo
8  * Date: May 22, 2002
9  * Time: 4:10:43 PM
10  */

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 /**
31  * DOCUMENT ME!
32  *
33  * @author $author$
34  * @version $Revision: 1.5 $
35  */

36 public class WorkflowJob implements Job {
37     //~ Static fields/initializers /////////////////////////////////////////////
38

39     private static final Log log = LogFactory.getLog(WorkflowJob.class);
40
41     //~ Methods ////////////////////////////////////////////////////////////////
42

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 JavaDoc username = data.getString("username");
49             String JavaDoc 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             //this cast is a fairly horrible hack, but it's more due to the fact that quartz is stupid enough to have wrapped exceptions
63
//wrap Exception, instead of Throwable.
64
throw new JobExecutionException("Error Executing trigger", (e.getRootCause() != null) ? (Exception JavaDoc) e.getRootCause() : e, true);
65         }
66     }
67 }
68
Popular Tags