Book Image

OSWorkflow: A guide for Java developers and architects to integrating open-source Business Process Management

Book Image

OSWorkflow: A guide for Java developers and architects to integrating open-source Business Process Management

Overview of this book

OSWorkflow is an open-source workflow engine written entirely in Java with a flexible approach and a technical user-base target. It is released under the Apache License. You can create simple or complex workflows, depending on your needs. You can focus your work on the business logic and rules. No more Petri Net or finite state machine coding! You can integrate OSWorkflow into your application with a minimum of fuss. OSWorkflow provides all of the workflow constructs that you might encounter in real-life processes, such as steps, conditions, loops, splits, joins, roles, etc.This book explains in detail all the various aspects of OSWorkflow, without assuming any prior knowledge of Business Process Management. Real-life examples are used to clarify concepts.
Table of Contents (13 chapters)
OSWorkflow
Credits
About the Author
About the Reviewers
Introduction

Scheduling a Job


We will get a first taste of Quartz, by executing a very simple job. The following snippet of code shows how easy it is to schedule a job.

SchedulerFactory schedFact = new
org.quartz.impl.StdSchedulerFactory();
Scheduler sched = schedFact.getScheduler();
sched.start();
JobDetail jobDetail = new JobDetail("myJob", null, HelloJob.class);
Trigger trigger = TriggerUtils.makeHourlyTrigger();
// fire every hour
trigger.setStartTime(TriggerUtils.getEvenHourDate(new Date()));
// start on the next even hour
trigger.setName("myTrigger");
sched.scheduleJob(jobDetail, trigger);

The following code assumes a HelloJob class exists. It is a very simple class that implements the job interface and just prints a message to the console.

package packtpub.osw;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
* Hello world job.
*/
public class HelloJob implements Job
{
public void execute(JobExecutionContext ctx) throws
JobExecutionException...