本文整理汇总了Java中org.quartz.JobExecutionContext.getTrigger方法的典型用法代码示例。如果您正苦于以下问题:Java JobExecutionContext.getTrigger方法的具体用法?Java JobExecutionContext.getTrigger怎么用?Java JobExecutionContext.getTrigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.JobExecutionContext
的用法示例。
在下文中一共展示了JobExecutionContext.getTrigger方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRunningJob
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* 所有正在运行的job
*
* @return
* @throws SchedulerException
*/
public List<ScheduleJob> getRunningJob() throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
List<ScheduleJob> jobList = new ArrayList<ScheduleJob>(executingJobs.size());
for (JobExecutionContext executingJob : executingJobs) {
ScheduleJob job = new ScheduleJob();
JobDetail jobDetail = executingJob.getJobDetail();
JobKey jobKey = jobDetail.getKey();
Trigger trigger = executingJob.getTrigger();
job.setName(jobKey.getName());
job.setGroup(jobKey.getGroup());
job.setDescription("触发器:" + trigger.getKey());
Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
job.setStatus(triggerState.name());
if (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger) trigger;
String cronExpression = cronTrigger.getCronExpression();
job.setCron(cronExpression);
}
jobList.add(job);
}
return jobList;
}
示例2: jobToBeExecuted
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* @see org.quartz.JobListener#jobToBeExecuted(JobExecutionContext)
*/
public void jobToBeExecuted(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobToBeFiredMessage(), args));
}
示例3: jobExecutionVetoed
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext)
*/
public void jobExecutionVetoed(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobWasVetoedMessage(), args));
}
示例4: jobToBeExecuted
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* @see org.quartz.JobListener#jobToBeExecuted(JobExecutionContext)
*/
public void jobToBeExecuted(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getName(),
context.getJobDetail().getGroup(), new java.util.Date(),
trigger.getName(), trigger.getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new Integer(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobToBeFiredMessage(), args));
}
示例5: jobExecutionVetoed
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext)
*/
public void jobExecutionVetoed(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getName(),
context.getJobDetail().getGroup(), new java.util.Date(),
trigger.getName(), trigger.getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new Integer(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobWasVetoedMessage(), args));
}
示例6: getRunningJobList
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
@Override
public List<ScheduleJobEntity> getRunningJobList() {
List<ScheduleJobEntity> jobList = null;
Scheduler scheduler = schedulerFactoryBean.getScheduler();
try {
List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();
jobList = new ArrayList<>(executingJobList.size());
for (JobExecutionContext executingJob : executingJobList) {
ScheduleJobEntity scheduleJob = new ScheduleJobEntity();
JobDetail jobDetail = executingJob.getJobDetail();
JobKey jobKey = jobDetail.getKey();
Trigger trigger = executingJob.getTrigger();
this.wrapScheduleJob(scheduleJob, scheduler, jobKey, trigger);
jobList.add(scheduleJob);
}
} catch (Exception e) {
logger.error("获取计划任务列表失败", e);
throw new ServiceException("获取计划任务列表失败", e);
}
return jobList;
}
示例7: jobWasExecuted
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* @see org.quartz.JobListener#jobWasExecuted(JobExecutionContext, JobExecutionException)
*/
public void jobWasExecuted(JobExecutionContext context,
JobExecutionException jobException) {
Trigger trigger = context.getTrigger();
Object[] args = null;
if (jobException != null) {
if (!getLog().isWarnEnabled()) {
return;
}
String errMsg = jobException.getMessage();
args =
new Object[] {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount()), errMsg
};
getLog().warn(MessageFormat.format(getJobFailedMessage(), args), jobException);
} else {
if (!getLog().isInfoEnabled()) {
return;
}
String result = String.valueOf(context.getResult());
args =
new Object[] {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount()), result
};
getLog().info(MessageFormat.format(getJobSuccessMessage(), args));
}
}
示例8: jobWasExecuted
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* @see org.quartz.JobListener#jobWasExecuted(JobExecutionContext, JobExecutionException)
*/
public void jobWasExecuted(JobExecutionContext context,
JobExecutionException jobException) {
Trigger trigger = context.getTrigger();
Object[] args = null;
if (jobException != null) {
if (!getLog().isWarnEnabled()) {
return;
}
String errMsg = jobException.getMessage();
args =
new Object[] {
context.getJobDetail().getName(),
context.getJobDetail().getGroup(), new java.util.Date(),
trigger.getName(), trigger.getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new Integer(context.getRefireCount()), errMsg
};
getLog().warn(MessageFormat.format(getJobFailedMessage(), args), jobException);
} else {
if (!getLog().isInfoEnabled()) {
return;
}
String result = String.valueOf(context.getResult());
args =
new Object[] {
context.getJobDetail().getName(),
context.getJobDetail().getGroup(), new java.util.Date(),
trigger.getName(), trigger.getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new Integer(context.getRefireCount()), result
};
getLog().info(MessageFormat.format(getJobSuccessMessage(), args));
}
}
示例9: execute
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* Calls the feed notifier to do its work
*/
public void execute(JobExecutionContext context) throws JobExecutionException
{
JobDataMap jobData = context.getJobDetail().getJobDataMap();
final FeedNotifier feedNotifier = (FeedNotifier)jobData.get(KEY_FEED_NOTIFIER);
final TenantAdminService tenantAdminService = (TenantAdminService)jobData.get(KEY_TENANT_ADMIN_SERVICE);
Long repeatInterval = null;
Trigger trigger = context.getTrigger();
if (trigger instanceof SimpleTrigger)
{
repeatInterval = ((SimpleTrigger)trigger).getRepeatInterval();
}
final int repeatIntervalMins = new Long(repeatInterval == null ? 0L : repeatInterval / 1000 / 60).intValue();
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
feedNotifier.execute(repeatIntervalMins);
return null;
}
}, AuthenticationUtil.getSystemUserName());
if ((tenantAdminService != null) && tenantAdminService.isEnabled())
{
List<Tenant> tenants = tenantAdminService.getAllTenants();
for (Tenant tenant : tenants)
{
TenantUtil.runAsSystemTenant(new TenantRunAsWork<Object>()
{
public Object doWork() throws Exception
{
feedNotifier.execute(repeatIntervalMins);
return null;
}
}, tenant.getTenantDomain());
}
}
}
示例10: getRunningJobList
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public List<ScheduleJob> getRunningJobList() throws SchedulerException{
List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();
List<ScheduleJob> jobList = new ArrayList<>(executingJobList.size());
for(JobExecutionContext executingJob : executingJobList){
ScheduleJob scheduleJob = new ScheduleJob();
JobDetail jobDetail = executingJob.getJobDetail();
JobKey jobKey = jobDetail.getKey();
Trigger trigger = executingJob.getTrigger();
this.wrapScheduleJob(scheduleJob,scheduler,jobKey,trigger);
jobList.add(scheduleJob);
}
return jobList;
}