KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > modules > scheduledjob > SimpleJob


1 package org.apache.turbine.modules.scheduledjob;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.turbine.modules.ScheduledJob;
20 import org.apache.turbine.services.schedule.JobEntry;
21
22 /**
23  * Simple job for use with unit testing of the scheduler service. This
24  * job merely increments a static counter variable when it is run. You
25  * can check the counter to verify the job has run.
26  *
27  * @author <a HREF="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
28  * @author <a HREF="mailto:epugh@upstate.com">Eric Pugh</a>
29  * @version $Id: SimpleJob.java,v 1.4.2.2 2004/05/20 03:32:54 seade Exp $
30  */

31 public class SimpleJob
32         extends ScheduledJob
33 {
34     /** The test counter */
35     private static int counter = 0;
36
37     /**
38      * Run the Jobentry from the scheduler queue.
39      *
40      * @param job The job to run.
41      * @throws java.lang.Exception generic exception
42      */

43     public void run(JobEntry job)
44             throws Exception JavaDoc
45     {
46         counter++;
47         System.out.println("\n\nI AM RUNNING!\n\n");
48         
49     }
50     /**
51      * Returns the counter value.
52      *
53      * @return The counter value
54      */

55     public static int getCounter()
56     {
57         return counter;
58     }
59
60     /**
61      * Sets the counter.
62      *
63      * @param i The new counter value
64      */

65     public static void setCounter(int i)
66     {
67         counter = i;
68     }
69 }
70
Popular Tags