org.apache.turbine.services.schedule
Class TurbineNonPersistentSchedulerService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.turbine.services.schedule.TurbineSchedulerService
                  extended byorg.apache.turbine.services.schedule.TurbineNonPersistentSchedulerService
All Implemented Interfaces:
Initable, ScheduleService, Service

public class TurbineNonPersistentSchedulerService
extends TurbineSchedulerService

Service for a cron like scheduler that uses the TurbineResources.properties file instead of the database. The methods that operate on jobs ( get,add,update,remove ) only operate on the queue in memory and changes are not reflected to the properties file which was used to initilize the jobs. An example is given below. The job names are the class names that extend ScheduledJob.


 services.SchedulerService.scheduler.jobs=scheduledJobName,scheduledJobName2

 services.SchedulerService.scheduler.job.scheduledJobName.ID=1
 services.SchedulerService.scheduler.job.scheduledJobName.SECOND=-1
 services.SchedulerService.scheduler.job.scheduledJobName.MINUTE=-1
 services.SchedulerService.scheduler.job.scheduledJobName.HOUR=7
 services.SchedulerService.scheduler.job.scheduledJobName.WEEKDAY=-1
 services.SchedulerService.scheduler.job.scheduledJobName.DAY_OF_MONTH=-1

 services.SchedulerService.scheduler.job.scheduledJobName2.ID=1
 services.SchedulerService.scheduler.job.scheduledJobName2.SECOND=-1
 services.SchedulerService.scheduler.job.scheduledJobName2.MINUTE=-1
 services.SchedulerService.scheduler.job.scheduledJobName2.HOUR=7
 services.SchedulerService.scheduler.job.scheduledJobName2.WEEKDAY=-1
 services.SchedulerService.scheduler.job.scheduledJobName2.DAY_OF_MONTH=-1

 
Based on TamboraSchedulerService written by John Thorhauer.

Version:
$Id: TurbineNonPersistentSchedulerService.java 534527 2007-05-02 16:10:59Z tv $
Author:
Jeff Brekke, John Thorhauer, Quinton McCombs

Nested Class Summary
 
Nested classes inherited from class org.apache.turbine.services.schedule.TurbineSchedulerService
TurbineSchedulerService.MainLoop
 
Field Summary
 
Fields inherited from class org.apache.turbine.services.schedule.TurbineSchedulerService
mainLoop, scheduleQueue, thread
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.turbine.services.schedule.ScheduleService
INTIALLY_ACTIVE, LOGGER_NAME, SERVICE_NAME
 
Constructor Summary
TurbineNonPersistentSchedulerService()
          Constructor.
 
Method Summary
 void addJob(JobEntry je)
          Add a new job to the queue.
 JobEntry getJob(int oid)
          This method returns the job element from the internal queue.
 void init()
          Called the first time the Service is used.
 void init(javax.servlet.ServletConfig config)
          Deprecated. use init() instead.
 void removeJob(JobEntry je)
          Remove a job from the queue.
 void updateJob(JobEntry je)
          Add/update a job
 
Methods inherited from class org.apache.turbine.services.schedule.TurbineSchedulerService
getThread, isEnabled, listJobs, restart, setEnabled, shutdown, startScheduler, stopScheduler
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker
 

Constructor Detail

TurbineNonPersistentSchedulerService

public TurbineNonPersistentSchedulerService()
                                     throws TurbineException
Constructor.

Throws:
TurbineException - a generic exception.
Method Detail

init

public void init()
          throws InitializationException
Called the first time the Service is used.
Load all the jobs from cold storage. Add jobs to the queue (sorted in ascending order by runtime) and start the scheduler thread.

Specified by:
init in interface Initable
Overrides:
init in class TurbineSchedulerService
Throws:
InitializationException - Something went wrong in the init stage

init

public void init(javax.servlet.ServletConfig config)
          throws InitializationException
Deprecated. use init() instead.

Called the first time the Service is used.
Load all the jobs from cold storage. Add jobs to the queue (sorted in ascending order by runtime) and start the scheduler thread.

Overrides:
init in class TurbineSchedulerService
Parameters:
config - A ServletConfig.
Throws:
InitializationException

getJob

public JobEntry getJob(int oid)
                throws TurbineException
This method returns the job element from the internal queue.

Specified by:
getJob in interface ScheduleService
Overrides:
getJob in class TurbineSchedulerService
Parameters:
oid - The int id for the job.
Returns:
A JobEntry.
Throws:
TurbineException - could not retrieve job

addJob

public void addJob(JobEntry je)
            throws TurbineException
Add a new job to the queue.

Specified by:
addJob in interface ScheduleService
Overrides:
addJob in class TurbineSchedulerService
Parameters:
je - A JobEntry with the job to add.
Throws:
TurbineException - job could not be added

removeJob

public void removeJob(JobEntry je)
Remove a job from the queue.

Specified by:
removeJob in interface ScheduleService
Overrides:
removeJob in class TurbineSchedulerService
Parameters:
je - A JobEntry with the job to remove.

updateJob

public void updateJob(JobEntry je)
               throws TurbineException
Add/update a job

Specified by:
updateJob in interface ScheduleService
Overrides:
updateJob in class TurbineSchedulerService
Parameters:
je - A JobEntry with the job to modify
Throws:
TurbineException - job could not be updated


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.