|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.commons.scheduler.impl.QuartzScheduler
public class QuartzScheduler
The quartz based implementation of the scheduler.
Field Summary | |
---|---|
protected org.osgi.service.component.ComponentContext |
context
The component context. |
protected static String |
DEFAULT_QUARTZ_JOB_GROUP
|
protected org.slf4j.Logger |
logger
Default log. |
protected static String |
PREFIX
|
protected static String |
QUARTZ_SCHEDULER_NAME
|
protected List<org.apache.sling.commons.scheduler.impl.QuartzScheduler.Registration> |
registeredJobs
List of registrations while this service is not activated yet. |
protected org.quartz.Scheduler |
scheduler
Theq quartz scheduler. |
protected ThreadPool |
threadPool
|
protected ThreadPoolManager |
threadPoolManager
|
Fields inherited from interface org.apache.sling.commons.scheduler.Scheduler |
---|
PROPERTY_SCHEDULER_CONCURRENT, PROPERTY_SCHEDULER_EXPRESSION, PROPERTY_SCHEDULER_NAME, PROPERTY_SCHEDULER_PERIOD |
Constructor Summary | |
---|---|
QuartzScheduler()
|
Method Summary | |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext ctx)
Activate this component. |
void |
addJob(String name,
Object job,
Map<String,Serializable> config,
String schedulingExpression,
boolean canRunConcurrently)
Schedule a time based job. |
void |
addPeriodicJob(String name,
Object job,
Map<String,Serializable> config,
long period,
boolean canRunConcurrently)
Schedule a periodic job. |
protected void |
bindJob(org.osgi.framework.ServiceReference ref)
Bind a new job. |
protected void |
bindTask(org.osgi.framework.ServiceReference ref)
Bind a new task. |
protected void |
checkJob(Object job)
Check the job object, either runnable or job is allowed |
protected org.quartz.JobDetail |
createJobDetail(String name,
org.quartz.JobDataMap jobDataMap)
Create the job detail. |
protected void |
deactivate(org.osgi.service.component.ComponentContext ctx)
Deactivate this component. |
protected void |
dispose(org.quartz.Scheduler s)
Dispose the quartz scheduler |
void |
fireJob(Object job,
Map<String,Serializable> config)
Fire a job immediately and only once. |
boolean |
fireJob(Object job,
Map<String,Serializable> config,
int times,
long period)
Fire a job immediately more than once. |
void |
fireJobAt(String name,
Object job,
Map<String,Serializable> config,
Date date)
Fire a job once at a specific date Note that if a job with the same name has already beed added, the old job is cancelled and this new job replaces the old job. |
boolean |
fireJobAt(String name,
Object job,
Map<String,Serializable> config,
Date date,
int times,
long period)
Fire a job once at a specific date, several times with a given interval. |
protected org.quartz.Scheduler |
init()
Initialize the quartz scheduler |
protected org.quartz.JobDataMap |
initDataMap(String jobName,
Object job,
Map<String,Serializable> config,
boolean concurrent)
Initialize the data map for the job executor. |
void |
removeJob(String name)
Remove a scheduled job by name. |
protected void |
scheduleJob(String name,
Object job,
Map<String,Serializable> config,
org.quartz.Trigger trigger,
boolean canRunConcurrently)
Add a job to the scheduler |
protected void |
unbindJob(org.osgi.framework.ServiceReference ref)
Unbind a job. |
protected void |
unbindTask(org.osgi.framework.ServiceReference ref)
Unbind a task. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.slf4j.Logger logger
protected static final String DEFAULT_QUARTZ_JOB_GROUP
protected static final String PREFIX
protected static final String QUARTZ_SCHEDULER_NAME
protected volatile org.quartz.Scheduler scheduler
protected final List<org.apache.sling.commons.scheduler.impl.QuartzScheduler.Registration> registeredJobs
protected volatile org.osgi.service.component.ComponentContext context
protected ThreadPoolManager threadPoolManager
protected ThreadPool threadPool
Constructor Detail |
---|
public QuartzScheduler()
Method Detail |
---|
protected void activate(org.osgi.service.component.ComponentContext ctx) throws Exception
ctx
- The component context.
Exception
protected void deactivate(org.osgi.service.component.ComponentContext ctx)
ctx
- The component context.protected org.quartz.Scheduler init() throws org.quartz.SchedulerException
org.quartz.SchedulerException
protected void dispose(org.quartz.Scheduler s)
s
- The scheduler.protected void scheduleJob(String name, Object job, Map<String,Serializable> config, org.quartz.Trigger trigger, boolean canRunConcurrently) throws org.quartz.SchedulerException
name
- The name of the job to add (or null)Tje
- jopbtrigger
- a TriggercanRunConcurrently
- whether this job can be run concurrently
org.quartz.SchedulerException
- thrown in case of errorsprotected org.quartz.JobDataMap initDataMap(String jobName, Object job, Map<String,Serializable> config, boolean concurrent)
jobName
- job
- config
- concurent
-
protected org.quartz.JobDetail createJobDetail(String name, org.quartz.JobDataMap jobDataMap)
name
- jobDataMap
-
protected void checkJob(Object job) throws IllegalArgumentException
IllegalArgumentException
public void addJob(String name, Object job, Map<String,Serializable> config, String schedulingExpression, boolean canRunConcurrently) throws org.quartz.SchedulerException
Scheduler
addJob
in interface Scheduler
name
- The name of the job - or null. If no name is specified it can't be cancelled.job
- The job to execute (either Job
or Runnable
).config
- An optional configuration object - this configuration is only passed to the job the job implements Job
.schedulingExpression
- The time specification using a scheduling expression.canRunConcurrently
- Whether this job can run even if previous scheduled runs are still running.
org.quartz.SchedulerException
Scheduler.addJob(java.lang.String, java.lang.Object, java.util.Map, java.lang.String, boolean)
public void addPeriodicJob(String name, Object job, Map<String,Serializable> config, long period, boolean canRunConcurrently) throws org.quartz.SchedulerException
Scheduler
addPeriodicJob
in interface Scheduler
name
- The name of the job - or null. If no name is specified it can't be cancelled.job
- The job to execute (either Job
or Runnable
).config
- An optional configuration object - this configuration is only passed to the job the job implements Job
.period
- Every period seconds this job is started.canRunConcurrently
- Whether this job can run even if previous scheduled runs are still running.
org.quartz.SchedulerException
Scheduler.addPeriodicJob(java.lang.String, java.lang.Object, java.util.Map, long, boolean)
public void fireJob(Object job, Map<String,Serializable> config) throws org.quartz.SchedulerException
Scheduler
fireJob
in interface Scheduler
job
- The job to execute (either Job
or Runnable
).config
- An optional configuration object - this configuration is only passed to the job the job implements Job
.
org.quartz.SchedulerException
Scheduler.fireJob(java.lang.Object, java.util.Map)
public void fireJobAt(String name, Object job, Map<String,Serializable> config, Date date) throws org.quartz.SchedulerException
Scheduler
fireJobAt
in interface Scheduler
name
- The name of the job - or null. If no name is specified it can't be cancelled.job
- The job to execute (either Job
or Runnable
).config
- An optional configuration object - this configuration is only passed to the job the job implements Job
.date
- The date this job should be run.
org.quartz.SchedulerException
Scheduler.fireJobAt(java.lang.String, java.lang.Object, java.util.Map, java.util.Date)
public boolean fireJob(Object job, Map<String,Serializable> config, int times, long period)
Scheduler
fireJob
in interface Scheduler
job
- The job to execute (either Job
or Runnable
).config
- An optional configuration object - this configuration is only passed to the job the job implements Job
.times
- The number of times this job should be started (must be higher than 1)period
- Every period seconds this job is started.
Scheduler.fireJob(java.lang.Object, java.util.Map, int, long)
public boolean fireJobAt(String name, Object job, Map<String,Serializable> config, Date date, int times, long period)
Scheduler
fireJobAt
in interface Scheduler
name
- The name of the job - or null. If no name is specified it can't be cancelled.job
- The job to execute (either Job
or Runnable
).config
- An optional configuration object - this configuration is only passed to the job the job implements Job
.date
- The date this job should be run.times
- The number of times this job should be started (must be higher than 1)period
- Every period seconds this job is started.
Scheduler.fireJobAt(java.lang.String, java.lang.Object, java.util.Map, java.util.Date, int, long)
public void removeJob(String name) throws NoSuchElementException
Scheduler
removeJob
in interface Scheduler
name
- The name of the job.
NoSuchElementException
- If the job is not scheduled.Scheduler.removeJob(java.lang.String)
protected void bindJob(org.osgi.framework.ServiceReference ref)
ref
-
Exception
protected void unbindJob(org.osgi.framework.ServiceReference ref)
ref
- protected void bindTask(org.osgi.framework.ServiceReference ref)
ref
-
Exception
protected void unbindTask(org.osgi.framework.ServiceReference ref)
ref
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |