[OSWORKFLOW-2] Scheduled workflow doesn't get the right config Created: 03/Nov/04  Updated: 03/Nov/04

Status: Open
Project: osworkflow
Component/s: www
Affects Version/s: current
Fix Version/s: milestone 1

Type: Task Priority: Major
Reporter: fxlelouarn Assignee: hani
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issuezilla Id: 2

 Description   

When a scheduled job recreates a workflow (i.e.: new BasicWorkflow()), it
doesn't specify its configuration, so the workflow is stuck with the static
configuration (described in "osworkflow.xml"). With the new, non-singletonish,
way of doing things, it should be possible to specify the configuration to the
WorkflowJob.

I guess the best way to handle this would be to add an optional parameter in the
ScheduleJob XML description. Something like <arg
name="configLocation">prot://some/url/myConfigLocation.xml</arg>.

I have a patch for an issue I just entered, if needed. Two files are to be
modified 1) com.opensymphony.workflow.timer.LocalWorkflowJob and 2)
com.opensymphony.workflow.util.ScheduleJob.

Index: LocalWorkflowJob.java
===================================================================
RCS file:
/cvs/osworkflow/src/java/com/opensymphony/workflow/timer/LocalWorkflowJob.java,v
retrieving revision 1.4
diff -u -r1.4 LocalWorkflowJob.java
— LocalWorkflowJob.java 3 Oct 2003 20:17:27 -0000 1.4
+++ LocalWorkflowJob.java 3 Nov 2004 15:45:09 -0000
@@ -7,12 +7,19 @@
import com.opensymphony.workflow.Workflow;
import com.opensymphony.workflow.WorkflowException;
import com.opensymphony.workflow.basic.BasicWorkflow;
+import com.opensymphony.workflow.config.Configuration;
+import com.opensymphony.workflow.config.DefaultConfiguration;
+
+import org.apache.log4j.Logger;

import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

+import java.net.MalformedURLException;
+import java.net.URL;
+

/**

  • DOCUMENT ME!
    @@ -21,21 +28,75 @@
  • @version $Revision: 1.4 $
    */
    public class LocalWorkflowJob implements Job {
    + //~ Static fields/initializers /////////////////////////////////////////////
    +
    + private static final Logger log = Logger.getLogger(LocalWorkflowJob.class);
    +
    //~ Methods ////////////////////////////////////////////////////////////////

+ // ////////////////////////////////////////////////////////////////
public void execute(JobExecutionContext jobExecutionContext) throws
JobExecutionException {
JobDataMap data = jobExecutionContext.getJobDetail().getJobDataMap();
long id = data.getLong("entryId");
int triggerId = data.getInt("triggerId");
String username = data.getString("username");
+ String configLocation = data.getString("configLocation");
+
+ Configuration config = new DefaultConfiguration();
+ URL configURL = getURL(Thread.currentThread().getContextClassLoader(),
configLocation);
+
+ if (configURL == null)

{ + configURL = getURL(getClass().getClassLoader(), configLocation); + }

+
+ if (configURL == null)

{ + configURL = getClass().getResource(configLocation); + }

+
Workflow wf = new BasicWorkflow(username);

try {
+ if (log.isDebugEnabled())

{ + log.debug("Loading configuration from '" + configURL + "'"); + }

+
+ config.load(configURL);
+ wf.setConfiguration(config);
wf.executeTriggerFunction(id, triggerId);
} catch (WorkflowException e)

{ - //this cast is a fairly horrible hack, but it's more due to the fact that quartz is stupid enough to have wrapped exceptions + //this cast is a fairly horrible hack, but it's more due to the + // fact that quartz is stupid enough to have wrapped exceptions //wrap Exception, instead of Throwable. throw new JobExecutionException("Error Executing local job", (e.getRootCause() != null) ? (Exception) e.getRootCause() : e, true); }

+ }
+
+ private URL getURL(ClassLoader classLoader, String location) {
+ URL url = null;
+
+ if ((location != null) && (location.indexOf(":/") > -1)) {
+ try

{ + url = new URL(location); + }

catch (MalformedURLException e)

{ + }

+ }
+
+ if (url == null)

{ + url = classLoader.getResource(location); + }

+
+ if (url == null)

{ + url = classLoader.getResource("/" + location); + }

+
+ if (url == null)

{ + url = classLoader.getResource("META-INF/" + location); + }

+
+ if (url == null)

{ + url = classLoader.getResource("/META-INF/" + location); + }

+
+ return url;
}
}

Index: ScheduleJob.java
===================================================================
RCS file: /cvs/osworkflow/src/java/com/opensymphony/workflow/util/ScheduleJob.java,v
retrieving revision 1.4
diff -u -r1.4 ScheduleJob.java
— ScheduleJob.java 5 Dec 2003 01:18:07 -0000 1.4
+++ ScheduleJob.java 3 Nov 2004 15:43:44 -0000
@@ -53,6 +53,7 @@

  • defaults to either a WorkflowJob or a LocalWorkflowJob if "local" is set to
    true.
  • <li>schedulerName - the name of an existing scheduler to use</li>
  • <li>schdulerStart - if "true", start the scheduler if it hasn't been
    started already</li>
    + * <li>configLocation - the location of the configuration file to be loaded
    ("osworkflow.xml"), in a resource format (url, ClassLoader.getResource(), etc.)</li>
  • <li>txHack - set this to true if you are getting lockups while running with
    transactions (defaults to false)</li>
  • </ul>
    *
    @@ -91,6 +92,8 @@
    String triggerName = (String) args.get("triggerName");
    String groupName = (String) args.get("groupName");

+ String configLocation = (String) args.get("configLocation");
+
String username = (String) args.get("username");
String password = (String) args.get("password");

@@ -205,6 +208,7 @@
dataMap.put("entryId", entry.getId());
dataMap.put("username", username);
dataMap.put("password", password);
+ dataMap.put("configLocation", configLocation);
jobDetail.setJobDataMap(dataMap);
jobDetail.setDurability(true);






[OSWORKFLOW-1] Scheduled workflow doesn't get the right config Created: 03/Nov/04  Updated: 03/Nov/04

Status: Open
Project: osworkflow
Component/s: www
Affects Version/s: current
Fix Version/s: milestone 1

Type: Bug Priority: Major
Reporter: fxlelouarn Assignee: osworkflow-issues
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issuezilla Id: 1

 Description   

When a scheduled job recreates a workflow (i.e.: new BasicWorkflow()), it
doesn't specify its configuration, so the workflow is stuck with the static
configuration (described in "osworkflow.xml"). With the new, non-singletonish,
way of doing things, it should be possible to specify the configuration to the
WorkflowJob.

I guess the best way to handle this would be to add an optional parameter in the
ScheduleJob XML description. Something like <arg
name="configLocation">prot://some/url/myConfigLocation.xml</arg>.






Generated at Fri May 22 16:48:10 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.