001package org.apache.turbine.services.schedule; 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 java.util.List; 025 026import org.apache.turbine.services.Service; 027import org.apache.turbine.util.TurbineException; 028 029/** 030 * ScheduleService interface. 031 * 032 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a> 033 * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a> 034 * @version $Id$ 035 */ 036public interface ScheduleService 037 extends Service 038{ 039 /** Name of service */ 040 String SERVICE_NAME = "SchedulerService"; 041 042 /** TR.props key for initially activating the scheduler thread */ 043 String INTIALLY_ACTIVE = "enabled"; 044 045 /** TR.props key for the logger */ 046 String LOGGER_NAME = "scheduler"; 047 048 /** 049 * Factory method for a new Job 050 * 051 * Schedule a job to run on a certain point of time.<br> 052 * 053 * Example 1: Run the DefaultScheduledJob at 8:00am every 15th of 054 * the month - <br> 055 * 056 * JobEntry je = newJob(0,0,8,-1,15,"DefaultScheduledJob");<br> 057 * 058 * Example 2: Run the DefaultScheduledJob at 8:00am every day - 059 * <br> 060 * 061 * JobEntry je = newJob(0,0,8,-1,-1,"DefaultScheduledJob");<br> 062 * 063 * Example 3: Run the DefaultScheduledJob every 2 hours. - <br> 064 * 065 * JobEntry je = newJob(0,120,-1,-1,-1,"DefaultScheduledJob");<br> 066 * 067 * Example 4: Run the DefaultScheduledJob every 30 seconds. - <br> 068 * 069 * JobEntry je = newJob(30,-1,-1,-1,-1,"DefaultScheduledJob");<br> 070 * 071 * @param sec Value for entry "seconds". 072 * @param min Value for entry "minutes". 073 * @param hour Value for entry "hours". 074 * @param wd Value for entry "week days". 075 * @param day_mo Value for entry "month days". 076 * @param task Task to execute. 077 * 078 * @return A JobEntry. 079 * @throws TurbineException could not create job 080 */ 081 JobEntry newJob(int sec, 082 int min, 083 int hour, 084 int wd, 085 int day_mo, 086 String task) throws TurbineException; 087 088 /** 089 * Get a specific Job from Storage. 090 * 091 * @param oid The int id for the job. 092 * @return A JobEntry. 093 * @throws TurbineException could not retrieve job 094 */ 095 JobEntry getJob(int oid) 096 throws TurbineException; 097 098 /** 099 * Add a new job to the queue. 100 * 101 * @param je A JobEntry with the job to add. 102 * @throws TurbineException job could not be added 103 */ 104 void addJob(JobEntry je) 105 throws TurbineException; 106 107 /** 108 * Modify a Job. 109 * 110 * @param je A JobEntry with the job to modify 111 * @throws TurbineException job could not be updated 112 */ 113 void updateJob(JobEntry je) 114 throws TurbineException; 115 116 /** 117 * Remove a job from the queue. 118 * 119 * @param je A JobEntry with the job to remove. 120 * @throws TurbineException job could not be removed 121 */ 122 void removeJob(JobEntry je) 123 throws TurbineException; 124 125 /** 126 * List jobs in the queue. This is used by the scheduler UI. 127 * 128 * @return A List of jobs. 129 */ 130 List<? extends JobEntry> listJobs(); 131 132 /** 133 * Determines if the scheduler service is currently active. 134 * 135 * @return Status of the scheduler service. 136 */ 137 boolean isEnabled(); 138 139 /** 140 * Starts the scheduler if not already running. 141 */ 142 void startScheduler(); 143 144 /** 145 * Stops the scheduler if ti is currently running. 146 */ 147 void stopScheduler(); 148 149}