org.figure8.join.services.scheduling
Class DefaultQuartzCronManager

java.lang.Object
  extended by org.figure8.join.services.scheduling.DefaultQuartzCronManager
All Implemented Interfaces:
QuartzCronManager

public class DefaultQuartzCronManager
extends java.lang.Object
implements QuartzCronManager

Default QuartzCronInfo instance manager.

Version:
$Revision: 1.3 $
Author:
Jerome Evrard

Field Summary
 
Fields inherited from interface org.figure8.join.services.scheduling.QuartzCronManager
JOB_ENTITY
 
Constructor Summary
DefaultQuartzCronManager()
          Create a new instance of DefaultQuartzCronManager.
 
Method Summary
protected  org.quartz.Trigger createTriggerFrom(QuartzCronInfo info)
          Build an activation trigger from the Quartc Cron information bean
 QuartzCronInfo getQuartzCron(java.lang.String name)
          Retrieve a QuartzCronInfo instance using its name.
 java.util.List getQuartzCronInfos()
          Retrieve all QuartzCronInfo instances.
protected  void initializeScheduler()
          Initialize the Quartz scheduler.
 void removeQuartzCronInfo(QuartzCronInfo info)
          Remove a Quartz Cron infos from datastore.
 void saveQuartzCronInfo(QuartzCronInfo info)
          Save a QuartzCronInfo within datastore.
protected  void scheduleJob(QuartzCronInfo info)
           
 void scheduleJobs()
          Start scheduling of all the already saved Quartz jobs.
 void setCronInfoDao(QuartzCronInfoDao quartzCronInfoDao)
           
protected  void unscheduleJob(QuartzCronInfo info)
           
 void unscheduleJobs()
          Stop the scheduling of all the registered Quartz jobs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultQuartzCronManager

public DefaultQuartzCronManager()
Create a new instance of DefaultQuartzCronManager.

Method Detail

setCronInfoDao

public void setCronInfoDao(QuartzCronInfoDao quartzCronInfoDao)
Parameters:
quartzCronInfoDao - The quartzCronInfoDaooDao to use.

saveQuartzCronInfo

public void saveQuartzCronInfo(QuartzCronInfo info)
                        throws DuplicateEntityException,
                               InfrastructureException
Save a QuartzCronInfo within datastore. This method is also responsible of cron activation/deactivation if necessary (depends on its status).

Specified by:
saveQuartzCronInfo in interface QuartzCronManager
Parameters:
info - The QuartzCronInfo instance to save.
Throws:
DuplicateEntityException - if another consumer with same name already exists.
InfrastructureException - if wrapped Quartz scheduler cannot schedule the job

removeQuartzCronInfo

public void removeQuartzCronInfo(QuartzCronInfo info)
Remove a Quartz Cron infos from datastore. This method should also stop existing scheduled instances before removing the related informations.

Specified by:
removeQuartzCronInfo in interface QuartzCronManager
Parameters:
info - The info on a Quartz cron to remove

getQuartzCron

public QuartzCronInfo getQuartzCron(java.lang.String name)
Retrieve a QuartzCronInfo instance using its name.

Specified by:
getQuartzCron in interface QuartzCronManager
Parameters:
name - The QuartzCronInfo name to retrieve.
Returns:
The QuartzCronInfo instance found or null if not exists.

getQuartzCronInfos

public java.util.List getQuartzCronInfos()
Retrieve all QuartzCronInfo instances.

Specified by:
getQuartzCronInfos in interface QuartzCronManager
Returns:
The list of QuartzCronInfo in data source.

scheduleJobs

public void scheduleJobs()
                  throws InfrastructureException
Start scheduling of all the already saved Quartz jobs. This method should be called on startup.

Specified by:
scheduleJobs in interface QuartzCronManager
Throws:
InfrastructureException - Throwed if exception occures on scheduling or starting Jobs.

unscheduleJobs

public void unscheduleJobs()
Stop the scheduling of all the registered Quartz jobs. This method should be clled on shutdown.

Specified by:
unscheduleJobs in interface QuartzCronManager

initializeScheduler

protected void initializeScheduler()
                            throws InfrastructureException
Initialize the Quartz scheduler.

Throws:
InfrastructureException

scheduleJob

protected void scheduleJob(QuartzCronInfo info)
                    throws InfrastructureException
Parameters:
info - The bean wrapping information on Quartz job to schedule
Throws:
InfrastructureException - if the wrapped Quartz Scheduler cannot schedule job

unscheduleJob

protected void unscheduleJob(QuartzCronInfo info)
                      throws InfrastructureException
Parameters:
info - The bean wrapping information on Quartz job to unschedule
Throws:
InfrastructureException - if the wrapped Quartz Scheduler cannot unschedule job

createTriggerFrom

protected org.quartz.Trigger createTriggerFrom(QuartzCronInfo info)
                                        throws InfrastructureException
Build an activation trigger from the Quartc Cron information bean

Parameters:
info - The info on Quartz cron to build trigger for.
Returns:
The newly created trigger instance.
Throws:
InfrastructureException - if the cron expression within info is not valid


Copyright © 2005-2008 Join. All Rights Reserved.