01: package org.apache.turbine.modules.scheduledjob;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.turbine.modules.ScheduledJob;
23: import org.apache.turbine.services.schedule.JobEntry;
24:
25: /**
26: * Simple job for use with unit testing of the scheduler service. This
27: * job merely increments a static counter variable when it is run. You
28: * can check the counter to verify the job has run.
29: *
30: * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
31: * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
32: * @version $Id: SimpleJob.java 534527 2007-05-02 16:10:59Z tv $
33: */
34: public class SimpleJob extends ScheduledJob {
35: /** The test counter */
36: private static int counter = 0;
37:
38: /**
39: * Run the Jobentry from the scheduler queue.
40: *
41: * @param job The job to run.
42: * @throws java.lang.Exception generic exception
43: */
44: public void run(JobEntry job) throws Exception {
45: counter++;
46: System.out.println("\n\nI AM RUNNING!\n\n");
47:
48: }
49:
50: /**
51: * Returns the counter value.
52: *
53: * @return The counter value
54: */
55: public static int getCounter() {
56: return counter;
57: }
58:
59: /**
60: * Sets the counter.
61: *
62: * @param i The new counter value
63: */
64: public static void setCounter(int i) {
65: counter = i;
66: }
67: }
|