    001// Copyright 2011 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007// http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.ioc.services.cron;
    016
    017/**
    018 * A service that executes a job at intervals specified by a {@link Schedule}.
    019 *
    020 * @since 5.3
    021 */
    022public interface PeriodicExecutor
    023{
    024    /**
    025     * Adds a job to be executed. The job is executed in a thread pool (via {@link org.apache.tapestry5.ioc.services.ParallelExecutor#invoke(org.apache.tapestry5.ioc.Invokable)}), as determined by the schedule.
    026     *
    027     * @param schedule defines when the job will next execute
    028     * @param name     a name used in debugging output related to the job
    029     * @param job      a Runnable object that represents the work to be done
    030     * @return a PeriodicJob that can be used to query when the job executes, or to cancel its execution
    031     */
    032    PeriodicJob addJob(Schedule schedule, String name, Runnable job);
    033}