Save This Page
Home » JBoss-5.1.0 » org.jboss.varia » scheduler » [javadoc | source]
org.jboss.varia.scheduler
public class: Scheduler [javadoc | source]
java.lang.Object
   org.jboss.mx.util.JBossNotificationBroadcasterSupport
      org.jboss.system.ServiceMBeanSupport
         org.jboss.varia.scheduler.Scheduler

All Implemented Interfaces:
    SchedulerMBean, KernelControllerContextAware, ServiceMBean, MBeanRegistration, NotificationEmitter

Schedules a timer task that calls an MBean or Object instance. Any MBean operation can be called. Object instances must implement the Schedulable interface.

Create a separate Scheduler MBean for every MBean or Object you wish to call. One example naming strategy for calling an MBean named: 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:
abstract public class  Scheduler.BaseListener  Base class for listeners. 
public class  Scheduler.PojoScheduler  Calls {@link Schedulable#perform} on a plain Java Object. 
public class  Scheduler.MBeanListener  Invokes an operation on an MBean. 
Field Summary
public static  String JNDI_NAME     
public static  String JMX_NAME     
public static  String DEFAULT_TIMER_NAME     
Fields inherited from org.jboss.system.ServiceMBeanSupport:
SERVICE_CONTROLLER_SIG,  log,  server,  serviceName
Constructor:
 public Scheduler() 
 public Scheduler(String pSchedulableClass,
    long pSchedulePeriod) 
    Constructs a new Scheduler instance.
    Parameters:
    pSchedulableClass -
    pSchedulePeriod -
 public Scheduler(String pSchedulableClass,
    String pInitArguments,
    String pInitTypes,
    String pInitialStartDate,
    long pSchedulePeriod,
    long pNumberOfRepetitions) 
    Constructs a new Scheduler instance.
    Parameters:
    pSchedulableClass -
    pInitArguments -
    pInitTypes -
    pInitialStartDate -
    pSchedulePeriod -
    pNumberOfRepetitions -
 public Scheduler(String pSchedulableClass,
    String pInitArguments,
    String pInitTypes,
    String pDateFormat,
    String pInitialStartDate,
    long pSchedulePeriod,
    long pNumberOfRepetitions) 
    Constructs a new Scheduler instance.
    Parameters:
    pSchedulableClass -
    pInitArguments -
    pInitTypes -
    pDateFormat -
    pInitialStartDate -
    pSchedulePeriod -
    pNumberOfRepetitions -
Method from org.jboss.varia.scheduler.Scheduler Summary:
getDateFormat,   getFixedRate,   getInitialRepetitions,   getInitialStartDate,   getRemainingRepetitions,   getSchedulableArgumentTypes,   getSchedulableArguments,   getSchedulableClass,   getSchedulableMBean,   getSchedulableMBeanMethod,   getSchedulePeriod,   getTimerName,   isActive,   isRestartPending,   isStartAtStartup,   isStarted,   isUsingMBean,   restartSchedule,   setDateFormat,   setFixedRate,   setInitialRepetitions,   setInitialStartDate,   setSchedulableArgumentTypes,   setSchedulableArguments,   setSchedulableClass,   setSchedulableMBean,   setSchedulableMBeanMethod,   setSchedulePeriod,   setStartAtStartup,   setTimerName,   startSchedule,   startService,   stopSchedule,   stopSchedule,   stopService
Methods from org.jboss.system.ServiceMBeanSupport:
create,   createService,   destroy,   destroyService,   getDeploymentInfo,   getLog,   getName,   getNextNotificationSequenceNumber,   getObjectName,   getServer,   getServiceName,   getState,   getStateString,   jbossInternalCreate,   jbossInternalDescription,   jbossInternalDestroy,   jbossInternalLifecycle,   jbossInternalStart,   jbossInternalStop,   pojoChange,   pojoCreate,   pojoDestroy,   pojoStart,   pojoStop,   postDeregister,   postRegister,   preDeregister,   preRegister,   setKernelControllerContext,   start,   startService,   stop,   stopService,   unsetKernelControllerContext
Methods from org.jboss.mx.util.JBossNotificationBroadcasterSupport:
addNotificationListener,   getNotificationInfo,   handleNotification,   nextNotificationSequenceNumber,   removeNotificationListener,   removeNotificationListener,   sendNotification
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.varia.scheduler.Scheduler Detail:
 public String getDateFormat() 
 public boolean getFixedRate() 
 public long getInitialRepetitions() 
 public String getInitialStartDate() 
 public long getRemainingRepetitions() 
 public String getSchedulableArgumentTypes() 
 public String getSchedulableArguments() 
 public String getSchedulableClass() 
 public String getSchedulableMBean() 
 public String getSchedulableMBeanMethod() 
 public long getSchedulePeriod() 
 public String getTimerName() 
 public boolean isActive() 
 public boolean isRestartPending() 
 public boolean isStartAtStartup() 
 public boolean isStarted() 
 public boolean isUsingMBean() 
 public  void restartSchedule() 
    Stops the server right now and starts it right now.
 public  void setDateFormat(String dateFormat) 
    Sets the date format used to parse date/times
 public  void setFixedRate(boolean fixedRate) 
 public  void setInitialRepetitions(long pNumberOfCalls) 
    Sets the initial number of scheduled calls.
 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.
 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.
 public  void setSchedulableArguments(String pArgumentList) 
 public  void setSchedulableClass(String pSchedulableClass) throws InvalidParameterException 
 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 , #setSchedulableArguments and #setSchedulableArgumentTypes are cleared and not used anymore. Therefore only use either Schedulable Class or Schedulable MBean. If #setSchedulableMBeanMethod is not set then the schedule method as in the Schedulable#perform 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.
 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:
    • 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, 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 ).
 public  void setSchedulePeriod(long pPeriod) 
    Sets the Schedule Period between two scheduled call.
 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.
 public  void setTimerName(String pTimerName) 
 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.
 protected  void startService() throws Exception 
 public  void stopSchedule() 
    Stops the schedule immediately.
 public  void stopSchedule(boolean pDoItNow) 
    Stops the schedule because it is either not used anymore or to restart it with new values.
 protected  void stopService()