    001package org.apache.turbine.modules.scheduledjobs;
    002
    003
    004/*
    005 * Licensed to the Apache Software Foundation (ASF) under one
    006 * or more contributor license agreements.  See the NOTICE file
    007 * distributed with this work for additional information
    008 * regarding copyright ownership.  The ASF licenses this file
    009 * to you under the Apache License, Version 2.0 (the
    010 * "License"); you may not use this file except in compliance
    011 * with the License.  You may obtain a copy of the License at
    012 *
    013 *   http://www.apache.org/licenses/LICENSE-2.0
    014 *
    015 * Unless required by applicable law or agreed to in writing,
    016 * software distributed under the License is distributed on an
    017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    018 * KIND, either express or implied.  See the License for the
    019 * specific language governing permissions and limitations
    020 * under the License.
    021 */
    022
    023
    024import org.apache.commons.logging.Log;
    025import org.apache.commons.logging.LogFactory;
    026import org.apache.turbine.modules.ScheduledJob;
    027import org.apache.turbine.services.schedule.JobEntry;
    028
    029/**
    030 * Simple job for use with unit testing of the scheduler service.  This
    031 * job merely increments a static counter variable when it is run.  You
    032 * can check the counter to verify the job has run.
    033 *
    034 * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
    035 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
    036 * @version $Id: SimpleJob.java 1723703 2016-01-08 11:40:19Z tv $
    037 */
    038public class SimpleJob
    039        extends ScheduledJob
    040{
    041    /** Logging */
    042    private static Log log = LogFactory.getLog(SimpleJob.class);
    043
    044    /** The test counter */
    045    private static int counter = 0;
    046
    047    /**
    048     * Run the Jobentry from the scheduler queue.
    049     *
    050     * @param job The job to run.
    051     * @throws java.lang.Exception generic exception
    052     */
    053    @Override
    054    public void run(JobEntry job)
    055            throws Exception
    056    {
    057        counter++;
    058        log.info("I AM RUNNING!");
    059    }
    060
    061    /**
    062     * Returns the counter value.
    063     *
    064     * @return The counter value
    065     */
    066    public static int getCounter()
    067    {
    068        return counter;
    069    }
    070
    071    /**
    072     * Sets the counter.
    073     *
    074     * @param i The new counter value
    075     */
    076    public static void setCounter(int i)
    077    {
    078        counter = i;
    079    }
    080}