org.jboss.varia.scheduler
Interface SchedulerMBean

All Superinterfaces:
Service, ServiceMBean
All Known Implementing Classes:
Scheduler

public interface SchedulerMBean
extends ServiceMBean

ScheduleMBean interface.

Version:
$Revision: 81038 $
Author:
Andreas Schaefer, Dimitris Andreadis

Field Summary
static ObjectName OBJECT_NAME
          The default ObjectName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Method Summary
 String getDateFormat()
           
 boolean getFixedRate()
           
 long getInitialRepetitions()
           
 String getInitialStartDate()
           
 long getRemainingRepetitions()
           
 String getSchedulableArguments()
           
 String getSchedulableArgumentTypes()
           
 String getSchedulableClass()
           
 String getSchedulableMBean()
           
 String getSchedulableMBeanMethod()
           
 long getSchedulePeriod()
           
 String getTimerName()
           
 boolean isActive()
           
 boolean isRestartPending()
           
 boolean isStartAtStartup()
           
 boolean isStarted()
           
 boolean isUsingMBean()
           
 void restartSchedule()
          Stops the server right now and starts it right now.
 void setDateFormat(String dateFormat)
          The date format used to parse date/times - when empty or null the locale is used to parse dates
 void setFixedRate(boolean fixedRate)
          The default scheduling to use, fixed-rate or fixed-delay (false, default)
 void setInitialRepetitions(long numberOfCalls)
          The number of scheduled calls
 void setInitialStartDate(String startDate)
          The first scheduled call - NOW: date will be the current date (new Date()) plus 1 seconds - Date as String able to be parsed by SimpleDateFormat with default format - Date as String parsed using the date format attribute - Milliseconds since 1/1/1970 If the date is in the past the Scheduler will search a start date in the future with respect to the initial repetitions and the period between calls.
 void setSchedulableArguments(String argumentList)
          The arguments to pass to the schedule
 void setSchedulableArgumentTypes(String typeList)
          The comma seperated list of argument types for the Schedulable class.
 void setSchedulableClass(String schedulableClass)
          The fully qualified Class name of the Schedulable Class being called by the Scheduler.
 void setSchedulableMBean(String schedulableMBean)
          The fully qualified JMX MBean name of the Schedulable MBean to be called.
 void setSchedulableMBeanMethod(String schedulableMBeanMethod)
          The method name to be called on the Schedulable MBean.
 void setSchedulePeriod(long period)
          The Schedule Period between two scheduled call (in msecs)
 void setStartAtStartup(boolean startAtStartup)
          Start the scheduler when the MBean started or not.
 void setTimerName(String timerName)
          The JMX Timer to use (or create if not there)
 void startSchedule()
          Starts the schedule if the schedule is stopped otherwise nothing will happen.
 void stopSchedule()
          Stops the schedule immediately.
 void stopSchedule(boolean doItNow)
          Stops the schedule because it is either not used anymore or to restart it with new values.
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

OBJECT_NAME

static final ObjectName OBJECT_NAME
The default ObjectName

Method Detail

setInitialStartDate

void setInitialStartDate(String startDate)
The first scheduled call - NOW: date will be the current date (new Date()) plus 1 seconds - Date as String able to be parsed by SimpleDateFormat with default format - Date as String parsed using the date format attribute - Milliseconds since 1/1/1970 If the date is in the past the Scheduler will search a start date in the future with respect to the initial repetitions and the period between calls. This means that when you restart the MBean (restarting JBoss etc.) it will start at the next scheduled time. When no start date is available in the future the Scheduler will not start. Example: if you start your Schedulable everyday at Noon and you restart your JBoss server then it will start at the next Noon (the same if started before Noon or the next day if start after Noon).


getInitialStartDate

String getInitialStartDate()

setDateFormat

void setDateFormat(String dateFormat)
The date format used to parse date/times - when empty or null the locale is used to parse dates


getDateFormat

String getDateFormat()

setSchedulePeriod

void setSchedulePeriod(long period)
The Schedule Period between two scheduled call (in msecs)


getSchedulePeriod

long getSchedulePeriod()

setInitialRepetitions

void setInitialRepetitions(long numberOfCalls)
The number of scheduled calls


getInitialRepetitions

long getInitialRepetitions()

setSchedulableClass

void setSchedulableClass(String schedulableClass)
                         throws InvalidParameterException
The fully qualified Class name of the Schedulable Class being called by the Scheduler.

Throws:
InvalidParameterException

getSchedulableClass

String getSchedulableClass()

setSchedulableArguments

void setSchedulableArguments(String argumentList)
The arguments to pass to the schedule


getSchedulableArguments

String getSchedulableArguments()

setSchedulableArgumentTypes

void setSchedulableArgumentTypes(String typeList)
                                 throws InvalidParameterException
The comma seperated list of argument types for the Schedulable class. This will be used to find the right constructor and to created the right instances to call the constructor with. This list must have as many elements as the Schedulable Arguments list otherwise the start of the Scheduler will fail. Right now only basic data types, String and Classes with a Constructor with a String as only argument are supported. If the list is null or empty then the no-args constructor is used.

Throws:
InvalidParameterException

getSchedulableArgumentTypes

String getSchedulableArgumentTypes()

setSchedulableMBean

void setSchedulableMBean(String schedulableMBean)
                         throws InvalidParameterException
The fully qualified JMX MBean name of the Schedulable MBean to be called. Attention: if set the values set by setSchedulableClass(java.lang.String), setSchedulableArguments(java.lang.String) and setSchedulableArgumentTypes(java.lang.String) are cleared and not used anymore. Therefore only use either Schedulable Class or Schedulable MBean. If setSchedulableMBeanMethod(java.lang.String) is not set then the schedule method as in the Schedulable.perform(java.util.Date, long) will be called with the same arguments. Also note that the Object Name will not be checked if the MBean is available. If the MBean is not available it will not be called but the remaining repetitions will be decreased.

Throws:
InvalidParameterException

getSchedulableMBean

String getSchedulableMBean()

setSchedulableMBeanMethod

void setSchedulableMBeanMethod(String schedulableMBeanMethod)
                               throws InvalidParameterException
The method name to be called on the Schedulable MBean. It can optionally be followed by an opening bracket, list of attributes (see below) and a closing bracket. The list of attributes can contain: - NOTIFICATION which will be replaced by the timers notification instance (javax.management.Notification) - DATE which will be replaced by the date of the notification call (java.util.Date) - REPETITIONS which will be replaced by the number of remaining repetitions (long) - SCHEDULER_NAME which will be replaced by the Object Name of the Scheduler (javax.management.ObjectName) - any full qualified Class name which the Scheduler will be set a "null" value for it An example could be: "doSomething( NOTIFICATION, REPETITIONS, String )" where the Scheduler will pass the timer's notification instance, the remaining repetitions as int and a null to the MBean's doSomething() method which must have the following signature: doSomething( javax.management.Notification, long, String ).

Throws:
InvalidParameterException

getSchedulableMBeanMethod

String getSchedulableMBeanMethod()

setFixedRate

void setFixedRate(boolean fixedRate)
The default scheduling to use, fixed-rate or fixed-delay (false, default)


getFixedRate

boolean getFixedRate()

setStartAtStartup

void setStartAtStartup(boolean startAtStartup)
Start the scheduler when the MBean started or not.


isStartAtStartup

boolean isStartAtStartup()

setTimerName

void setTimerName(String timerName)
The JMX Timer to use (or create if not there)


getTimerName

String getTimerName()

getRemainingRepetitions

long getRemainingRepetitions()

isActive

boolean isActive()

isStarted

boolean isStarted()

isRestartPending

boolean isRestartPending()

isUsingMBean

boolean isUsingMBean()

startSchedule

void startSchedule()
Starts the schedule if the schedule is stopped otherwise nothing will happen. The Schedule is immediately set to started even the first call is in the future.

Throws:
InvalidParameterException - If any of the necessary values are not set or invalid (especially for the Schedulable class attributes).

stopSchedule

void stopSchedule(boolean doItNow)
Stops the schedule because it is either not used anymore or to restart it with new values.

Parameters:
doItNow - If true the schedule will be stopped without waiting for the next scheduled call otherwise the next call will be performed before the schedule is stopped.

stopSchedule

void stopSchedule()
Stops the schedule immediately.


restartSchedule

void restartSchedule()
Stops the server right now and starts it right now.



Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.