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


Java SchedulerFactory類代碼示例

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


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

示例1: refreshMetadata

import org.quartz.SchedulerFactory; //導入依賴的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: start

import org.quartz.SchedulerFactory; //導入依賴的package包/類
public void start(){
    for(int index = 0; index < jobList.size(); index++){
        JobInfo jobInfo = jobList.get(index);
        String logTitle = "[" + code + "]" + jobInfo.getName() + " ";
        try{
            SchedulerFactory sf = new StdSchedulerFactory();
            Scheduler sched = sf.getScheduler();
            JobDetail job = newJob(DataTask.class).withIdentity("job-" + jobInfo.getName(), code).build();
            job.getJobDataMap().put("srcDb", srcDb);
            job.getJobDataMap().put("destDb", destDb);
            job.getJobDataMap().put("jobInfo", jobInfo);
            job.getJobDataMap().put("logTitle", logTitle);
            logger.info(jobInfo.getCron());
            CronTrigger trigger = newTrigger()
                            .withIdentity("trigger-" +  jobInfo.getName(), code)
                            .withSchedule(cronSchedule(jobInfo.getCron())).build();
            sched.scheduleJob(job, trigger);
            sched.start();  
        }catch(Exception e){
            logger.info(logTitle + e.getMessage());
            logger.info(logTitle + " run failed");
            continue;
        }
    }
}
 
開發者ID:GongDexing,項目名稱:database-sync,代碼行數:26,代碼來源:App.java

示例3: serverTasks

import org.quartz.SchedulerFactory; //導入依賴的package包/類
public serverTasks() throws SchedulerException, ParseException{
	
	/* 
	 * 循環式的
	 */
	SchedulerFactory factory = new StdSchedulerFactory();
	Scheduler scheduler = factory.getScheduler();
	//設置啟動時間
	DateBuilder.evenMinuteDate(new Date());
	JobDetail job = JobBuilder.newJob(job.class).withIdentity("job1", "group1").build();
 
	//job.getJobDataMap().put("a", true);//實現傳參
	// @NOTICE
	// 與SimpleTrigger對比:類不同了,現在的是Trigger的子類CronTrigger;withSchedule中的參數變為CronScheduleBuilder了
	// CronScheduleBuilder可以通過類似"0/13 * * * * ?"這種表達式來創建定時任務
	// 當前這個表達式的定義是30分鍾執行一次
	CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "group1")
			.withSchedule(CronScheduleBuilder.cronSchedule("1 0/30 * * * ?")).build();

	scheduler.scheduleJob(job, trigger);

	scheduler.start();
 
	//scheduler.shutdown(true);
	
}
 
開發者ID:Xvms,項目名稱:xvms,代碼行數:27,代碼來源:serverTasks.java

示例4: createScheduler

import org.quartz.SchedulerFactory; //導入依賴的package包/類
/**
 * Create the Scheduler instance for the given factory and scheduler name.
 * Called by {@link #afterPropertiesSet}.
 * <p>The default implementation invokes SchedulerFactory's {@code getScheduler}
 * method. Can be overridden for custom Scheduler creation.
 * @param schedulerFactory the factory to create the Scheduler with
 * @param schedulerName the name of the scheduler to create
 * @return the Scheduler instance
 * @throws SchedulerException if thrown by Quartz methods
 * @see #afterPropertiesSet
 * @see org.quartz.SchedulerFactory#getScheduler
 */
protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName)
		throws SchedulerException {

	// Override thread context ClassLoader to work around naive Quartz ClassLoadHelper loading.
	Thread currentThread = Thread.currentThread();
	ClassLoader threadContextClassLoader = currentThread.getContextClassLoader();
	boolean overrideClassLoader = (this.resourceLoader != null &&
			!this.resourceLoader.getClassLoader().equals(threadContextClassLoader));
	if (overrideClassLoader) {
		currentThread.setContextClassLoader(this.resourceLoader.getClassLoader());
	}
	try {
		SchedulerRepository repository = SchedulerRepository.getInstance();
		synchronized (repository) {
			Scheduler existingScheduler = (schedulerName != null ? repository.lookup(schedulerName) : null);
			Scheduler newScheduler = schedulerFactory.getScheduler();
			if (newScheduler == existingScheduler) {
				throw new IllegalStateException("Active Scheduler of name '" + schedulerName + "' already registered " +
						"in Quartz SchedulerRepository. Cannot create a new Spring-managed Scheduler of the same name!");
			}
			if (!this.exposeSchedulerInRepository) {
				// Need to remove it in this case, since Quartz shares the Scheduler instance by default!
				SchedulerRepository.getInstance().remove(newScheduler.getSchedulerName());
			}
			return newScheduler;
		}
	}
	finally {
		if (overrideClassLoader) {
			// Reset original thread context ClassLoader.
			currentThread.setContextClassLoader(threadContextClassLoader);
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:47,代碼來源:SchedulerFactoryBean.java

示例5: configure

import org.quartz.SchedulerFactory; //導入依賴的package包/類
/**
 * @see com.google.inject.AbstractModule#configure()
 */
@Override
protected void configure() {
    logger.info("NinjaQuartz Module initialising.");

    // disable Quartz' checking for updates
    System.setProperty("org.terracotta.quartz.skipUpdateCheck", "true");

    bind(SchedulerFactory.class).toProvider(QuartzSchedulerFactoryProvider.class).in(Singleton.class);

    NinjaQuartzScheduleHelper scheduleHelper = new NinjaQuartzScheduleHelper();
    requestInjection(scheduleHelper);

    bindListener(Matchers.any(), new NinjaQuartzTypeListener(scheduleHelper));
    bind(NinjaQuartzScheduleHelper.class).toInstance(scheduleHelper);

    bind(NinjaQuartzUtil.class).to(NinjaQuartzUtilImpl.class);

    logger.info("NinjaQuartz Module initialisation completed.");
}
 
開發者ID:FendlerConsulting,項目名稱:ninja-quartz,代碼行數:23,代碼來源:NinjaQuartzModule.java

示例6: createScheduler

import org.quartz.SchedulerFactory; //導入依賴的package包/類
/**
 * @param method
 * @param quartzSchedule
 * @return
 * @throws SchedulerException
 */
private Scheduler createScheduler(Method method, QuartzSchedule quartzSchedule) throws SchedulerException {
    int schedulerDelay = quartzSchedule.schedulerDelay();

    SchedulerFactory sf = schedulerFactoryProvider.get();
    Scheduler scheduler = sf.getScheduler();
    if (!scheduler.isStarted()) {
        if (schedulerDelay == -1) {
            scheduler.start();
            logger.debug("Started new scheduler of type {}", scheduler.getClass().getName());
        } else {
            scheduler.startDelayed(schedulerDelay);
            logger.debug("Started new scheduler of type {} with delay {}", scheduler.getClass().getName(),
                    schedulerDelay);
        }
    }

    return scheduler;
}
 
開發者ID:FendlerConsulting,項目名稱:ninja-quartz,代碼行數:25,代碼來源:NinjaQuartzScheduleHelper.java

示例7: main

import org.quartz.SchedulerFactory; //導入依賴的package包/類
/** 
 * Starts the main program and schedules the twitter post stats job
 * @param  args  (unused array of strings)
 */
public static void main(String[] args) throws IOException {
	logMsg("Twitter poster started...\n");

	// Set the job logging level to "ERROR" and
	// schedule the station updater for every 60 seconds
	System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "ERROR");
	JobDetail job = JobBuilder.newJob(TwitterPostStatsJob.class)
			.withIdentity("twitterPostStatsJob").build();
	Trigger trigger = TriggerBuilder.newTrigger()
			.withSchedule(SimpleScheduleBuilder.simpleSchedule()
			.withIntervalInSeconds(60).repeatForever()).build();

	// Schedule the twitter post stats job
	try {
		SchedulerFactory sf = new StdSchedulerFactory();
		Scheduler sched = sf.getScheduler();
		sched.start();
		sched.scheduleJob(job, trigger);
	} catch (SchedulerException e) {
		logMsg("Error running the twitter post stats job...");
		e.printStackTrace();
	}
}
 
開發者ID:rcbyron,項目名稱:java-projects,代碼行數:28,代碼來源:Main.java

示例8: open

import org.quartz.SchedulerFactory; //導入依賴的package包/類
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
	try {
		_collector = collector;

		ru = new RedisUtil();
		redis = ru.getJedisInstance();

		SchedulerFactory schedulerFactory = new StdSchedulerFactory();
		Scheduler scheduler = schedulerFactory.getScheduler();
		_qManager = new QuartzManager();
		_qManager.setScheduler(scheduler);
		PlatformUtils.initRegisterProject(_qManager);
		scheduler.start();

		//init Hbase tables
		CreateTable.initHbaseTable();
	}catch(Exception ex){
		logger.error("error:"+MySysLogger.formatException(ex));
		ex.printStackTrace();
	}
}
 
開發者ID:cutoutsy,項目名稱:miner,代碼行數:22,代碼來源:BeginSpout.java

示例9: testQuartzComponentCustomScheduler

import org.quartz.SchedulerFactory; //導入依賴的package包/類
@Test
public void testQuartzComponentCustomScheduler() throws Exception {
    QuartzComponent comp = new QuartzComponent();
    comp.setCamelContext(context);

    SchedulerFactory fac = new StdSchedulerFactory();
    comp.setSchedulerFactory(fac);
    assertSame(fac, comp.getSchedulerFactory());

    Scheduler sch = fac.getScheduler();
    comp.setScheduler(sch);
    assertSame(sch, comp.getScheduler());

    comp.start();
    comp.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:QuartzComponentTest.java

示例10: testQuartzComponentCustomScheduler

import org.quartz.SchedulerFactory; //導入依賴的package包/類
@Test
public void testQuartzComponentCustomScheduler() throws Exception {
    QuartzComponent comp = new QuartzComponent();
    comp.setCamelContext(context);

    SchedulerFactory fac = new StdSchedulerFactory();
    comp.setFactory(fac);
    assertSame(fac, comp.getFactory());

    Scheduler sch = fac.getScheduler();
    comp.setScheduler(sch);
    assertSame(sch, comp.getScheduler());

    comp.start();
    comp.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:QuartzComponentTest.java

示例11: init

import org.quartz.SchedulerFactory; //導入依賴的package包/類
@PostConstruct  
	public void init() { 
        try {
        	// Load stored jobs.
        	logger.debug("LOADING QUARTZ JOBS");
            SchedulerFactory sf = new StdSchedulerFactory("quartz.properties");
			scheduler = sf.getScheduler();
			scheduler.start();
			
//	        classLoadHelper = new CascadingClassLoadHelper();
//	        classLoadHelper.initialize();
//	        processor = new XMLSchedulingDataProcessor(this.classLoadHelper);
	        
		} catch (SchedulerException e) {
			e.printStackTrace();
//		} catch (ParserConfigurationException e) {
//			e.printStackTrace();
		}
	}
 
開發者ID:erfgoed-en-locatie,項目名稱:artsholland-platform,代碼行數:20,代碼來源:SchedulerServiceImpl.java

示例12: configure

import org.quartz.SchedulerFactory; //導入依賴的package包/類
@Override
  protected void configure() {
logger.info("** Binding OSS Config classes.");

      // Fix bug in Jersey-Guice integration exposed by child injectors
      binder().bind(GuiceContainer.class).asEagerSingleton();
      binder().bind(GuiceJobFactory.class).asEagerSingleton();
      binder().bind(IRaigadInstanceFactory.class).to(CassandraInstanceFactory.class);

      // TODO: Use config.getCredentialProvider() instead of IAMCredential
      binder().bind(ICredential.class).to(IAMCredential.class);
      binder().bind(AbstractRepository.class).annotatedWith(Names.named("s3")).to(S3Repository.class);
      binder().bind(AbstractRepositorySettingsParams.class).annotatedWith(Names.named("s3")).to(S3RepositorySettingsParams.class);
      bind(SchedulerFactory.class).to(StdSchedulerFactory.class).asEagerSingleton();
      bind(HostSupplier.class).to(EurekaHostsSupplier.class).in(Scopes.SINGLETON);
  }
 
開發者ID:Netflix,項目名稱:Raigad,代碼行數:17,代碼來源:InjectedWebListener.java

示例13: init

import org.quartz.SchedulerFactory; //導入依賴的package包/類
/**
 * Initialize the service.
 */
private void init( )
{
    SchedulerFactory factory = new StdSchedulerFactory( );

    try
    {
        _scheduler = factory.getScheduler( );
        _scheduler.start( );
        AppLogService.info( "Lutece job scheduler started." );
    }
    catch( SchedulerException e )
    {
        AppLogService.error( "Error starting the Lutece job scheduler ", e );
    }
}
 
開發者ID:lutece-platform,項目名稱:lutece-core,代碼行數:19,代碼來源:JobSchedulerService.java

示例14: AbstractParser

import org.quartz.SchedulerFactory; //導入依賴的package包/類
public AbstractParser() throws SchedulerException {
    
    final SchedulerFactory schedulerFactory = new StdSchedulerFactory();
    final Scheduler scheduler = schedulerFactory.getScheduler();
    
    this.injector = Guice.createInjector(new AbstractModule() {
        
        @Override
        protected void configure() {
            install(new FactoryModuleBuilder().build(ResourceFactory.class));
            bind(MetadataFactoryIf.class).to(MetadataFactoryTest.class);
            bind(CCJSqlParserManager.class).toInstance(new CCJSqlParserManager());
            bind(ConnectionFactory.class).toInstance(new ConnectionFactoryTest());
            bind(Scheduler.class).toInstance(scheduler);
        }
    });
    this.rf = injector.getInstance(ResourceFactory.class);
    this.mf = injector.getInstance(MetadataFactoryIf.class);
}
 
開發者ID:valdasraps,項目名稱:resthub,代碼行數:20,代碼來源:AbstractParser.java

示例15: getScheduler

import org.quartz.SchedulerFactory; //導入依賴的package包/類
/**
 * 
 * @return
 */
private static org.quartz.Scheduler getScheduler() {
	if (quartzScheduler != null) {
		return quartzScheduler;
	}

	synchronized (instance) {
		if (quartzScheduler == null) {
			try {
				SchedulerFactory schedFact = new StdSchedulerFactory();
				quartzScheduler = schedFact.getScheduler();
				quartzScheduler.start();
			} catch (SchedulerException e) {
				logger.error("Error instantiating Scheduler", e);
			}
		}
		return quartzScheduler;
	}

}
 
開發者ID:sfera-labs,項目名稱:sfera,代碼行數:24,代碼來源:Scheduler.java


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