org.jboss.varia.scheduler
Interface SchedulerMBean

All Superinterfaces:
org.jboss.system.Service, org.jboss.system.ServiceMBean
All Known Implementing Classes:
Scheduler

public interface SchedulerMBean
extends org.jboss.system.ServiceMBean

MBean interface.


Field Summary
static javax.management.ObjectName OBJECT_NAME
           
 
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()
           
 long getInitialRepetitions()
           
 String getInitialStartDate()
           
 long getRemainingRepetitions()
           
 String getSchedulableArguments()
           
 String getSchedulableArgumentTypes()
           
 String getSchedulableClass()
           
 String getSchedulableMBean()
           
 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)
          Sets the date format used to parse date/times
 void setInitialRepetitions(long pNumberOfCalls)
          Sets the initial number of scheduled calls.
 void setInitialStartDate(String pStartDate)
          Sets the first scheduled call.
 void setSchedulableArguments(String pArgumentList)
           
 void setSchedulableArgumentTypes(String pTypeList)
          Sets the comma seperated list of argument types for the Schedulable class.
 void setSchedulableClass(String pSchedulableClass)
          Sets the fully qualified Class name of the Schedulable Class being called by the Scheduler.
 void setSchedulableMBean(String pSchedulableMBean)
          Sets the fully qualified JMX MBean name of the Schedulable MBean to be called.
 void setSchedulableMBeanMethod(String pSchedulableMBeanMethod)
          Sets the method name to be called on the Schedulable MBean.
 void setSchedulePeriod(long pPeriod)
          Sets the Schedule Period between two scheduled call.
 void setStartAtStartup(boolean pStartAtStartup)
          Set the scheduler to start when MBean started or not.
 void setTimerName(String pTimerName)
           
 void startSchedule()
          Starts the schedule if the schedule is stopped otherwise nothing will happen.
 void stopSchedule(boolean pDoItNow)
          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

public static final javax.management.ObjectName OBJECT_NAME
Method Detail

startSchedule

public 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

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

Parameters:
pDoItNow - 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.

restartSchedule

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


getSchedulableClass

public String getSchedulableClass()

setSchedulableClass

public void setSchedulableClass(String pSchedulableClass)
                         throws InvalidParameterException
Sets the fully qualified Class name of the Schedulable Class being called by the Scheduler. Must be set before the Schedule is started. Please also set the setSchedulableArguments(java.lang.String) and setSchedulableArgumentTypes(java.lang.String).

Parameters:
pSchedulableClass - Fully Qualified Schedulable Class.
Throws:
InvalidParameterException - If the given value is not a valid class or cannot be loaded by the Scheduler or is not of instance Schedulable.

getSchedulableArguments

public String getSchedulableArguments()

setSchedulableArguments

public void setSchedulableArguments(String pArgumentList)

getSchedulableArgumentTypes

public String getSchedulableArgumentTypes()

setSchedulableArgumentTypes

public void setSchedulableArgumentTypes(String pTypeList)
                                 throws InvalidParameterException
Sets 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.

Parameters:
pTypeList - List of arguments used to create the Schedulable intance. If the list is null or empty then the no-args constructor is used.
Throws:
InvalidParameterException - If the given list contains a unknow datat type.

getSchedulableMBean

public String getSchedulableMBean()

setSchedulableMBean

public void setSchedulableMBean(String pSchedulableMBean)
                         throws InvalidParameterException
Sets the fully qualified JMX MBean name of the Schedulable MBean to be called. Attention: if set the all 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.

Parameters:
pSchedulableMBean - JMX MBean Object Name which should be called.
Throws:
InvalidParameterException - If the given value is an valid Object Name.

setSchedulableMBeanMethod

public void setSchedulableMBeanMethod(String pSchedulableMBeanMethod)
                               throws InvalidParameterException
Sets 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:
An example could be: "doSomething( NOTIFICATION, REPETITIONS, java.lang.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, java.lang.String ).

Parameters:
pSchedulableMBeanMethod - Name of the method to be called optional followed by method arguments (see above).
Throws:
InvalidParameterException - If the given value is not of the right format

isUsingMBean

public boolean isUsingMBean()

getSchedulePeriod

public long getSchedulePeriod()

setSchedulePeriod

public void setSchedulePeriod(long pPeriod)
Sets the Schedule Period between two scheduled call.

Parameters:
pPeriod - Time between to scheduled calls (after the initial call) in Milliseconds. This value must be bigger than 0.
Throws:
InvalidParameterException - If the given value is less or equal than 0

getDateFormat

public String getDateFormat()

setDateFormat

public void setDateFormat(String dateFormat)
Sets the date format used to parse date/times

Parameters:
dateFormat - The date format when empty or null the locale is used to parse dates

getInitialStartDate

public String getInitialStartDate()

setInitialStartDate

public void setInitialStartDate(String pStartDate)
Sets the first scheduled call. If the date is in the past the scheduler tries to find the next available start date.

Parameters:
pStartDate - Date when the initial call is scheduled. It can be either:
  • 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 repe- titions 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).

getInitialRepetitions

public long getInitialRepetitions()

setInitialRepetitions

public void setInitialRepetitions(long pNumberOfCalls)
Sets the initial number of scheduled calls.

Parameters:
pNumberOfCalls - Initial Number of scheduled calls. If -1 then the number is unlimted.
Throws:
InvalidParameterException - If the given value is less or equal than 0

getRemainingRepetitions

public long getRemainingRepetitions()

isStarted

public boolean isStarted()

isRestartPending

public boolean isRestartPending()

isStartAtStartup

public boolean isStartAtStartup()

setStartAtStartup

public void setStartAtStartup(boolean pStartAtStartup)
Set the scheduler to start when MBean started or not. Note that this method only affects when the startService() gets called (normally at startup time.

Parameters:
pStartAtStartup - True if Schedule has to be started at startup time

isActive

public boolean isActive()

getTimerName

public String getTimerName()

setTimerName

public void setTimerName(String pTimerName)


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.