KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > jobs > DummyStateJob


1 /*
2  * Copyright 2004, Rob Gordon.
3  */

4 package org.oddjob.jobs;
5
6 import org.oddjob.framework.SimpleJob;
7 import org.oddjob.state.JobState;
8
9 /**
10  *
11  * @author Rob Gordon.
12  */

13 public class DummyStateJob extends SimpleJob {
14     private JobState desired;
15     
16     protected int execute() throws Exception JavaDoc {
17         if (desired.equals(JobState.COMPLETE)) {
18             return 0;
19         }
20         if (desired.equals(JobState.NOT_COMPLETE)) {
21             return 1;
22         }
23         throw new Exception JavaDoc("An exception.");
24     }
25
26     /**
27      * @return Returns the desired.
28      */

29     public String JavaDoc getDesired() {
30         return desired.toString();
31     }
32     /**
33      * @param desired The desired to set.
34      */

35     public void setDesired(String JavaDoc desired) {
36         this.desired = JobState.stateFor(desired);
37         if (this.desired == null) {
38             throw new IllegalArgumentException JavaDoc("Invalid state " + desired);
39         }
40     }
41 }
42
Popular Tags