01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: /*
06: * Created by IntelliJ IDEA.
07: * User: plightbo
08: * Date: May 22, 2002
09: * 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: * DOCUMENT ME!
31: *
32: */
33: public class WorkflowJob implements Job {
34: //~ Static fields/initializers /////////////////////////////////////////////
35:
36: private static final Log log = LogFactory.getLog(WorkflowJob.class);
37:
38: //~ Methods ////////////////////////////////////////////////////////////////
39:
40: public void execute(JobExecutionContext jobExecutionContext)
41: throws JobExecutionException {
42: try {
43: JobDataMap data = jobExecutionContext.getJobDetail()
44: .getJobDataMap();
45: long id = data.getLong("entryId");
46: int triggerId = data.getInt("triggerId");
47: String username = data.getString("username");
48: String password = data.getString("password");
49: Context context = new Context();
50: context.setProperty("authUser", username);
51: context.setProperty("authPassword", password);
52:
53: Workflow wf = (Workflow) Registry.bind(System.getProperty(
54: "osworkflow.soap.url",
55: "http://localhost/example/glue/oswf.wsdl"),
56: Workflow.class, context);
57: wf.executeTriggerFunction(id, triggerId);
58: } catch (RegistryException e) {
59: log.error("Error using GLUE to make remote call", e);
60: throw new JobExecutionException(
61: "Error using GLUE to make remote call", e, true);
62: } catch (WorkflowException e) {
63: log.error("Error Executing trigger", e);
64:
65: //this cast is a fairly horrible hack, but it's more due to the fact that quartz is stupid enough to have wrapped exceptions
66: //wrap Exception, instead of Throwable.
67: throw new JobExecutionException("Error Executing trigger",
68: (e.getRootCause() != null) ? (Exception) e
69: .getRootCause() : e, true);
70: }
71: }
72: }
|