|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.mx.util.JBossNotificationBroadcasterSupport
org.jboss.system.ServiceMBeanSupport
org.jboss.varia.scheduler.Scheduler
public class Scheduler
Schedules a timer task that calls an MBean or Object instance.
Any MBean operation can be called. Object instances must implement the
Schedulable
interface.
example:type=HelloWorld
is to create a similarly named:
example:type=Scheduler,call=HelloWorld
MBean.
This way you should not run into a name conflict.
This MBean registers a notification listener with an javax.management.timer.Timer MBean. If the Timer does not exist, this MBean will create it. Each Timer can handle multiple Scheduler instances.
Nested Class Summary | |
---|---|
class |
Scheduler.BaseListener
Base class for listeners. |
class |
Scheduler.MBeanListener
Invokes an operation on an MBean. |
class |
Scheduler.PojoScheduler
Calls Schedulable.perform(java.util.Date, long) on a plain Java Object. |
Field Summary | |
---|---|
static String |
DEFAULT_TIMER_NAME
|
static String |
JMX_NAME
|
static String |
JNDI_NAME
|
Fields inherited from class org.jboss.system.ServiceMBeanSupport |
---|
log, server, SERVICE_CONTROLLER_SIG, serviceName |
Fields inherited from interface org.jboss.varia.scheduler.SchedulerMBean |
---|
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 |
Constructor Summary | |
---|---|
Scheduler()
Constructs a new Scheduler instance. |
|
Scheduler(String pSchedulableClass,
long pSchedulePeriod)
Constructs a new Scheduler instance. |
|
Scheduler(String pSchedulableClass,
String pInitArguments,
String pInitTypes,
String pInitialStartDate,
long pSchedulePeriod,
long pNumberOfRepetitions)
Constructs a new Scheduler instance. |
|
Scheduler(String pSchedulableClass,
String pInitArguments,
String pInitTypes,
String pDateFormat,
String pInitialStartDate,
long pSchedulePeriod,
long pNumberOfRepetitions)
Constructs a new Scheduler instance. |
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)
Sets the date format used to parse date/times |
void |
setFixedRate(boolean fixedRate)
The default scheduling to use, fixed-rate or fixed-delay (false, default) |
void |
setInitialRepetitions(long pNumberOfCalls)
Sets the initial number of scheduled calls. |
void |
setInitialStartDate(String pStartDate)
Sets the first scheduled call. |
void |
setSchedulableArguments(String pArgumentList)
The arguments to pass to the schedule |
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)
The JMX Timer to use (or create if not there) |
void |
startSchedule()
Starts the schedule if the schedule is stopped otherwise nothing will happen. |
protected void |
startService()
|
void |
stopSchedule()
Stops the schedule immediately. |
void |
stopSchedule(boolean pDoItNow)
Stops the schedule because it is either not used anymore or to restart it with new values. |
protected void |
stopService()
|
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport |
---|
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 |
---|
public static String JNDI_NAME
public static String JMX_NAME
public static String DEFAULT_TIMER_NAME
Constructor Detail |
---|
public Scheduler()
public Scheduler(String pSchedulableClass, long pSchedulePeriod)
pSchedulableClass
- pSchedulePeriod
- public Scheduler(String pSchedulableClass, String pInitArguments, String pInitTypes, String pInitialStartDate, long pSchedulePeriod, long pNumberOfRepetitions)
pSchedulableClass
- pInitArguments
- pInitTypes
- pInitialStartDate
- pSchedulePeriod
- pNumberOfRepetitions
- public Scheduler(String pSchedulableClass, String pInitArguments, String pInitTypes, String pDateFormat, String pInitialStartDate, long pSchedulePeriod, long pNumberOfRepetitions)
pSchedulableClass
- pInitArguments
- pInitTypes
- pDateFormat
- pInitialStartDate
- pSchedulePeriod
- pNumberOfRepetitions
- Method Detail |
---|
public void startSchedule()
startSchedule
in interface SchedulerMBean
InvalidParameterException
- If any of the necessary values are not set
or invalid (especially for the Schedulable
class attributes).public void stopSchedule()
stopSchedule
in interface SchedulerMBean
public void stopSchedule(boolean pDoItNow)
stopSchedule
in interface SchedulerMBean
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.public void restartSchedule()
restartSchedule
in interface SchedulerMBean
public String getSchedulableClass()
getSchedulableClass
in interface SchedulerMBean
public void setSchedulableClass(String pSchedulableClass) throws InvalidParameterException
setSchedulableArguments(java.lang.String)
and setSchedulableArgumentTypes(java.lang.String)
.
setSchedulableClass
in interface SchedulerMBean
pSchedulableClass
- Fully Qualified Schedulable Class.
InvalidParameterException
- If the given value is not a valid class or cannot
be loaded by the Scheduler or is not of instance
Schedulable.public String getSchedulableArguments()
getSchedulableArguments
in interface SchedulerMBean
public void setSchedulableArguments(String pArgumentList)
SchedulerMBean
setSchedulableArguments
in interface SchedulerMBean
pArgumentList
- List of arguments used to create the Schedulable intance. If
the list is null or empty then the no-args constructor is used.public String getSchedulableArgumentTypes()
getSchedulableArgumentTypes
in interface SchedulerMBean
public void setSchedulableArgumentTypes(String pTypeList) throws InvalidParameterException
setSchedulableArgumentTypes
in interface SchedulerMBean
pTypeList
- List of arguments used to create the Schedulable intance. If
the list is null or empty then the no-args constructor is used.
InvalidParameterException
- If the given list contains a unknow datat type.public String getSchedulableMBean()
getSchedulableMBean
in interface SchedulerMBean
public void setSchedulableMBean(String pSchedulableMBean) throws InvalidParameterException
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.
setSchedulableMBean
in interface SchedulerMBean
pSchedulableMBean
- JMX MBean Object Name which should be called.
InvalidParameterException
- If the given value is an valid Object Name.public String getSchedulableMBeanMethod()
getSchedulableMBeanMethod
in interface SchedulerMBean
public void setSchedulableMBeanMethod(String pSchedulableMBeanMethod) throws InvalidParameterException
setSchedulableMBeanMethod
in interface SchedulerMBean
pSchedulableMBeanMethod
- Name of the method to be called optional followed
by method arguments (see above).
InvalidParameterException
- If the given value is not of the right
formatpublic boolean isUsingMBean()
isUsingMBean
in interface SchedulerMBean
public long getSchedulePeriod()
getSchedulePeriod
in interface SchedulerMBean
public void setSchedulePeriod(long pPeriod)
setSchedulePeriod
in interface SchedulerMBean
pPeriod
- Time between to scheduled calls (after the initial call) in Milliseconds.
This value must be bigger than 0.
InvalidParameterException
- If the given value is less or equal than 0public String getDateFormat()
getDateFormat
in interface SchedulerMBean
public void setDateFormat(String dateFormat)
setDateFormat
in interface SchedulerMBean
dateFormat
- The date format when empty or null the locale is used to parse datespublic String getInitialStartDate()
getInitialStartDate
in interface SchedulerMBean
setInitialStartDate(java.lang.String)
method.public void setInitialStartDate(String pStartDate)
setInitialStartDate
in interface SchedulerMBean
pStartDate
- Date when the initial call is scheduled. It can be either:
public long getInitialRepetitions()
getInitialRepetitions
in interface SchedulerMBean
public void setInitialRepetitions(long pNumberOfCalls)
setInitialRepetitions
in interface SchedulerMBean
pNumberOfCalls
- Initial Number of scheduled calls. If -1 then the number
is infinite
InvalidParameterException
- If the given value is less or equal than 0public long getRemainingRepetitions()
getRemainingRepetitions
in interface SchedulerMBean
public boolean isStarted()
isStarted
in interface SchedulerMBean
public boolean isRestartPending()
isRestartPending
in interface SchedulerMBean
public boolean isStartAtStartup()
isStartAtStartup
in interface SchedulerMBean
public void setStartAtStartup(boolean pStartAtStartup)
startService()
gets called (normally at
startup time.
setStartAtStartup
in interface SchedulerMBean
pStartAtStartup
- True if Schedule has to be started at startup timepublic boolean isActive()
isActive
in interface SchedulerMBean
public String getTimerName()
getTimerName
in interface SchedulerMBean
public void setTimerName(String pTimerName)
SchedulerMBean
setTimerName
in interface SchedulerMBean
pTimerName
- Object Name of the Timer MBean to
be used. If null or not a valid ObjectName
the default will be usedpublic void setFixedRate(boolean fixedRate)
SchedulerMBean
setFixedRate
in interface SchedulerMBean
fixedRate
- the default scheduling to use, fixed-rate or fixed-delay (false, default)public boolean getFixedRate()
getFixedRate
in interface SchedulerMBean
protected void startService() throws Exception
startService
in class ServiceMBeanSupport
Exception
protected void stopService()
stopService
in class ServiceMBeanSupport
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |