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