当前位置: 首页>>代码示例>>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;未经允许,请勿转载。