/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.varia.scheduler;

/**
 * MBean interface.
 */
public interface ScheduleManagerMBean extends org.jboss.system.ServiceMBean
{

   //default object name
   public static final javax.management.ObjectName OBJECT_NAME = org.jboss.mx.util.ObjectNameFactory
         .create("jboss:service=ScheduleMBean");

   /**
    * Starts all the containing Schedules
    */
   void startSchedules();

   /**
    * Stops all the sontaining Schedules
    * @param pDoItNow If true all the schedules are stopped immeditaly otherwise it waits until the next notification is sent
    * @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 stopSchedules(boolean pDoItNow);

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

   /**
    * Register a Provider to make him available. In turn this method calls "startProviding()" method on the Provider to indicate that the Provider can start adding Schedules.
    * @param pProviderObjectName Object Name of the Provider
    */
   void registerProvider(java.lang.String pProviderObjectName);

   /**
    * Unregister a Provider which in turn calls "stopProviding()" indicating to the Provider to remove all the Schedules.
    * @param pProviderObjectName Object Name of the Provider
    */
   void unregisterProvider(java.lang.String pProviderObjectName);

   /**
    * Adds a new Schedule to the Scheduler
    * @param pTarget Object Name of the Target MBean
    * @param pMethodName Name of the method to be called
    * @param pMethodSignature List of Attributes of the method to be called where ...
    * @param pStartDate Date when the schedule is started
    * @param pRepetitions Initial Number of repetitions
    * @return Identification of the Schedule used later to remove it if necessary
    */
   int addSchedule(javax.management.ObjectName pProvider, javax.management.ObjectName pTarget,
         java.lang.String pMethodName, java.lang.String[] pMethodSignature, java.util.Date pStartDate, long pPeriod,
         int pRepetitions);

   /**
    * Removes a Schedule so that no notification is sent anymore
    * @param pIdentification Identification returned by {@link #addSchedule addSchedule()} or {@link #getSchedules getSchedules()}.
    */
   void removeSchedule(int pIdentification);

   boolean isStartAtStartup();

   /**
    * 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);

   java.lang.String getTimerName();

   void setTimerName(java.lang.String pTimerName);

}
