TorqueBox 3.1.2

org.torquebox.jobs
Class JobSchedulizer

java.lang.Object
  extended by org.projectodd.polyglot.core.AtRuntimeInstaller<JobSchedulizer>
      extended by org.torquebox.jobs.JobSchedulizer
All Implemented Interfaces:
org.jboss.msc.service.Service<JobSchedulizer>, org.jboss.msc.value.Value<JobSchedulizer>, org.projectodd.polyglot.core.StartState

public class JobSchedulizer
extends org.projectodd.polyglot.core.AtRuntimeInstaller<JobSchedulizer>

Service to manage scheduled and 'at' jobs at runtime.

Author:
Marek Goldmann

Nested Class Summary
 
Nested classes/interfaces inherited from class org.projectodd.polyglot.core.AtRuntimeInstaller
org.projectodd.polyglot.core.AtRuntimeInstaller.RemovalListener
 
Field Summary
 
Fields inherited from class org.projectodd.polyglot.core.AtRuntimeInstaller
HA_SINGLETON_SERVICE_SUFFIX
 
Fields inherited from interface org.jboss.msc.service.Service
NULL, NULL_VALUE
 
Constructor Summary
JobSchedulizer(org.jboss.as.server.deployment.DeploymentUnit unit)
           
 
Method Summary
 CountDownLatch createAtJob(String rubyClassName, Date startAt, Date endAt, long interval, int repeat, String timeout, String name, String description, Map<String,Object> config, boolean singleton)
          Creates new 'at' job.
 CountDownLatch createAtJob(String rubyClassName, Date startAt, Date endAt, long interval, int repeat, org.projectodd.polyglot.core.util.TimeInterval timeout, String name, String description, Map<String,Object> config, boolean singleton)
          Creates new 'at' job.
 CountDownLatch createJob(String rubyClassName, String cronExpression, String timeout, String name, String description, Map<String,Object> config, boolean singleton, boolean stopped)
          Creates and deploys a new scheduled job or replace existing.
 CountDownLatch createJob(String rubyClassName, String cronExpression, org.projectodd.polyglot.core.util.TimeInterval timeout, String name, String description, Map<String,Object> config, boolean singleton, boolean stopped)
          Creates and deploys a new scheduled job or replace existing.
 CountDownLatch removeJob(String name)
          Removes the scheduled job by its name.
 void start(org.jboss.msc.service.StartContext context)
          When the JobSchedulizer service is starting it deploys all the scheduled jobs defined in deployment descriptors for the current deployment unit.
 
Methods inherited from class org.projectodd.polyglot.core.AtRuntimeInstaller
build, build, deploy, deploy, getCoordinationMap, getCoordinationMapInjector, getGlobalTarget, getName, getTarget, getUnit, getValue, hasStartedAtLeastOnce, inCluster, installMBeanFor, installMBeanFor, isStarted, mbeanName, mbeanServiceName, removeMBeanFor, removeMBeanFor, removeService, removeService, replaceService, replaceService, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobSchedulizer

public JobSchedulizer(org.jboss.as.server.deployment.DeploymentUnit unit)
Method Detail

start

public void start(org.jboss.msc.service.StartContext context)
           throws org.jboss.msc.service.StartException
When the JobSchedulizer service is starting it deploys all the scheduled jobs defined in deployment descriptors for the current deployment unit.

Specified by:
start in interface org.jboss.msc.service.Service<JobSchedulizer>
Overrides:
start in class org.projectodd.polyglot.core.AtRuntimeInstaller<JobSchedulizer>
Parameters:
context - JBoss MSC start context
Throws:
org.jboss.msc.service.StartException
See Also:
StartContext

createJob

public CountDownLatch createJob(String rubyClassName,
                                String cronExpression,
                                String timeout,
                                String name,
                                String description,
                                Map<String,Object> config,
                                boolean singleton,
                                boolean stopped)
Creates and deploys a new scheduled job or replace existing.

If there is a job with the same name, it'll be removed and replaced.

Used by the TorqueBox::ScheduledJob.schedule method.

Parameters:
rubyClassName - The Ruby class name of the job implementation
cronExpression - When the job should be executed, in cron format
timeout - After how much time the job should be interrupted, by default it'll never be interrupted. Accepts a String value, example: '5s'
name - Job name
description - Job description
config - Job configuration that should be injected to the job implementation class constructor
singleton - Should the job be running only on one node in cluster?
Returns:
The latch (CountDownLatch) to wait for the task completion.
See Also:
CountDownLatch, createJob(String, String, org.projectodd.polyglot.core.util.TimeInterval, String, String, java.util.Map, boolean, boolean)

createJob

public CountDownLatch createJob(String rubyClassName,
                                String cronExpression,
                                org.projectodd.polyglot.core.util.TimeInterval timeout,
                                String name,
                                String description,
                                Map<String,Object> config,
                                boolean singleton,
                                boolean stopped)
Creates and deploys a new scheduled job or replace existing.

If there is a job with the same name, it'll be removed and replaced.

Parameters:
rubyClassName - The Ruby class name of the job implementation
cronExpression - When the job should be executed, in cron format
timeout - After how much time the job should be interrupted, by default it'll never be interrupted.
name - Job name
description - Job description
config - Job configuration that should be injected to the job implementation class constructor
singleton - Should the job be running only on one node in cluster?
stopped - Defines if the job should not be started after scheduling
Returns:
The latch (CountDownLatch) to wait for the task completion.
See Also:
CountDownLatch

createAtJob

public CountDownLatch createAtJob(String rubyClassName,
                                  Date startAt,
                                  Date endAt,
                                  long interval,
                                  int repeat,
                                  String timeout,
                                  String name,
                                  String description,
                                  Map<String,Object> config,
                                  boolean singleton)
Creates new 'at' job.

Used by the TorqueBox::ScheduledJob.at method.

Parameters:
rubyClassName - The ruby class name of the job implementation
startAt - The start date of the job
endAt - The end date of the job
interval - Interval between job executions
repeat - How many times the job firing should be repeated (first run is not counted)
timeout - The job execution timeout
name - Name of the job
description - Description of the job
config - The configuration (if any) which should be injected into the job constructor
singleton - If the job should be a singleton
Returns:
The latch (CountDownLatch) to wait for the task completion.
See Also:
CountDownLatch

createAtJob

public CountDownLatch createAtJob(String rubyClassName,
                                  Date startAt,
                                  Date endAt,
                                  long interval,
                                  int repeat,
                                  org.projectodd.polyglot.core.util.TimeInterval timeout,
                                  String name,
                                  String description,
                                  Map<String,Object> config,
                                  boolean singleton)
Creates new 'at' job.

Parameters:
rubyClassName - The ruby class name of the job implementation
startAt - The start date of the job
endAt - The end date of the job
interval - Interval between job executions
repeat - How many times the job firing should be repeated (first run is not counted)
timeout - The job execution timeout
name - Name of the job
description - Description of the job
config - The configuration (if any) which should be injected into the job constructor
singleton - If the job should be a singleton
Returns:
The latch (CountDownLatch) to wait for the task completion.
See Also:
CountDownLatch

removeJob

public CountDownLatch removeJob(String name)
Removes the scheduled job by its name.

This operation is executed asynchronously. To watch when the removal is finished use the CountDownLatch returned by this method.

Parameters:
name - Name of the scheduled job
Returns:
The latch (CountDownLatch) to wait for the task completion.
See Also:
CountDownLatch

TorqueBox 3.1.2

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.