Class SchedulerService

java.lang.Object
ortus.boxlang.runtime.services.BaseService
ortus.boxlang.runtime.services.SchedulerService
All Implemented Interfaces:
IService

public class SchedulerService extends BaseService
This service manages all schedulers in the system.
  • Constructor Details

    • SchedulerService

      public SchedulerService(BoxRuntime runtime)
      Constructor
      Parameters:
      runtime - The BoxRuntime
  • Method Details

    • onStartup

      public void onStartup()
      The startup event is fired when the runtime starts up
      Specified by:
      onStartup in interface IService
      Specified by:
      onStartup in class BaseService
    • onShutdown

      public void onShutdown(Boolean force)
      The shutdown event is fired when the runtime shuts down
      Specified by:
      onShutdown in interface IService
      Specified by:
      onShutdown in class BaseService
      Parameters:
      force - If true, forces the shutdown of the scheduler
    • startupSchedulers

      public SchedulerService startupSchedulers()
      Startup all the registered schedulers This is called by the runtime when it starts up
    • getSchedulers

      public Map<Key,IScheduler> getSchedulers()
      Get all schedulers
      Returns:
      The schedulers
    • getScheduler

      public IScheduler getScheduler(Key name)
      Get a scheduler by name
      Parameters:
      name - The name of the scheduler
      Returns:
      The scheduler or null if not found
    • size

      public int size()
      How many schedulers do we have registered
      Returns:
      The number of schedulers
    • hasScheduler

      public boolean hasScheduler(Key name)
      Do we have a scheduler by this name?
      Parameters:
      name - The name of the scheduler
    • registerScheduler

      public IScheduler registerScheduler(IScheduler scheduler)
      Register a scheduler with the service
      Parameters:
      scheduler - The IScheduler to register
      Returns:
      The scheduler
      Throws:
      BoxRuntimeException - If a scheduler with the same name already exists
    • registerScheduler

      public IScheduler registerScheduler(IScheduler scheduler, Boolean force)
      Register a scheduler with the service
      Parameters:
      scheduler - The IScheduler to register
      force - If true, forces the registration of the scheduler
      Returns:
      The scheduler
      Throws:
      BoxRuntimeException - If a scheduler with the same name already exists
    • loadScheduler

      public IScheduler loadScheduler(Key name, IScheduler scheduler)
      This method is used to load a scheduler into the service. If the scheduler already exists, it will be replaced. This is usually used from the ModuleService to load a module scheduler
      Parameters:
      name - The name of the scheduler
      scheduler - The IScheduler to load
      Returns:
    • removeScheduler

      public boolean removeScheduler(Key name, boolean force, long timeout)
      Remove a scheduler from the service. This will also shutdown the scheduler.
      Parameters:
      name - The name of the scheduler
      force - If true, forces the shutdown of the scheduler
      timeout - The timeout in milliseconds to wait for the scheduler to shutdown
      Returns:
      True if the scheduler was removed, false if it was not found
    • removeScheduler

      public boolean removeScheduler(Key name)
      Remove a scheduler from the service. This will also shutdown the scheduler gracefully
      Parameters:
      name - The name of the scheduler
      Returns:
      True if the scheduler was removed, false if it was not found
    • clearSchedulers

      public void clearSchedulers(Boolean force, Long timeout)
      Clear all schedulers from the service. This will also shutdown all the schedulers
      Parameters:
      force - If true, forces the shutdown of the scheduler
      timeout - The timeout in milliseconds to wait for the scheduler to shutdown
    • restartScheduler

      public boolean restartScheduler(Key name, boolean force, long timeout)
      Restart the scheduler if it exists
      Parameters:
      name - The name of the scheduler
      force - If true, forces the shutdown of the scheduler
      timeout - The timeout in milliseconds to wait for the scheduler to shutdown
    • restartScheduler

      public boolean restartScheduler(Key name)
      Restart the scheduler if it exists. Not forced
      Parameters:
      name - The name of the scheduler