pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.bundle
Class JobletScheduler

java.lang.Object
  extended by org.torweg.pulse.bundle.JobletScheduler

public final class JobletScheduler
extends java.lang.Object

Version:
$Revision: 2028 $
Author:
Christian Schatt

Field Summary
static java.lang.String BUNDLE_NULL_STRING
          The String that is internally used for grouping if a Joblet is scheduled with a Bundle that is null.
 
Method Summary
 void executeOnceNow(Bundle b, java.lang.Class<? extends AbstractJoblet> j)
          The Joblet with the given Class is executed once, for the given Bundle.
static JobletScheduler getInstance()
          Returns the JobletScheduler singleton.
 java.util.Date getNextExecutionTime(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Returns the Date of the next scheduled execution of the Joblet scheduled with the given Bundle, Joblet Class and cron expression String.
 java.util.Date getPreviousExecutionTime(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Returns the Date of the previous scheduled execution of the Joblet scheduled with the given Bundle, Joblet Class and cron expression String.
 java.util.Map<Bundle,java.util.Map<java.lang.Class<? extends AbstractJoblet>,java.util.List<java.lang.String>>> getSchedules()
          Returns a Collection holding all the currently scheduled Joblets.
 java.util.Map<java.lang.Class<? extends AbstractJoblet>,java.util.List<java.lang.String>> getSchedules(Bundle b)
          Returns a Collection holding all the Joblets, that are currently scheduled for the given Bundle.
 java.util.List<java.lang.String> getSchedules(Bundle b, java.lang.Class<? extends AbstractJoblet> j)
          Returns a Collection holding all the cron expressions of the Joblets with the given Class, that are currently scheduled for the given Bundle.
static boolean isPaused()
          Checks whether the JobletScheduler singleton is paused.
 boolean isPaused(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Checks whether the Joblet with the given Class is paused for the given Bundle, with the given cron expression String.
 boolean isScheduled(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Checks whether the Joblet with the given Class is scheduled for the given Bundle, with the given cron expression String.
static boolean isStarted()
          Checks whether the JobletScheduler singleton has already been started.
static void pause()
          Pauses the JobletScheduler singleton.
 void pause(Bundle b)
          Pauses all the Joblets, that are currently scheduled for the given Bundle.
 void pause(Bundle b, java.lang.Class<? extends AbstractJoblet> j)
          Pauses all the Joblets with the given Class, that are currently scheduled for the given Bundle.
 void pause(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Pauses the Joblet with the given Class, that is currently scheduled for the given Bundle, with the given cron expression String.
 void pauseAll()
          Pauses all the currently scheduled Joblets.
static void resume()
          Resumes the JobletScheduler singleton.
 void resume(Bundle b)
          Resumes all the Joblets, that are currently scheduled for the given Bundle.
 void resume(Bundle b, java.lang.Class<? extends AbstractJoblet> j)
          Resumes all the Joblets with the given Class, that are currently scheduled for the given Bundle.
 void resume(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Resumes the Joblet with the given Class, that is currently scheduled for the given Bundle, with the given cron expression String.
 void resumeAll()
          Resumes all the currently scheduled Joblets.
 void schedule(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Schedules the Joblet with the given Class, for the given Bundle, with the given cron expression String.
static void startPaused(org.jdom.Element c)
          Starts and pauses the JobletScheduler singleton.
static void stop()
          Stops the JobletScheduler singleton.
 void unschedule(Bundle b)
          Unschedules all the Joblets, that are currently scheduled for the given Bundle.
 void unschedule(Bundle b, java.lang.Class<? extends AbstractJoblet> j)
          Unschedules all the Joblets with the given Class, that are currently scheduled for the given Bundle.
 void unschedule(Bundle b, java.lang.Class<? extends AbstractJoblet> j, java.lang.String ce)
          Unschedules the Joblet with the given Class, that is currently scheduled for the given Bundle, with the given cron expression String.
 void unscheduleAll()
          Unschedules all the currently scheduled Joblets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUNDLE_NULL_STRING

public static final java.lang.String BUNDLE_NULL_STRING
The String that is internally used for grouping if a Joblet is scheduled with a Bundle that is null.

See Also:
Constant Field Values
Method Detail

startPaused

public static void startPaused(org.jdom.Element c)
                        throws JobletSchedulerException
Starts and pauses the JobletScheduler singleton.

Parameters:
c - a JDOM Element holding the configuration properties of the JobletScheduler.
Throws:
java.lang.IllegalStateException - if the JobletScheduler has already been started
JobletSchedulerException - if a SchedulerException is thrown by the underlying quartz Scheduler.

stop

public static void stop()
Stops the JobletScheduler singleton.

Throws:
java.lang.IllegalStateException - if the JobletScheduler has not yet been started
JobletSchedulerException - if a SchedulerException is thrown by the underlying quartz Scheduler.

pause

public static void pause()
Pauses the JobletScheduler singleton.

Throws:
java.lang.IllegalStateException - if the JobletScheduler has not yet been started
JobletSchedulerException - if a SchedulerException is thrown by the underlying quartz Scheduler.

resume

public static void resume()
Resumes the JobletScheduler singleton.

Throws:
java.lang.IllegalStateException - if the JobletScheduler has not yet been started
JobletSchedulerException - if a SchedulerException is thrown by the underlying quartz Scheduler.

isStarted

public static boolean isStarted()
Checks whether the JobletScheduler singleton has already been started.

Returns:
true if the JobletScheduler has already been started. Otherwise, return false.

isPaused

public static boolean isPaused()
Checks whether the JobletScheduler singleton is paused.

Returns:
true if the JobletScheduler is paused. Otherwise, return false.

getInstance

public static JobletScheduler getInstance()
Returns the JobletScheduler singleton.

Returns:
the JobletScheduler singleton.
Throws:
java.lang.IllegalStateException - if the JobletScheduler has not yet been started.

executeOnceNow

public void executeOnceNow(Bundle b,
                           java.lang.Class<? extends AbstractJoblet> j)
The Joblet with the given Class is executed once, for the given Bundle.

Parameters:
b - the Bundle.
j - the Joblet Class.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

schedule

public void schedule(Bundle b,
                     java.lang.Class<? extends AbstractJoblet> j,
                     java.lang.String ce)
Schedules the Joblet with the given Class, for the given Bundle, with the given cron expression String.

Parameters:
b - the Bundle.
j - the Joblet Class.
ce - the cron expression String.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException, or if a ParseException is thrown when creating the CronTrigger.

isScheduled

public boolean isScheduled(Bundle b,
                           java.lang.Class<? extends AbstractJoblet> j,
                           java.lang.String ce)
Checks whether the Joblet with the given Class is scheduled for the given Bundle, with the given cron expression String.

Parameters:
b - the Bundle.
j - the Joblet Class.
ce - the cron expression String.
Returns:
true if the Joblet with the given Class is scheduled for the given Bundle , with the given cron expression String. Otherwise, return false.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

getSchedules

public java.util.Map<Bundle,java.util.Map<java.lang.Class<? extends AbstractJoblet>,java.util.List<java.lang.String>>> getSchedules()
Returns a Collection holding all the currently scheduled Joblets.

Returns:
a Collection holding all the currently scheduled Joblets.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

getSchedules

public java.util.Map<java.lang.Class<? extends AbstractJoblet>,java.util.List<java.lang.String>> getSchedules(Bundle b)
Returns a Collection holding all the Joblets, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
Returns:
a Collection holding all the Joblets, that are currently scheduled for the given Bundle.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

getSchedules

public java.util.List<java.lang.String> getSchedules(Bundle b,
                                                     java.lang.Class<? extends AbstractJoblet> j)
Returns a Collection holding all the cron expressions of the Joblets with the given Class, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
j - the Joblet Class.
Returns:
a Collection holding all the cron expressions of the Joblets with the given Class, that are currently scheduled for the given Bundle.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

unscheduleAll

public void unscheduleAll()
Unschedules all the currently scheduled Joblets.

Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException, or if a ClassNotFoundException is thrown when instantiating the Joblet(s).

unschedule

public void unschedule(Bundle b)
Unschedules all the Joblets, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException, or if a ClassNotFoundException is thrown when instantiating the Joblet(s).

unschedule

public void unschedule(Bundle b,
                       java.lang.Class<? extends AbstractJoblet> j)
Unschedules all the Joblets with the given Class, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
j - the Joblet Class.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

unschedule

public void unschedule(Bundle b,
                       java.lang.Class<? extends AbstractJoblet> j,
                       java.lang.String ce)
Unschedules the Joblet with the given Class, that is currently scheduled for the given Bundle, with the given cron expression String.

Parameters:
b - the Bundle.
j - the Joblet Class.
ce - the cron expression String.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

pauseAll

public void pauseAll()
Pauses all the currently scheduled Joblets.

Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException, or if a ClassNotFoundException is thrown when instantiating the Joblet(s).

pause

public void pause(Bundle b)
Pauses all the Joblets, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException, or if a ClassNotFoundException is thrown when instantiating the Joblet(s).

pause

public void pause(Bundle b,
                  java.lang.Class<? extends AbstractJoblet> j)
Pauses all the Joblets with the given Class, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
j - the Joblet Class.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

pause

public void pause(Bundle b,
                  java.lang.Class<? extends AbstractJoblet> j,
                  java.lang.String ce)
Pauses the Joblet with the given Class, that is currently scheduled for the given Bundle, with the given cron expression String.

Parameters:
b - the Bundle.
j - the Joblet Class.
ce - the cron expression String.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

isPaused

public boolean isPaused(Bundle b,
                        java.lang.Class<? extends AbstractJoblet> j,
                        java.lang.String ce)
Checks whether the Joblet with the given Class is paused for the given Bundle, with the given cron expression String.

Parameters:
b - the Bundle.
j - the Joblet Class.
ce - the cron expression String.
Returns:
true if the Joblet with the given Class is paused for the given Bundle, with the given cron expression String. Otherwise, return false.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

resumeAll

public void resumeAll()
Resumes all the currently scheduled Joblets.

Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException, or if a ClassNotFoundException is thrown when instantiating the Joblet(s).

resume

public void resume(Bundle b)
Resumes all the Joblets, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException, or if a ClassNotFoundException is thrown when instantiating the Joblet(s).

resume

public void resume(Bundle b,
                   java.lang.Class<? extends AbstractJoblet> j)
Resumes all the Joblets with the given Class, that are currently scheduled for the given Bundle.

Parameters:
b - the Bundle.
j - the Joblet Class.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

resume

public void resume(Bundle b,
                   java.lang.Class<? extends AbstractJoblet> j,
                   java.lang.String ce)
Resumes the Joblet with the given Class, that is currently scheduled for the given Bundle, with the given cron expression String.

Parameters:
b - the Bundle.
j - the Joblet Class.
ce - the cron expression String.
Throws:
JobletSchedulerException - if the underlying quartz Scheduler throws a SchedulerException.

getPreviousExecutionTime

public java.util.Date getPreviousExecutionTime(Bundle b,
                                               java.lang.Class<? extends AbstractJoblet> j,
                                               java.lang.String ce)
                                        throws JobletSchedulerException
Returns the Date of the previous scheduled execution of the Joblet scheduled with the given Bundle, Joblet Class and cron expression String.

Returns null if no Joblet is scheduled with the given arguments or if one is scheduled but has not yet been executed.

Parameters:
b - the Bundle the Joblet is scheduled with
j - the Class of the scheduled Joblet
ce - the cron expression String the Joblet is scheduled with
Returns:
the Date of the previous scheduled execution of the Joblet scheduled with the given arguments or null
Throws:
java.lang.IllegalArgumentException - if the name of the given Bundle is either null or an empty String, if the given Joblet Class is null, or if the given cron expression String is either null or not parsable into a valid CronExpression.
JobletSchedulerException - if a SchedulerException is thrown by the quartz Scheduler

getNextExecutionTime

public java.util.Date getNextExecutionTime(Bundle b,
                                           java.lang.Class<? extends AbstractJoblet> j,
                                           java.lang.String ce)
                                    throws JobletSchedulerException
Returns the Date of the next scheduled execution of the Joblet scheduled with the given Bundle, Joblet Class and cron expression String.

Returns null if no Joblet is scheduled with the given arguments or if one is scheduled but will not be executed again.

Parameters:
b - the Bundle the Joblet is scheduled with
j - the Class of the scheduled Joblet
ce - the cron expression String the Joblet is scheduled with
Returns:
the Date of the next scheduled execution of the Joblet scheduled with the given arguments or null
Throws:
java.lang.IllegalArgumentException - if the name of the given Bundle is either null or an empty String, if the given Joblet Class is null, or if the given cron expression String is either null or not parsable into a valid CronExpression.
JobletSchedulerException - if a SchedulerException is thrown by the quartz Scheduler