    001    package org.apache.turbine.modules.scheduledjob;
    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
    024    import org.apache.turbine.modules.ScheduledJob;
    025    import org.apache.turbine.services.schedule.JobEntry;
    026
    027    /**
    028     * Simple job for use with unit testing of the scheduler service.  This
    029     * job merely increments a static counter variable when it is run.  You
    030     * can check the counter to verify the job has run.
    031     *
    032     * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
    033     * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
    034     * @version $Id: SimpleJob.java 615328 2008-01-25 20:25:05Z tv $
    035     */
    036    public class SimpleJob
    037            extends ScheduledJob
    038    {
    039        /** The test counter */
    040        private static int counter = 0;
    041
    042        /**
    043         * Run the Jobentry from the scheduler queue.
    044         *
    045         * @param job The job to run.
    046         * @throws java.lang.Exception generic exception
    047         */
    048        public void run(JobEntry job)
    049                throws Exception
    050        {
    051            counter++;
    052            System.out.println("\n\nI AM RUNNING!\n\n");
    053
    054        }
    055        /**
    056         * Returns the counter value.
    057         *
    058         * @return The counter value
    059         */
    060        public static int getCounter()
    061        {
    062            return counter;
    063        }
    064
    065        /**
    066         * Sets the counter.
    067         *
    068         * @param i The new counter value
    069         */
    070        public static void setCounter(int i)
    071        {
    072            counter = i;
    073        }
    074    }