Implementing Jobs

From Obsidian Scheduler
Revision as of 22:43, 20 February 2011 by Craig (talk | contribs) (Created page with "= SchedulableJob Interface = Implementing jobs in Espresso couldn't be easier. All functionality in Espresso is exposed in an interface requiring implementation of a single meth...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

SchedulableJob Interface

Implementing jobs in Espresso couldn't be easier. All functionality in Espresso is exposed in an interface requiring implementation of a single method.
com.carfey.ops.job.SchedulableJob's contract is simply public void execute(Context context) throws Exception.

Implementation

In your implementation, the single method would do whatever work is required and is free to throw any Exception that is then handled by Espresso. If you have no parameterization or any dependency on runtime information, that's all you need do. Perhaps you are able to just call some existing class that provides all the functionality that you need to schedule. Here's an example you can follow.

import com.carfey.ops.job.Context;
import com.carfey.ops.job.SchedulableJob;

public class MyScheduledJob implements SchedulableJob {
	public void execute(Context context) throws Exception {
		MyExistingFunction function = new MyExistingFunction();
		function.go();
	}
}