本文整理汇总了Java中org.quartz.Scheduler.isShutdown方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.isShutdown方法的具体用法?Java Scheduler.isShutdown怎么用?Java Scheduler.isShutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.Scheduler
的用法示例。
在下文中一共展示了Scheduler.isShutdown方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSchedule
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 增加一个调度任务(cron版)
*
* @param name
* 任务名称
* @param job
* 执行内容
* @param cronExpression
* cron表达式
* @throws SchedulerException
*/
public Trigger addSchedule(String name, Class<? extends Job> task, String cronExpression, JobDataMap param)
throws SchedulerException {
Scheduler sched = SF.getScheduler();
JobBuilder builder = JobBuilder.newJob(task);
builder.withIdentity(name, Scheduler.DEFAULT_GROUP);
if (param != null) {
builder.usingJobData(param);
}
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(name, Scheduler.DEFAULT_GROUP)
.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
sched.scheduleJob(builder.build(), trigger);
if (!sched.isShutdown())
sched.start();
return trigger;
}
示例2: schedulerShutdown
import org.quartz.Scheduler; //导入方法依赖的package包/类
public void schedulerShutdown(String schedulerName, boolean waitForJobsToComplete) throws SchedulerException {
Scheduler scheduler = this.getAssertScheduler(schedulerName);
if (!scheduler.isShutdown()) {
List<JobDetail> allJobsOfScheduler = QuartzUtils.getAllJobsOfScheduler(scheduler);
for (JobDetail jobDetail : allJobsOfScheduler) {
QuartzUtils.pauseJob(jobDetail, scheduler);
}
if (waitForJobsToComplete) {
scheduler.shutdown(waitForJobsToComplete);
} else {
scheduler.shutdown();
}
}
}
示例3: getScheduler
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* <p>
* Returns a handle to the Scheduler produced by this factory.
* </p>
*
* <p>
* If one of the <code>initialize</code> methods has not be previously
* called, then the default (no-arg) <code>initialize()</code> method
* will be called by this method.
* </p>
*/
public Scheduler getScheduler() throws SchedulerException {
if (cfg == null) {
initialize();
}
SchedulerRepository schedRep = SchedulerRepository.getInstance();
Scheduler sched = schedRep.lookup(getSchedulerName());
if (sched != null) {
if (sched.isShutdown()) {
schedRep.remove(getSchedulerName());
} else {
return sched;
}
}
sched = instantiate();
return sched;
}
示例4: execute
import org.quartz.Scheduler; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
DetectionJobDetail jobDetail=(DetectionJobDetail)context.getJobDetail();
try {
ISchedulerService service=jobDetail.getSchedulerService();
if(!service.isRunJobInCurrentInstance()){
log.warn("Current instance not allowed run scheduler!");
return;
}
Scheduler scheduler=service.getCurrentScheduler();
if(scheduler==null || scheduler.isShutdown()){
System.out.println("Current instance scheduler was shutdown,start reset...");
service.resetScheduer();
System.out.println("Reset successful...");
}
} catch (Exception e) {
throw new JobExecutionException(e);
}
}
示例5: addJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* @Description: 添加一个定时任务,使用默认的任务组名,触发器名,触发器组名
* @param jobName 任务名
* @param cls 任务
* @param time 时间设置,参考quartz说明文档
*
*/
@SuppressWarnings("unchecked")
public static void addJob(String jobName, Class cls, String cron,String groovyName,String groovyMethod,String paramStr) {
try {
Scheduler sched = gSchedulerFactory.getScheduler();
JobDetail job = newJob(cls)
.withIdentity(jobName, JOB_GROUP_NAME)
.build();
// 添加具体任务方法
job.getJobDataMap().put("groovyName", groovyName);
job.getJobDataMap().put("groovyMethod", groovyMethod);
job.getJobDataMap().put("paramStr", paramStr);
// 表达式调度构建器
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cron);
// 按新的cronExpression表达式构建一个新的trigger
Trigger trigger = TriggerBuilder
.newTrigger()
.withIdentity(jobName, TRIGGER_GROUP_NAME)
.withSchedule(scheduleBuilder).build();
//交给scheduler去调度
sched.scheduleJob(job, trigger);
// 启动
if (!sched.isShutdown()) {
sched.start();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: shutdownJobs
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* @Description 关闭所有定时任务
*
*
*/
public static void shutdownJobs() {
try {
Scheduler sched = gSchedulerFactory.getScheduler();
if (!sched.isShutdown()) {
sched.shutdown();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例7: doHandleRequest
import org.quartz.Scheduler; //导入方法依赖的package包/类
@Override
protected ModelAndView doHandleRequest(HttpServletRequest req,HttpServletResponse res) throws Exception {
SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Scheduler scheduler=instanceDetection.getScheduler();
StringBuffer sb=new StringBuffer();
sb.append("<strong>Status</strong>:");
if(scheduler.isInStandbyMode()){
sb.append("Standby");
}
if(scheduler.isShutdown()){
sb.append("Shutdown");
}
if(scheduler.isStarted()){
sb.append("Started");
}
sb.append("<br>");
for (String groupName : scheduler.getJobGroupNames()) {
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
JobDetail jobDetail=scheduler.getJobDetail(jobKey);
sb.append("<strong>JobClass:</strong>");
sb.append(jobDetail.getJobClass().getName());
Trigger trigger=scheduler.getTriggersOfJob(jobDetail.getKey()).get(0);
sb.append("<br><strong>PreviousFireDate:</strong>");
if(trigger.getPreviousFireTime()!=null){
sb.append(sd.format(trigger.getPreviousFireTime()));
}
sb.append("<br><strong>NextFireDate:</strong>");
if(sd.format(trigger.getNextFireTime())!=null){
sb.append(sd.format(trigger.getNextFireTime()));
}
if(trigger instanceof CronTriggerImpl){
CronTriggerImpl cron=(CronTriggerImpl)trigger;
sb.append("<br><strong>CronExpression:</strong>");
sb.append(cron.getCronExpression());
}
}
}
res.setContentType("text/html; charset=utf-8");
PrintWriter pw=res.getWriter();
pw.write(sb.toString());
pw.flush();
pw.close();
return null;
}
示例8: loadScheduerInfo
import org.quartz.Scheduler; //导入方法依赖的package包/类
@DataProvider
public SchedulerInfo loadScheduerInfo() throws Exception{
SchedulerInfo info=new SchedulerInfo();
info.setRunJob(schedulerService.isRunJobInCurrentInstance());
Scheduler scheduler=schedulerService.getCurrentScheduler();
if(scheduler!=null){
if(scheduler.isStarted()){
info.setState(SchedulerState.started);
}else if(scheduler.isShutdown()){
info.setState(SchedulerState.shutdown);
}else if(scheduler.isInStandbyMode()){
info.setState(SchedulerState.standby);
}
info.setJobInstanceName(schedulerService.getJobInstanceName());
List<JobInfo> jobs=new ArrayList<JobInfo>();
for (String groupName : scheduler.getJobGroupNames()) {
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
JobInfo jobInfo=new JobInfo();
JobDetail jobDetail=scheduler.getJobDetail(jobKey);
if(jobDetail instanceof SpringBeanJobExecutorDetail){
SpringBeanJobExecutorDetail springBeanDetail=(SpringBeanJobExecutorDetail)jobDetail;
jobInfo.setTargetJobInfo("SpringBean:"+springBeanDetail.getTargetJobBeanId());
jobInfo.setType(JobType.definition);
}else if(jobDetail instanceof ScanJobExecutorDetail){
jobInfo.setType(JobType.scan);
jobInfo.setTargetJobInfo(jobDetail.getJobClass().getName());
}
Trigger trigger=scheduler.getTriggersOfJob(jobKey).get(0);
jobInfo.setName(jobDetail.getKey().getName());
jobInfo.setGroup(jobDetail.getKey().getGroup());
jobInfo.setNextFireDate(trigger.getNextFireTime());
jobInfo.setPreviousFireDate(trigger.getPreviousFireTime());
if(trigger instanceof CronTriggerImpl){
CronTriggerImpl cron=(CronTriggerImpl)trigger;
jobInfo.setTriggerInfo("Cron表达式类型触发器["+cron.getCronExpression()+"]");
}else{
jobInfo.setTriggerInfo("触发器类型:"+trigger.getClass());
}
jobs.add(jobInfo);
}
info.setJobs(jobs);
}
}
return info;
}