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


Java Scheduler.start方法代碼示例

本文整理匯總了Java中org.quartz.Scheduler.start方法的典型用法代碼示例。如果您正苦於以下問題:Java Scheduler.start方法的具體用法?Java Scheduler.start怎麽用?Java Scheduler.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.Scheduler的用法示例。


在下文中一共展示了Scheduler.start方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refreshMetadata

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * Refresh metadata. Schedules the job to retrieve metadata.
 * @throws SchedulerException the scheduler exception
 */
@PostConstruct
public void refreshMetadata() throws SchedulerException {
    final Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            buildMetadataResolverAggregate();
        }
    });
    thread.start();

    final JobDetail job = JobBuilder.newJob(this.getClass())
            .withIdentity(this.getClass().getSimpleName()).build();
    final Trigger trigger = TriggerBuilder.newTrigger()
            .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                    .withIntervalInMinutes(this.refreshIntervalInMinutes)
                    .repeatForever()).build();

    final SchedulerFactory schFactory = new StdSchedulerFactory();
    final Scheduler sch = schFactory.getScheduler();
    sch.start();
    sch.scheduleJob(job, trigger);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:27,代碼來源:StaticMetadataResolverAdapter.java

示例2: 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

示例3: startIndexerJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
private void startIndexerJob() throws SchedulerException {
    Scheduler scheduler = Singleton.getScheduler();
    // Setup the indexer which runs forever indexing
    JobDetail job = newJob(IndexJob.class)
            .withIdentity("indexjob")
            .build();

    SimpleTrigger trigger = newTrigger()
            .withIdentity("indexerjob")
            .withSchedule(simpleSchedule()
                    .withIntervalInHours(24)
                    .repeatForever()
            )
            .build();

    scheduler.scheduleJob(job, trigger);
    scheduler.start();
}
 
開發者ID:boyter,項目名稱:freemoz,代碼行數:19,代碼來源:JobService.java

示例4: enableSessionValidation

import org.quartz.Scheduler; //導入方法依賴的package包/類
public void enableSessionValidation() {  
    if (log.isDebugEnabled()) {  
        log.debug("Scheduling session validation job using Quartz with session validation interval of ["  
                + this.sessionValidationInterval + "]ms...");  
    }  
  
    try {  
        SimpleTrigger trigger = TriggerBuilder.newTrigger().startNow().withIdentity(JOB_NAME, Scheduler.DEFAULT_GROUP)  
                .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMilliseconds(sessionValidationInterval))  
                .build(); 
  
        JobDetail detail = JobBuilder.newJob(QuartzSessionValidationJob.class)  
                .withIdentity(JOB_NAME, Scheduler.DEFAULT_GROUP).build();  
        detail.getJobDataMap().put(SESSION_MANAGER_KEY, this.sessionManager);  
        Scheduler scheduler = getScheduler();  
  
        scheduler.scheduleJob(detail, trigger);  
        if (this.schedulerImplicitlyCreated) {  
            scheduler.start();  
            if (log.isDebugEnabled()) {  
                log.debug("Successfully started implicitly created Quartz Scheduler instance.");  
            }  
        }  
        this.enabled = true;  
  
        if (log.isDebugEnabled())  
            log.debug("Session validation job successfully scheduled with Quartz.");  
    } catch (SchedulerException e) {  
        if (log.isErrorEnabled())  
            log.error("Error starting the Quartz session validation job.  Session validation may not occur.", e);  
    }  
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:33,代碼來源:QuartzSessionValidationScheduler.java

示例5: main

import org.quartz.Scheduler; //導入方法依賴的package包/類
public static void main(String[] args) {
    try {
        final Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        scheduler.start();
        final JobDetail job = JobBuilder.newJob(MailFilterJob.class).build();
        final Trigger trigger = TriggerBuilder.newTrigger()
                .startNow()
                .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                        .withIntervalInMinutes(15)
                        .repeatForever())
                .build();
        scheduler.scheduleJob(job, trigger);
    } catch (SchedulerException ex) {
        Logger.getLogger(MailFilterService.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:17,代碼來源:MailFilterService.java

示例6: schedulerStart

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 啟動全部
 * @throws SchedulerException
 */
public void schedulerStart() throws SchedulerException {
    List<Scheduler> schedulers = this.getSchedulers();
    for (Scheduler scheduler : schedulers) {
        scheduler.start();
    }
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:11,代碼來源:QuartzManager.java

示例7: startJobInstance

import org.quartz.Scheduler; //導入方法依賴的package包/類
public void startJobInstance() throws Exception{
	if(schedulerService.isRunJobInCurrentInstance()){
		initRunJobsForStartup();
		initSystemJobs();
		Scheduler scheduler=schedulerService.retrieveScheduler();
		if(scheduler.isInStandbyMode()){
			System.out.println("Start scheduler ["+scheduler.getSchedulerName()+"]...");
			scheduler.start();
		}
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:12,代碼來源:Initializer.java

示例8: scheduleJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
private void scheduleJob(final Scheduler scheduler, final JobDetail jobDetail, final String triggerIdentity, final String cron) {
    try {
        if (!scheduler.checkExists(jobDetail.getKey())) {
            scheduler.scheduleJob(jobDetail, createTrigger(triggerIdentity, cron));
        }
        scheduler.start();
        RUNNING_SCHEDULERS.putIfAbsent(scheduler.getSchedulerName(), scheduler);
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
}
 
開發者ID:elasticjob,項目名稱:elastic-job-cloud,代碼行數:12,代碼來源:DaemonTaskScheduler.java

示例9: startScheduler

import org.quartz.Scheduler; //導入方法依賴的package包/類
private void startScheduler() throws SchedulerException {
      log.warn("Starting scheduler (pid:" + ServerUtil.getCurrentPid() + ")");
      Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
      scheduler.start();

      JobDataMap jobDataMap = new JobDataMap();
      jobDataMap.put(ApiFactoryService.class.getName(), this.apiFactoryService);
      jobDataMap.put(DistributedApplianceConformJobFactory.class.getName(), this.daConformJobFactory);
      jobDataMap.put(DeploymentSpecConformJobFactory.class.getName(), this.dsConformJobFactory);
      jobDataMap.put(SecurityGroupConformJobFactory.class.getName(), this.sgConformJobFactory);
      jobDataMap.put(ManagerConnectorConformJobFactory.class.getName(), this.mcConformJobFactory);


      JobDetail syncDaJob = JobBuilder.newJob(SyncDistributedApplianceJob.class).usingJobData(jobDataMap).build();
      JobDetail syncSgJob = JobBuilder.newJob(SyncSecurityGroupJob.class).usingJobData(jobDataMap).build();

// TODO: Remove the delay, once plugin state listener is implemented.
      // Related issue: https://github.com/opensecuritycontroller/osc-core/issues/545
Trigger syncDaJobTrigger = TriggerBuilder.newTrigger()
		.startAt(Date.from(Instant.now().plusSeconds(SERVER_SYNC_DELAY))).withSchedule(SimpleScheduleBuilder
		.simpleSchedule().withIntervalInMinutes(this.scheduledSyncInterval).repeatForever()).build();

Trigger syncSgJobTrigger = TriggerBuilder.newTrigger()
		.startAt(Date.from(Instant.now().plusSeconds(SERVER_SYNC_DELAY))).withSchedule(SimpleScheduleBuilder
		.simpleSchedule().withIntervalInMinutes(this.scheduledSyncInterval).repeatForever()).build();

      scheduler.scheduleJob(syncDaJob, syncDaJobTrigger);
      scheduler.scheduleJob(syncSgJob, syncSgJobTrigger);

      this.archiveService.maybeScheduleArchiveJob();
  }
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:32,代碼來源:Server.java

示例10: startService

import org.quartz.Scheduler; //導入方法依賴的package包/類
@Override
public void startService() throws Exception {
    log.info("Start QuartzService(" + jndiName + ")...");

    try {
        rebind();
    } catch (NamingException ne) {
        log.error("Failed to rebind Scheduler", ne);

        throw new SchedulerConfigException("Failed to rebind Scheduler - ",
                ne);
    }

    try {
        Scheduler scheduler = schedulerFactory.getScheduler();

        if (startScheduler) {
            scheduler.start();
        } else {
            log.info("Skipping starting the scheduler (will not run jobs).");
        }
    } catch (Exception e) {
        log.error("Failed to start Scheduler", e);

        throw new SchedulerConfigException("Failed to start Scheduler - ",
                e);
    }

    log.info("QuartzService(" + jndiName + ") started.");
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:QuartzService.java

示例11: 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

示例12: execute

import org.quartz.Scheduler; //導入方法依賴的package包/類
@Override
public void execute(final WebScriptRequest request, final WebScriptResponse response) throws IOException {

	final Writer w = response.getWriter();
	String siteId = request.getParameter(PARAM_SITE_ID);
	String role = siteService.getMembersRole(siteId, authenticationService.getCurrentUserName());
	if (authorityService.hasAdminAuthority() || SiteModel.SITE_MANAGER.equals(role)) {

		log.debug("Starting job manually. jobdetailbean=" + jobdetailbean);
		SchedulerFactory schedFact = new StdSchedulerFactory();

		// Create a trigger that fires exactly once, ten seconds from now
		final long startTime = System.currentTimeMillis() + 1000L;
		final SimpleTrigger trigger = new SimpleTrigger("manualTrigger", null, new Date(startTime), null, 0, 0L);

		try {
			final Scheduler s = schedFact.getScheduler();
			s.addJobListener(new ManualJobListener());
			log.debug("trigger: " + trigger + ", scheduler: " + s);

			s.scheduleJob(jobdetailbean, trigger);
			s.start();

			String msgStart = "LDAP Sync triggered at " + new Date(startTime);
			log.info(msgStart);
			w.write(msgStart);

		} catch (final Exception e) {
			log.error("Error while executing " + jobdetailbean + " manually");
			throw new AlfrescoRuntimeException("Error while executing " + jobdetailbean + " manually", e);
		}

	} else {
		String msg = "Only Alfresco Administrators or SiteManagers can trigger ldpa sync action manually.";
		log.error(msg);
		throw new AlfrescoRuntimeException(msg);
	}
}
 
開發者ID:form4,項目名稱:alfresco-triggerauthenticationsync,代碼行數:39,代碼來源:StartPeopleSyncWebScript.java

示例13: startJobs

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**  
 * @Description:啟動所有定時任務  
 *  
 * 
 */  
public static void startJobs() {    
    try {    
        Scheduler sched = gSchedulerFactory.getScheduler();    
        sched.start();    
    } catch (Exception e) {    
        throw new RuntimeException(e);    
    }    
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:14,代碼來源:MicroQuartzManager.java

示例14: main

import org.quartz.Scheduler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
	SchedulerFactory sf = new StdSchedulerFactory(
			"E:\\git-working\\asura-framework\\asura\\asura-dubbo\\src\\test\\java\\com\\asura\\test\\quartz.properties");
	Scheduler sched = sf.getScheduler();
	sched.start();

}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:8,代碼來源:DB3.java

示例15: main

import org.quartz.Scheduler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
  // create the parser
  CommandLineParser parser = new DefaultParser();
  CommandLine line = parser.parse(getOptions(), args);

  // files directory
  String directory = line.getOptionValue("directory", "hkex/");

  // config file
  String config = line.getOptionValue("config", "config/tracker.properties");

  // init scheduler
  SchedulerFactory sf = new StdSchedulerFactory();
  Scheduler scheduler = sf.getScheduler();

  // define job instance
  JobDetail job = newJob(TrackerJob.class)
      .withIdentity("job", "group")
      .usingJobData("directory", directory)
      .usingJobData("config", config)
      .build();

  // define trigger instance
  Trigger trigger = newTrigger()
      .withIdentity("trigger", "group")
      .startNow()
      .withSchedule(dailyAtHourAndMinute(8, 30)) // fire every day at 8:30
      .build();

  // schedule the job with the trigger
  scheduler.scheduleJob(job, trigger);

  // start scheduler
  scheduler.start();
}
 
開發者ID:longkerdandy,項目名稱:qfii-tracker,代碼行數:36,代碼來源:ScheduleService.java


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