當前位置: 首頁>>代碼示例>>Java>>正文


Java Scheduler.isShutdown方法代碼示例

本文整理匯總了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;
}
 
開發者ID:HankXV,項目名稱:Limitart,代碼行數:27,代碼來源:SchedulerUtil.java

示例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();
        }
    }
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:15,代碼來源:QuartzManager.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:StdSchedulerFactory.java

示例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);
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:19,代碼來源:DaemonDetectionJob.java

示例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);    
    }    
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:39,代碼來源:MicroQuartzManager.java

示例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);    
    }    
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:16,代碼來源:MicroQuartzManager.java

示例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;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:47,代碼來源:DaemonStatusController.java

示例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;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:48,代碼來源:SchedulerAnalysis.java


注:本文中的org.quartz.Scheduler.isShutdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。