类org.quartz.JobDetail源码实例Demo

下面列出了怎么用org.quartz.JobDetail的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: rice   文件: QuartzQueueAction.java
@Override
public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm form) throws Exception {
    if ("moveToRouteQueue".equals(request.getParameter("methodToCall")) && request.getAttribute(RENDER_LIST_OVERRIDE) == null) {
        return null;
    }

    Scheduler scheduler = KSBServiceLocator.getScheduler();
    List<QuartzQueueForm> jobs = new ArrayList<QuartzQueueForm>();
    List<String> jobGroups = KSBServiceLocator.getScheduler().getJobGroupNames();

    for (int i = 0; i < jobGroups.size(); i++) {
        String jobGroup = KSBServiceLocator.getScheduler().getJobGroupNames().get(i);
        for(JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroup))) {
            Trigger trigger = scheduler.getTriggersOfJob(jobKey).get(0);
            JobDetail jobDetail = scheduler.getJobDetail(jobKey);
            jobs.add(new QuartzQueueForm(jobDetail, trigger) );
        }
    }

    request.setAttribute("jobs", jobs);
    return null;
}
 
源代码2 项目: nexus-public   文件: SchedulerTest.java
@Test
public void testAbilityToFireImmediatelyWhenStartedAfter() throws Exception {
  List<Long> jobExecTimestamps = Collections.synchronizedList(new ArrayList<Long>());
  CyclicBarrier barrier = new CyclicBarrier(2);

  Scheduler sched = createScheduler("testAbilityToFireImmediatelyWhenStartedAfter", 5);
  sched.getContext().put(BARRIER, barrier);
  sched.getContext().put(DATE_STAMPS, jobExecTimestamps);

  JobDetail job1 = JobBuilder.newJob(TestJobWithSync.class).withIdentity("job1").build();
  Trigger trigger1 = TriggerBuilder.newTrigger().forJob(job1).build();

  long sTime = System.currentTimeMillis();

  sched.scheduleJob(job1, trigger1);
  sched.start();

  barrier.await(TEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);

  sched.shutdown(true);

  long fTime = jobExecTimestamps.get(0);

  assertTrue("Immediate trigger did not fire within a reasonable amount of time.",
      (fTime - sTime < 7000L));  // This is dangerously subjective!  but what else to do?
}
 
源代码3 项目: lams   文件: JobDetailImpl.java
@Override
public boolean equals(Object obj) {
    if (!(obj instanceof JobDetail)) {
        return false;
    }

    JobDetail other = (JobDetail) obj;

    if(other.getKey() == null || getKey() == null)
        return false;
    
    if (!other.getKey().equals(getKey())) {
        return false;
    }
        
    return true;
}
 
源代码4 项目: nexus-public   文件: JobStoreImpl.java
private void storeJob(final ODatabaseDocumentTx db, final JobDetail jobDetail, final boolean replaceExisting)
    throws JobPersistenceException
{
  log.debug("Store job: jobDetail={}, replaceExisting={}", jobDetail, replaceExisting);

  JobDetailEntity entity = jobDetailEntityAdapter.readByKey(db, jobDetail.getKey());
  if (entity == null) {
    // no existing entity, add new one
    entity = new JobDetailEntity(jobDetail);
    jobDetailEntityAdapter.addEntity(db, entity);
  }
  else {
    // otherwise entity exists, maybe replace if allowed
    if (replaceExisting) {
      entity.setValue(jobDetail);
      jobDetailEntityAdapter.editEntity(db, entity);
    }
    else {
      throw new ObjectAlreadyExistsException(jobDetail);
    }
  }
}
 
源代码5 项目: JuniperBot   文件: ReminderJob.java
public static JobDetail createDetails(MessageChannel channel, Member member, String message) {
    String userId;
    String guildId = null;
    if (channel instanceof PrivateChannel) {
        userId = ((PrivateChannel) channel).getUser().getId();
    } else {
        guildId = member.getGuild().getId();
        userId = member.getUser().getId();
    }
    return JobBuilder
            .newJob(ReminderJob.class)
            .withIdentity(GROUP + " - " + UUID.randomUUID(), GROUP)
            .usingJobData(ATTR_GUILD_ID, guildId)
            .usingJobData(ATTR_USER_ID, userId)
            .usingJobData(ATTR_CHANNEL_ID, channel.getId())
            .usingJobData(ATTR_MESSAGE, message)
            .build();
}
 
源代码6 项目: Lottery   文件: CmsTaskAct.java
/**
 * 开始任务调度
 * @param task 任务
 * @param taskCode 任务名称
 * @throws ParseException
 * @throws SchedulerException
 * @throws ClassNotFoundException
 */
private void startTask(CmsTask task,String taskCode) throws ParseException, SchedulerException, ClassNotFoundException{
	String cronExpress=manager.getCronExpressionFromDB(task.getId());
	System.out.println(cronExpress);
	if(cronExpress.indexOf("null")==-1){
		JobDetail jobDetail = new JobDetail();
		jobDetail.setName(taskCode);
		jobDetail.setGroup(Scheduler.DEFAULT_GROUP);
		jobDetail.setJobClass(getClassByTask(task.getJobClass()));
		//任务需要参数attr属性 
		jobDetail.setJobDataMap(getJobDataMap(task.getAttr()));
		CronTrigger cronTrigger = new CronTrigger("cron_" + taskCode,Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP);
		cronTrigger.setCronExpression(cronExpress);
		scheduler.scheduleJob(jobDetail, cronTrigger); 
	}
}
 
源代码7 项目: quartz-redis-jobstore   文件: RedisJobStoreTest.java
@Test
public void clearAllSchedulingData() throws Exception {
    // create and store some jobs, triggers, and calendars
    Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = getJobsAndTriggers(2, 2, 2, 2);
    jobStore.storeJobsAndTriggers(jobsAndTriggers, false);

    // ensure that the jobs, triggers, and calendars were stored
    assertEquals(2, (long) jedis.scard(schema.jobGroupsSet()));
    assertEquals(4, (long) jedis.scard(schema.jobsSet()));
    assertEquals(8, (long) jedis.scard(schema.triggerGroupsSet()));
    assertEquals(16, (long) jedis.scard(schema.triggersSet()));

    jobStore.clearAllSchedulingData();

    assertEquals(0, (long) jedis.scard(schema.jobGroupsSet()));
    assertEquals(0, (long) jedis.scard(schema.jobsSet()));
    assertEquals(0, (long) jedis.scard(schema.triggerGroupsSet()));
    assertEquals(0, (long) jedis.scard(schema.triggersSet()));
}
 
源代码8 项目: molgenis   文件: JobSchedulerTest.java
@Test
void scheduleInactive() throws SchedulerException {
  ScheduledJob scheduledJob = scheduledJobFactory.create();
  scheduledJob.setId(id);
  scheduledJob.set(ScheduledJobMetadata.CRON_EXPRESSION, "	0/20 * * * * ?");
  scheduledJob.set(ScheduledJobMetadata.NAME, "name");
  scheduledJob.set(ScheduledJobMetadata.ACTIVE, false);
  scheduledJob.setType(scheduledJobType);

  when(quartzScheduler.checkExists(jobKey)).thenReturn(false);

  jobScheduler.schedule(scheduledJob);

  verify(quartzScheduler, Mockito.never())
      .scheduleJob(ArgumentMatchers.any(JobDetail.class), ArgumentMatchers.any(Trigger.class));
}
 
源代码9 项目: quartz-web   文件: QuartzManager.java
public JobDetail addStatefulMethodJob(String schedulerName, String jobName, String jobGroup, String jobClass,
                                    Object[] constructorArguments, String jobClassMethodName,
                                    Object[] jobClassMethodArgs, String description) throws SchedulerException {
    Assert.notNull(jobClass, "jobClass can not be null");
    Assert.notEmpty(schedulerName, "schedulerName can not be empty");
    Assert.notEmpty(jobName, "jobName can not be empty");
    Assert.notEmpty(jobGroup, "jobGroup can not be empty");
    Assert.notEmpty(jobClassMethodName, "jobClassMethodName can not be empty");
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("jobClass", jobClass);
    jobDataMap.put("constructorArguments", constructorArguments);
    jobDataMap.put("jobClassMethodName", jobClassMethodName);
    jobDataMap.put("jobClassMethodArgs", jobClassMethodArgs);
    JobDetail jobDetail = JobBuilder.newJob(StatefulMethodInvokeJob.class).withIdentity(jobName, jobGroup)
            .withDescription(description).setJobData(jobDataMap).storeDurably().build();
    addJob(schedulerName, jobDetail);
    return jobDetail;
}
 
源代码10 项目: springboot-quartz   文件: ScheduleJobService.java
private void wrapScheduleJob(ScheduleJob scheduleJob,Scheduler scheduler,JobKey jobKey,Trigger trigger){  
    try {  
        scheduleJob.setJobName(jobKey.getName());  
        scheduleJob.setJobGroup(jobKey.getGroup()); 
  
        JobDetail jobDetail = scheduler.getJobDetail(jobKey);  
        ScheduleJob job = (ScheduleJob)jobDetail.getJobDataMap().get("scheduleJob");  
        scheduleJob.setDesc(job.getDesc());  
        scheduleJob.setJobId(job.getJobId());
  
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());  
        scheduleJob.setJobStatus(triggerState.name());  
        if(trigger instanceof CronTrigger){  
            CronTrigger cronTrigger = (CronTrigger)trigger;  
            String cronExpression = cronTrigger.getCronExpression();  
            scheduleJob.setCronExpression(cronExpression);  
        }  
    } catch (SchedulerException e) {  
        e.printStackTrace(); 
    }  
}
 
源代码11 项目: alfresco-data-model   文件: ConfigScheduler.java
private synchronized void schedule()
{
    try
    {
        scheduler = schedulerFactory.getScheduler();

        JobDetail job = JobBuilder.newJob()
                .withIdentity(jobName)
                .ofType(ConfigSchedulerJob.class)
                .build();
        jobKey = job.getKey();
        job.getJobDataMap().put(CONFIG_SCHEDULER, this);
        CronExpression cronExpression = normalCronSchedule ? this.cronExpression : initialAndOnErrorCronExpression;
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .withIdentity(jobName+"Trigger", Scheduler.DEFAULT_GROUP)
                .withSchedule(CronScheduleBuilder.cronSchedule(cronExpression))
                .build();
        scheduler.startDelayed(0);
        scheduler.scheduleJob(job, trigger);
        log.debug("Schedule set "+cronExpression);
    }
    catch (Exception e)
    {
        log.error("Error scheduling "+e.getMessage());
    }
}
 
源代码12 项目: LuckyFrameWeb   文件: ScheduleUtils.java
/**
 * 创建定时任务
 */
public static void createScheduleJob(Scheduler scheduler, Job job)
{
    try
    {
        // 构建job信息
        JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(job.getJobId())).build();

        // 表达式调度构建器
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
        cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);

        // 按新的cronExpression表达式构建一个新的trigger
        CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(job.getJobId())).withSchedule(cronScheduleBuilder).build();

        // 放入参数,运行时的方法可以获取
        jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);

        scheduler.scheduleJob(jobDetail, trigger);

        // 暂停任务
        if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
        {
            pauseJob(scheduler, job.getJobId());
        }
    }
    catch (SchedulerException | TaskException e)
    {
        log.error("createScheduleJob 异常:", e);
    }
}
 
源代码13 项目: o2oa   文件: ScheduleLogRequest.java
public ScheduleLogRequest(JobExecutionContext jobExecutionContext, JobExecutionException jobExecutionException) {
	JobDetail jobDetail = jobExecutionContext.getJobDetail();
	this.className = jobDetail.getKey().getName();
	this.application = jobDetail.getKey().getGroup();
	this.node = jobDetail.getDescription();
	this.type = jobExecutionContext.getTrigger().getDescription();
	this.elapsed = jobExecutionContext.getJobRunTime();
	this.fireTime = jobExecutionContext.getFireTime();
	if (null != jobExecutionException) {
		this.stackTrace = ExceptionUtils.getStackTrace(jobExecutionException);
		this.success = false;
	} else {
		this.success = true;
	}
}
 
源代码14 项目: redis-quartz   文件: RedisJobStore.java
@Override
public JobDetail retrieveJob(JobKey jobKey) throws JobPersistenceException {
	JobDetail jobDetail = null;
	String jobHashkey = createJobHashKey(jobKey.getGroup(), jobKey.getName());
     try (Jedis jedis = pool.getResource()) {
        lockPool.acquire();
		jobDetail = retrieveJob(jobKey, jedis);			
     } catch (JobPersistenceException | ClassNotFoundException | InterruptedException ex) {
		log.error("could not retrieve job: " + jobHashkey, ex);
		throw new JobPersistenceException(ex.getMessage(), ex.getCause());
	} finally {
        lockPool.release();
	}
	return jobDetail;
}
 
源代码15 项目: SensorWebClient   文件: CacheUpdateJob.java
@Override
    public JobDetail createJobDetails() {
        return JobBuilder.newJob(CacheUpdateJob.class)
                .withIdentity(getJobName())
                .withDescription(getJobDescription())
//                .usingJobData(REWRITE_AT_STARTUP, rewriteAtStartup)
                .build();
    }
 
源代码16 项目: lams   文件: RemoteScheduler.java
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
 * </p>
 */
public JobDetail getJobDetail(JobKey jobKey)
    throws SchedulerException {
    try {
        return getRemoteScheduler().getJobDetail(jobKey);
    } catch (RemoteException re) {
        throw invalidateHandleCreateException(
                "Error communicating with remote scheduler.", re);
    }
}
 
源代码17 项目: nextreports-server   文件: DefaultReportService.java
@Transactional(readOnly = true)
public void runMonitorReport(JobDetail jobDetail) {
	try {
		quartzJobHandler.runMonitorJob(jobDetail);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
源代码18 项目: nexus-public   文件: QuartzTaskUtils.java
/**
 * Saves {@link TaskConfiguration} back to the given {@link JobDetail}.
 */
public static void updateJobData(final JobDetail jobDetail, final TaskConfiguration taskConfiguration) {
  JobDataMap jobDataMap = jobDetail.getJobDataMap();
  taskConfiguration.asMap().forEach((key, value) -> {
    if (!value.equals(jobDataMap.get(key))) {
      jobDataMap.put(key, value); // only touch jobDataMap if value actually changed
    }
  });
}
 
源代码19 项目: smarthome   文件: RuleTriggerManager.java
/**
 * Creates and schedules a new quartz-job and trigger with model and rule name as jobData.
 *
 * @param rule the rule to schedule
 * @param trigger the defined trigger
 *
 * @throws SchedulerException if there is an internal Scheduler error.
 */
private void createTimer(Rule rule, TimerTrigger trigger) throws SchedulerException {
    String cronExpression = trigger.getCron();
    if (trigger.getTime() != null) {
        if (trigger.getTime().equals("noon")) {
            cronExpression = "0 0 12 * * ?";
        } else if (trigger.getTime().equals("midnight")) {
            cronExpression = "0 0 0 * * ?";
        } else {
            logger.warn("Unrecognized time expression '{}' in rule '{}'", trigger.getTime(), rule.getName());
            return;
        }
    }

    String jobIdentity = getJobIdentityString(rule, trigger);

    try {
        JobDetail job = newJob(ExecuteRuleJob.class)
                .usingJobData(ExecuteRuleJob.JOB_DATA_RULEMODEL, rule.eResource().getURI().path())
                .usingJobData(ExecuteRuleJob.JOB_DATA_RULENAME, rule.getName()).withIdentity(jobIdentity).build();
        Trigger quartzTrigger = newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
        scheduler.scheduleJob(job, Collections.singleton(quartzTrigger), true);

        logger.debug("Scheduled rule '{}' with cron expression '{}'", rule.getName(), cronExpression);
    } catch (RuntimeException e) {
        throw new SchedulerException(e.getMessage());
    }
}
 
源代码20 项目: sunbird-lms-service   文件: SchedulerManager.java
public static void scheduleChannelReg(String identifier) {
  // add another job for registering channel to ekstep.
  // 1- create a job and bind with class which is implementing Job
  // interface.
  JobDetail channelRegistrationJob =
      JobBuilder.newJob(ChannelRegistrationScheduler.class)
          .requestRecovery(true)
          .withDescription("Scheduler for channel registration")
          .withIdentity("channelRegistrationScheduler", identifier)
          .build();

  // 2- Create a trigger object that will define frequency of run.
  // It will run only once after server startup
  Trigger channelRegistrationTrigger =
      TriggerBuilder.newTrigger()
          .withIdentity("channelRegistrationScheduler", identifier)
          .withSchedule(SimpleScheduleBuilder.repeatMinutelyForTotalCount(1))
          .build();
  try {
    if (scheduler.checkExists(channelRegistrationJob.getKey())) {
      scheduler.deleteJob(channelRegistrationJob.getKey());
    }
    scheduler.scheduleJob(channelRegistrationJob, channelRegistrationTrigger);
    scheduler.start();
    ProjectLogger.log(
        "SchedulerManager:scheduleChannelReg: channelRegistration schedular started",
        LoggerEnum.INFO.name());
  } catch (Exception e) {
    ProjectLogger.log(e.getMessage(), e);
  }
}
 
private void scheduleJob2(Scheduler scheduler) throws SchedulerException{
    JobDetail jobDetail = JobBuilder.newJob(CronJob2.class) .withIdentity("job2", "group2")
    		.usingJobData("serviceCode","Live lesson reminder2").build();
    CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/10 * * * * ?");
    CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("trigger2", "group2") .withSchedule(scheduleBuilder).build();
    scheduler.scheduleJob(jobDetail,cronTrigger);  
}
 
源代码22 项目: roboconf-platform   文件: RoboconfSchedulerTest.java
@Test( expected = IOException.class )
public void testSaveJob_exception() throws Exception {

	this.scheduler.scheduler = Mockito.mock( Scheduler.class );
	Mockito.when( this.scheduler.scheduler.scheduleJob(
			Mockito.any( JobDetail.class ),
			Mockito.any( Trigger.class ))).thenThrow( new SchedulerException( "For test" ));

	this.scheduler.saveJob( null, "job", "cmd", "0 0 0 ? 1 *", "app" );
}
 
源代码23 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Update the job detail record.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param job
 *          the job to update
 * @return number of rows updated
 * @throws IOException
 *           if there were problems serializing the JobDataMap
 */
public int updateJobDetail(Connection conn, JobDetail job)
    throws IOException, SQLException {
    ByteArrayOutputStream baos = serializeJobData(job.getJobDataMap());

    PreparedStatement ps = null;

    int insertResult = 0;

    try {
        ps = conn.prepareStatement(rtp(UPDATE_JOB_DETAIL));
        ps.setString(1, job.getDescription());
        ps.setString(2, job.getJobClass().getName());
        setBoolean(ps, 3, job.isDurable());
        setBoolean(ps, 4, job.isVolatile());
        setBoolean(ps, 5, job.isStateful());
        setBoolean(ps, 6, job.requestsRecovery());
        setBytes(ps, 7, baos);
        ps.setString(8, job.getName());
        ps.setString(9, job.getGroup());

        insertResult = ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }

    if (insertResult > 0) {
        deleteJobListeners(conn, job.getName(), job.getGroup());

        String[] jobListeners = job.getJobListenerNames();
        for (int i = 0; jobListeners != null && i < jobListeners.length; i++) {
            insertJobListener(conn, job, jobListeners[i]);
        }
    }

    return insertResult;
}
 
源代码24 项目: centraldogma   文件: FileBasedSessionManager.java
private Scheduler createScheduler(String cronExpr) throws SchedulerException {
    // The scheduler can be started and stopped several times in JUnit tests, but Quartz holds
    // every scheduler instances in a singleton SchedulerRepository. So it's possible to pick up
    // the scheduler which is going to be stopped if we use the same instance name for every scheduler,
    // because CentralDogmaExtension stops the server asynchronously using another thread.
    final String myInstanceId = String.valueOf(hashCode());

    final Properties cfg = new Properties();
    cfg.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
    cfg.setProperty("org.quartz.scheduler.instanceName",
                    FileBasedSessionManager.class.getSimpleName() + '@' + myInstanceId);
    cfg.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
    cfg.setProperty("org.quartz.threadPool.threadCount", "1");

    final Scheduler scheduler = new StdSchedulerFactory(cfg).getScheduler();

    final JobDetail job = newJob(ExpiredSessionDeletingJob.class)
            .usingJobData(newJobDataMap(ImmutableMap.of(ROOT_DIR, rootDir)))
            .build();

    final Trigger trigger = newTrigger()
            .withIdentity(myInstanceId, ExpiredSessionDeletingJob.class.getSimpleName())
            .withSchedule(cronSchedule(cronExpr))
            .build();

    scheduler.scheduleJob(job, trigger);
    return scheduler;
}
 
源代码25 项目: lams   文件: RemoteMBeanScheduler.java
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
 * passing the <code>SchedulingContext</code> associated with this
 * instance.
 * </p>
 */
public void addJob(JobDetail jobDetail, boolean replace, boolean storeNonDurableWhileAwaitingScheduling)
        throws SchedulerException {
    invoke(
            "addJob",
            new Object[] { JobDetailSupport.toCompositeData(jobDetail), replace , storeNonDurableWhileAwaitingScheduling},
            new String[] { CompositeData.class.getName(), boolean.class.getName(), boolean.class.getName() });
}
 
源代码26 项目: griffin   文件: SparkSubmitJob.java
@Override
public void execute(JobExecutionContext context) {
    JobDetail jd = context.getJobDetail();
    try {
        if (isNeedLivyQueue) {
            //livy batch limit
            livyTaskSubmitHelper.addTaskToWaitingQueue(jd);
        } else {
            saveJobInstance(jd);
        }
    } catch (Exception e) {
        LOGGER.error("Post spark task ERROR.", e);
    }
}
 
源代码27 项目: lams   文件: JobStoreSupport.java
/**
 * <p>
 * Inform the <code>JobStore</code> that the scheduler has completed the
 * firing of the given <code>Trigger</code> (and the execution its
 * associated <code>Job</code>), and that the <code>{@link org.quartz.JobDataMap}</code>
 * in the given <code>JobDetail</code> should be updated if the <code>Job</code>
 * is stateful.
 * </p>
 */
public void triggeredJobComplete(final OperableTrigger trigger,
        final JobDetail jobDetail, final CompletedExecutionInstruction triggerInstCode) {
    retryExecuteInNonManagedTXLock(
        LOCK_TRIGGER_ACCESS,
        new VoidTransactionCallback() {
            public void executeVoid(Connection conn) throws JobPersistenceException {
                triggeredJobComplete(conn, trigger, jobDetail,triggerInstCode);
            }
        });    
}
 
void verifyJobDetails(JobDetail job) {
    await().untilAsserted(() -> assertThat(reporter.getTransactions().size()).isEqualTo(1));
    assertThat(reporter.getTransactions().get(0).getType()).isEqualToIgnoringCase("scheduled");
    assertThat(reporter.getTransactions().get(0).getNameAsString())
        .isEqualToIgnoringCase(String.format("%s.%s", job.getKey().getGroup(), job.getKey().getName()));
    assertThat(reporter.getTransactions().get(0).getFrameworkName()).isEqualTo("Quartz");
    assertThat(reporter.getTransactions().get(0).getFrameworkVersion()).isEqualTo("2.3.1");
}
 
源代码29 项目: Knowage-Server   文件: SchedulerServiceSupplier.java
/**
 * Gets the job list.
 * 
 * @return the job list
 */
public String getJobList() {
	String xml = "";
	try {
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); 
		List toReturn = new ArrayList();
		String[] groups = scheduler.getJobGroupNames();
		if (groups == null || groups.length == 0) {
			SpagoBITracer.warning(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
					              "getJobList", "No job groups defined!");
		} else {
			for (int i = 0; i < groups.length; i++) {
				String group = groups[i];
				String[] jobNames = scheduler.getJobNames(group);
				if (jobNames == null || jobNames.length == 0) {
					SpagoBITracer.warning(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
							              "getJobList", "No job defined for group " + group + "!");
				} else {
					for (int j = 0; j < jobNames.length; j++) {
						JobDetail aJob = scheduler.getJobDetail(jobNames[j], group);
						toReturn.add(aJob);
					}
				}
			}
		}
		xml = buildJobListXmlString(toReturn);
	} catch (Exception e) {
		SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
	              			"getJobList", "Error while recovering job list");
		xml = "<ROWS></ROWS>";
	}
	return xml;
}
 
源代码30 项目: lams   文件: QuartzSchedulerMBeanImpl.java
public TabularData getAllJobDetails() throws Exception {
    try {
        List<JobDetail> detailList = new ArrayList<JobDetail>();
        for (String jobGroupName : scheduler.getJobGroupNames()) {
            for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroupName))) {
                detailList.add(scheduler.getJobDetail(jobKey));
            }
        }
        return JobDetailSupport.toTabularData(detailList.toArray(new JobDetail[detailList.size()]));
    } catch (Exception e) {
        throw newPlainException(e);
    }
}
 
 类所在包
 同包方法