[jboss-cvs] contrib/varia/src/main/org/jboss/varia/scheduler ...

Dimitris Andreadis dimitris.andreadis at jboss.com
Thu Jul 13 15:52:10 EDT 2006


  User: dimitris
  Date: 06/07/13 15:52:10

  Modified:    varia/src/main/org/jboss/varia/scheduler     Tag: Branch_4_0
                        ScheduleManager.java ScheduleManagerMBean.java
                        Scheduler.java SchedulerMBean.java
  Log:
  JBAS-3282, add FixedRate attribute.
   The default JMX Timer scheduling behaviour of FixedDelay execution
   (as of JDK5 or JBoss v4.0.5) is overriden in the config using FixedRate true
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.13.6.4  +46 -20    contrib/varia/src/main/org/jboss/varia/scheduler/ScheduleManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ScheduleManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/varia/scheduler/ScheduleManager.java,v
  retrieving revision 1.13.6.3
  retrieving revision 1.13.6.4
  diff -u -b -r1.13.6.3 -r1.13.6.4
  --- ScheduleManager.java	20 Feb 2006 21:49:42 -0000	1.13.6.3
  +++ ScheduleManager.java	13 Jul 2006 19:52:10 -0000	1.13.6.4
  @@ -47,7 +47,8 @@
    * ready.
    *
    * @author <a href="mailto:andreas at jboss.org">Andreas Schaefer</a>
  - * @version $Revision: 1.13.6.3 $
  + * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  + * @version $Revision: 1.13.6.4 $
    */
   public class ScheduleManager extends ServiceMBeanSupport
      implements ScheduleManagerMBean
  @@ -78,9 +79,9 @@
      private String mTimerName = DEFAULT_TIMER_NAME;
      private ObjectName mTimer;
   
  -   private boolean mScheduleIsStarted = false;
      private boolean mWaitForNextCallToStop = false;
      private boolean mStartOnStart = false;
  +   private boolean mFixedRate = false;
      private boolean mIsPaused = false;
   
      /**
  @@ -88,6 +89,7 @@
       * Schedule is stop / started or destroyed
       */
      private ArrayList mProviders = new ArrayList();
  +   
      /** List of added Schedules */
      private Hashtable mSchedules = new Hashtable();
   
  @@ -131,7 +133,6 @@
               }
            }
         }
  -      mScheduleIsStarted = true;
      }
   
      /**
  @@ -163,7 +164,6 @@
               }
            }
         }
  -      mScheduleIsStarted = false;
      }
   
      /**
  @@ -393,15 +393,9 @@
         return getState() == STARTED;
      }
   
  -   /**
  -    * @jmx:managed-attribute
  -    *
  -    * @return true if the scheduler should be started upon MBean start or not
  -    */
  -   public boolean isStartAtStartup()
  -   {
  -      return mStartOnStart;
  -   }
  +   // -------------------------------------------------------------------------
  +   // SchedulerManagerMBean Attributes
  +   // -------------------------------------------------------------------------
   
      /**
       * Set the scheduler to start when MBean started or not. Note that this method only
  @@ -420,11 +414,11 @@
      /**
       * @jmx:managed-attribute
       *
  -    * @return Name of the Timer MBean used in here
  +    * @return true if the scheduler should be started upon MBean start or not
       */
  -   public String getTimerName()
  +   public boolean isStartAtStartup()
      {
  -      return mTimerName;
  +      return mStartOnStart;
      }
   
      /**
  @@ -439,6 +433,36 @@
         mTimerName = pTimerName;
      }
   
  +   /**
  +    * @jmx:managed-attribute
  +    *
  +    * @return Name of the Timer MBean used in here
  +    */
  +   public String getTimerName()
  +   {
  +      return mTimerName;
  +   }
  +
  +   /**
  +    * @jmx:managed-attribute
  +    * 
  +    * @param fixedRate the default scheduling to use, fixed-rate or fixed-delay (false, default)
  +    */
  +   public void setFixedRate(boolean fixedRate)
  +   {
  +      mFixedRate = fixedRate;
  +   }
  +   
  +   /**
  +    * @jmx:managed-attribute
  +    * 
  +    * @return the default scheduling to use
  +    */   
  +   public boolean getFixedRate()
  +   {
  +      return mFixedRate;
  +   }
  +   
      // -------------------------------------------------------------------------
      // ServiceMBeanSupport overrides
      // -------------------------------------------------------------------------
  @@ -650,7 +674,7 @@
      }
   
      /**
  -    * Represents a single Schedule which can be started and stop
  +    * Represents a single Schedule which can be started and stopped
       * if necessary.
       */
      private class ScheduleInstance
  @@ -790,7 +814,8 @@
                       new Integer(getID()), // User Object
                       lStartDate,
                       new Long(mPeriod),
  -                    mRemainingRepetitions < 0 ? new Long(0) : new Long(mRemainingRepetitions)
  +                    mRemainingRepetitions < 0 ? new Long(0) : new Long(mRemainingRepetitions),
  +                    new Boolean(mFixedRate)
                    },
                    new String[]{
                       String.class.getName(),
  @@ -798,7 +823,8 @@
                       Object.class.getName(),
                       Date.class.getName(),
                       Long.TYPE.getName(),
  -                    Long.TYPE.getName()
  +                    Long.TYPE.getName(),
  +                    Boolean.TYPE.getName()
                    }
            )).intValue();
            // Register the notification listener at the MBeanServer
  
  
  
  1.1.4.5   +5 -1      contrib/varia/src/main/org/jboss/varia/scheduler/ScheduleManagerMBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ScheduleManagerMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/varia/scheduler/ScheduleManagerMBean.java,v
  retrieving revision 1.1.4.4
  retrieving revision 1.1.4.5
  diff -u -b -r1.1.4.4 -r1.1.4.5
  --- ScheduleManagerMBean.java	20 Feb 2006 18:30:21 -0000	1.1.4.4
  +++ ScheduleManagerMBean.java	13 Jul 2006 19:52:10 -0000	1.1.4.5
  @@ -33,7 +33,7 @@
    * 
    * @author <a href="mailto:andreas at jboss.org">Andreas Schaefer</a>
    * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  - * @version $Revision: 1.1.4.4 $
  + * @version $Revision: 1.1.4.5 $
    */
   public interface ScheduleManagerMBean extends ServiceMBean
   {
  @@ -50,6 +50,10 @@
      void setTimerName(String timerObjectName);
      String getTimerName();
      
  +   /** The default scheduling to use, fixed-rate or fixed-delay (false, default) */
  +   void setFixedRate(boolean fixedRate);
  +   boolean getFixedRate();
  +   
      // Operations ----------------------------------------------------
      
      /**
  
  
  
  1.12.4.3  +51 -35    contrib/varia/src/main/org/jboss/varia/scheduler/Scheduler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Scheduler.java
  ===================================================================
  RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/varia/scheduler/Scheduler.java,v
  retrieving revision 1.12.4.2
  retrieving revision 1.12.4.3
  diff -u -b -r1.12.4.2 -r1.12.4.3
  --- Scheduler.java	29 Oct 2005 05:06:46 -0000	1.12.4.2
  +++ Scheduler.java	13 Jul 2006 19:52:10 -0000	1.12.4.3
  @@ -1,42 +1,42 @@
   /*
  -* JBoss, Home of Professional Open Source
  -* Copyright 2005, JBoss Inc., and individual contributors as indicated
  -* by the @authors tag. See the copyright.txt in the distribution for a
  -* full listing of individual contributors.
  -*
  -* This is free software; you can redistribute it and/or modify it
  -* under the terms of the GNU Lesser General Public License as
  -* published by the Free Software Foundation; either version 2.1 of
  -* the License, or (at your option) any later version.
  -*
  -* This software is distributed in the hope that it will be useful,
  -* but WITHOUT ANY WARRANTY; without even the implied warranty of
  -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  -* Lesser General Public License for more details.
  -*
  -* You should have received a copy of the GNU Lesser General Public
  -* License along with this software; if not, write to the Free
  -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  -* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -*/
  + * JBoss, Home of Professional Open Source
  + * Copyright 2005, JBoss Inc., and individual contributors as indicated
  + * by the @authors tag. See the copyright.txt in the distribution for a
  + * full listing of individual contributors.
  + *
  + * This is free software; you can redistribute it and/or modify it
  + * under the terms of the GNU Lesser General Public License as
  + * published by the Free Software Foundation; either version 2.1 of
  + * the License, or (at your option) any later version.
  + *
  + * This software is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this software; if not, write to the Free
  + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  + */
   package org.jboss.varia.scheduler;
   
   import java.lang.reflect.Constructor;
  -import java.text.SimpleDateFormat;
   import java.security.InvalidParameterException;
  +import java.text.SimpleDateFormat;
   import java.util.Date;
   import java.util.StringTokenizer;
   import java.util.Vector;
   
   import javax.management.MalformedObjectNameException;
   import javax.management.Notification;
  -import javax.management.timer.TimerNotification;
   import javax.management.NotificationListener;
   import javax.management.ObjectName;
  +import javax.management.timer.TimerNotification;
   
   import org.jboss.logging.Logger;
  -import org.jboss.system.ServiceMBeanSupport;
   import org.jboss.mx.loading.ClassLoaderUtils;
  +import org.jboss.system.ServiceMBeanSupport;
   
   /**
    * Scheduler Instance to allow clients to run this as a scheduling service for
  @@ -48,15 +48,11 @@
    * :service=Scheduler,schedule=<you schedule name><br>
    * This way you should not run into a name conflict.
    *
  - * @jmx:mbean name="jboss:service=Scheduler"
  - *            extends="org.jboss.system.ServiceMBean"
  - *
    * @author <a href="mailto:andreas at jboss.org">Andreas Schaefer</a>
    * @author Cameron (camtabor)
  - * @version $Revision: 1.12.4.2 $
  + * @version $Revision: 1.12.4.3 $
    */
  -public class Scheduler
  -   extends ServiceMBeanSupport
  +public class Scheduler extends ServiceMBeanSupport
      implements SchedulerMBean
   {
   
  @@ -85,7 +81,6 @@
      private String mTimerName = DEFAULT_TIMER_NAME;
      private ObjectName mTimer;
      private Schedulable mSchedulable;
  -//as   private Object mSchedulableMBeanObjectName;
   
      private boolean mScheduleIsStarted = false;
      private boolean mWaitForNextCallToStop = false;
  @@ -113,6 +108,7 @@
      private boolean mStartDateIsNow;
      private long mSchedulePeriod;
      private long mInitialRepetitions;
  +   private boolean mFixedRate = false;
   
      private NotificationListener listener;
   
  @@ -369,9 +365,8 @@
                     null, // User Object
                     lStartDate,
                     new Long(mActualSchedulePeriod),
  -                  mRemainingRepetitions < 0 ?
  -               new Long(0) :
  -               new Long(mRemainingRepetitions)
  +                  mRemainingRepetitions < 0 ? new Long(0) : new Long(mRemainingRepetitions),
  +                  new Boolean(mFixedRate)
                  },
                  new String[]{
                     String.class.getName(),
  @@ -379,7 +374,8 @@
                     Object.class.getName(),
                     Date.class.getName(),
                     Long.TYPE.getName(),
  -                  Long.TYPE.getName()
  +                  Long.TYPE.getName(),
  +                  Boolean.TYPE.getName()
                  }
               )).intValue();
               if (mUseMBean)
  @@ -1128,6 +1124,26 @@
         mTimerName = pTimerName;
      }
   
  +   /**
  +    * @jmx:managed-attribute
  +    * 
  +    * @param fixedRate the default scheduling to use, fixed-rate or fixed-delay (false, default)
  +    */
  +   public void setFixedRate(boolean fixedRate)
  +   {
  +      mFixedRate = fixedRate;
  +   }
  +   
  +   /**
  +    * @jmx:managed-attribute
  +    * 
  +    * @return the default scheduling to use
  +    */   
  +   public boolean getFixedRate()
  +   {
  +      return mFixedRate;
  +   }
  +   
      // -------------------------------------------------------------------------
      // Methods
      // -------------------------------------------------------------------------
  
  
  
  1.3.4.4   +152 -117  contrib/varia/src/main/org/jboss/varia/scheduler/SchedulerMBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SchedulerMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/varia/scheduler/SchedulerMBean.java,v
  retrieving revision 1.3.4.3
  retrieving revision 1.3.4.4
  diff -u -b -r1.3.4.3 -r1.3.4.4
  --- SchedulerMBean.java	29 Oct 2005 05:06:46 -0000	1.3.4.3
  +++ SchedulerMBean.java	13 Jul 2006 19:52:10 -0000	1.3.4.4
  @@ -1,135 +1,170 @@
   /*
  -* JBoss, Home of Professional Open Source
  -* Copyright 2005, JBoss Inc., and individual contributors as indicated
  -* by the @authors tag. See the copyright.txt in the distribution for a
  -* full listing of individual contributors.
  -*
  -* This is free software; you can redistribute it and/or modify it
  -* under the terms of the GNU Lesser General Public License as
  -* published by the Free Software Foundation; either version 2.1 of
  -* the License, or (at your option) any later version.
  -*
  -* This software is distributed in the hope that it will be useful,
  -* but WITHOUT ANY WARRANTY; without even the implied warranty of
  -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  -* Lesser General Public License for more details.
  -*
  -* You should have received a copy of the GNU Lesser General Public
  -* License along with this software; if not, write to the Free
  -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  -* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -*/
  + * JBoss, Home of Professional Open Source
  + * Copyright 2005, JBoss Inc., and individual contributors as indicated
  + * by the @authors tag. See the copyright.txt in the distribution for a
  + * full listing of individual contributors.
  + *
  + * This is free software; you can redistribute it and/or modify it
  + * under the terms of the GNU Lesser General Public License as
  + * published by the Free Software Foundation; either version 2.1 of
  + * the License, or (at your option) any later version.
  + *
  + * This software is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this software; if not, write to the Free
  + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  + */
   package org.jboss.varia.scheduler;
   
  -/**
  - * MBean interface.
  - */
  -public interface SchedulerMBean extends org.jboss.system.ServiceMBean
  -{
  +import java.security.InvalidParameterException;
   
  -   //default object name
  -   public static final javax.management.ObjectName OBJECT_NAME = org.jboss.mx.util.ObjectNameFactory
  -         .create("jboss:service=Scheduler");
  +import javax.management.ObjectName;
   
  -   /**
  -    * 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).    */
  -   void startSchedule();
  +import org.jboss.mx.util.ObjectNameFactory;
  +import org.jboss.system.ServiceMBean;
   
  -   /**
  -    * Stops the schedule because it is either not used anymore or to restart it with new values.
  -    * @param 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.    */
  -   void stopSchedule(boolean pDoItNow);
  -
  -   /**
  -    * Stops the server right now and starts it right now.
  +/**
  + * ScheduleMBean interface.
  + * 
  + * @author <a href="mailto:andreas at jboss.org">Andreas Schaefer</a>
  + * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  + * @version $Revision: 1.3.4.4 $
       */
  -   void restartSchedule();
  -
  -   java.lang.String getSchedulableClass();
  -
  -   /**
  -    * 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 {@link #setSchedulableArguments} and {@link #setSchedulableArgumentTypes}.
  -    * @param 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.    */
  -   void setSchedulableClass(java.lang.String pSchedulableClass) throws java.security.InvalidParameterException;
  -
  -   java.lang.String getSchedulableArguments();
  -
  -   void setSchedulableArguments(java.lang.String pArgumentList);
  -
  -   java.lang.String getSchedulableArgumentTypes();
  -
  -   /**
  -    * 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.
  -    * @param 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.    */
  -   void setSchedulableArgumentTypes(java.lang.String pTypeList) throws java.security.InvalidParameterException;
  -
  -   java.lang.String getSchedulableMBean();
  +public interface SchedulerMBean extends ServiceMBean
  +{
  +   /** The default ObjectName */
  +   ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss:service=Scheduler");
   
  -   /**
  -    * Sets the fully qualified JMX MBean name of the Schedulable MBean to be called. <b>Attention: </b>if set the all values set by {@link #setSchedulableClass}, {@link #setSchedulableArguments} and {@link #setSchedulableArgumentTypes} are cleared and not used anymore. Therefore only use either Schedulable Class or Schedulable MBean. If {@link #setSchedulableMBeanMethod} is not set then the schedule method as in the {@link 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.
  -    * @param pSchedulableMBean JMX MBean Object Name which should be called.
  -    * @throws InvalidParameterException If the given value is an valid Object Name.    */
  -   void setSchedulableMBean(java.lang.String pSchedulableMBean) throws java.security.InvalidParameterException;
  +   // Attributes ----------------------------------------------------
   
      /**
  -    * 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: <ul> <li>NOTIFICATION which will be replaced by the timers notification instance (javax.management.Notification)</li> <li>DATE which will be replaced by the date of the notification call (java.util.Date)</li> <li>REPETITIONS which will be replaced by the number of remaining repetitions (long)</li> <li>SCHEDULER_NAME which will be replaced by the Object Name of the Scheduler (javax.management.ObjectName)</li> <li>any full qualified Class name which the Scheduler will be set a "null" value for it</li> </ul> <br> 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 sign!
 ature: doSomething( javax.management.Notification, long, java.lang.String ).
  -    * @param 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    */
  -   void setSchedulableMBeanMethod(java.lang.String pSchedulableMBeanMethod)
  -         throws java.security.InvalidParameterException;
  +    * 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).
  +    */
  +   void setInitialStartDate(String startDate);
  +   String getInitialStartDate();
   
  -   boolean isUsingMBean();
  +   /** The date format used to parse date/times - when empty or null the locale is used to parse dates */
  +   void setDateFormat(String dateFormat);
  +   String getDateFormat();
   
  +   /** The Schedule Period between two scheduled call (in msecs) */
  +   void setSchedulePeriod(long period);
      long getSchedulePeriod();
   
  -   /**
  -    * Sets the Schedule Period between two scheduled call.
  -    * @param 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    */
  -   void setSchedulePeriod(long pPeriod);
  +   /** The number of scheduled calls */
  +   void setInitialRepetitions(long numberOfCalls);
  +   long getInitialRepetitions();
   
  -   java.lang.String getDateFormat();
  +   /** The fully qualified Class name of the Schedulable Class being called by the Scheduler. */
  +   void setSchedulableClass(String schedulableClass) throws java.security.InvalidParameterException;
  +   String getSchedulableClass(); 
  +   
  +   /** The arguments to pass to the schedule */
  +   void setSchedulableArguments(String argumentList);
  +   String getSchedulableArguments();   
  +   
  +   /**
  +    * 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.
  +    */
  +   void setSchedulableArgumentTypes(String typeList) throws java.security.InvalidParameterException;
  +   String getSchedulableArgumentTypes();
   
  -   /**
  -    * Sets the date format used to parse date/times
  -    * @param dateFormat The date format when empty or null the locale is used to parse dates    */
  -   void setDateFormat(java.lang.String dateFormat);
  +   /** The fully qualified JMX MBean name of the Schedulable MBean to be called.
  +    * Attention: if set the values set by {@link #setSchedulableClass},
  +    * {@link #setSchedulableArguments} and {@link #setSchedulableArgumentTypes}
  +    * are cleared and not used anymore. Therefore only use either Schedulable Class
  +    * or Schedulable MBean. If {@link #setSchedulableMBeanMethod} is not set then
  +    * the schedule method as in the {@link 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. */
  +   void setSchedulableMBean(String schedulableMBean) throws java.security.InvalidParameterException;
  +   String getSchedulableMBean();
  +   
  +   /**
  +    * 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 ).
  +    */
  +   void setSchedulableMBeanMethod(String schedulableMBeanMethod) throws java.security.InvalidParameterException;
  +   String getSchedulableMBeanMethod();
   
  -   java.lang.String getInitialStartDate();
  +   /** The default scheduling to use, fixed-rate or fixed-delay (false, default) */
  +   void setFixedRate(boolean fixedRate);
  +   boolean getFixedRate();
   
  -   /**
  -    * Sets the first scheduled call. If the date is in the past the scheduler tries to find the next available start date.
  -    * @param pStartDate Date when the initial call is scheduled. It can be either: <ul> <li> NOW: date will be the current date (new Date()) plus 1 seconds </li><li> Date as String able to be parsed by SimpleDateFormat with default format </li><li> Date as String parsed using the date format attribute </li><li> Milliseconds since 1/1/1970 </li> </ul> 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.<br> 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).    */
  -   void setInitialStartDate(java.lang.String pStartDate);
  +   /** Start the scheduler when the MBean started or not. */
  +   void setStartAtStartup(boolean startAtStartup);
  +   boolean isStartAtStartup();
   
  -   long getInitialRepetitions();
  +   /** The JMX Timer to use (or create if not there) */
  +   void setTimerName(String timerName);    
  +   String getTimerName();
   
  -   /**
  -    * Sets the initial number of scheduled calls.
  -    * @param 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    */
  -   void setInitialRepetitions(long pNumberOfCalls);
  +   // Informative Attributes ----------------------------------------
   
      long getRemainingRepetitions();
  -
  +   boolean isActive();   
      boolean isStarted();
  -
      boolean isRestartPending();
  +   boolean isUsingMBean();
   
  -   boolean isStartAtStartup();
  +   // Operations ----------------------------------------------------
   
      /**
  -    * Set the scheduler to start when MBean started or not. Note that this method only affects when the {@link #startService startService()} gets called (normally at startup time.
  -    * @param pStartAtStartup True if Schedule has to be started at startup time    */
  -   void setStartAtStartup(boolean pStartAtStartup);
  -
  -   boolean isActive();
  -
  -   java.lang.String getTimerName();
  +    * 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).
  +    */
  +   void startSchedule();
   
  -   void setTimerName(java.lang.String pTimerName);
  +   /**
  +    * Stops the schedule because it is either not used anymore or to restart it with new values.
  +    * @param 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.
  +    */
  +   void stopSchedule(boolean doItNow);
   
  +   /**
  +    * Stops the server right now and starts it right now.
  +    */
  +   void restartSchedule();
   }
  
  
  



More information about the jboss-cvs-commits mailing list