Package org.quartz

Examples of org.quartz.JobExecutionContext


    }

    @SuppressWarnings("unchecked")
    public boolean isExecuting() throws SchedulerException {
        for (Iterator i = scheduler.getCurrentlyExecutingJobs().iterator(); i.hasNext();) {
            JobExecutionContext context = (JobExecutionContext) i.next();
            if (context.getJobDetail().getFullName().equals(jobDetail.getFullName())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here


    {
    JobDetail jobDetail = new JobDetail();

    SimpleTrigger trig = new SimpleTrigger();

    JobExecutionContext jec = new JobExecutionContext(null, new TriggerFiredBundle(jobDetail, trig, null, false, null, null, null, null), new NoOpJob());
    jec.put("deleteVersions", new Boolean(deleteVersions));
    new CleanOldVersionsJob().execute(jec);

    Map<String,Integer> result = (Map<String,Integer>)jec.getResult();
    this.cleaningMap = result;
   
        return "input";
    }
View Full Code Here

            groupName = Scheduler.DEFAULT_GROUP;
       
        List jobs = getCurrentlyExecutingJobs();
        java.util.Iterator it = jobs.iterator();
       
        JobExecutionContext jec = null;
        JobDetail jobDetail = null;
        Job job = null;
       
        boolean interrupted = false;
       
        while (it.hasNext()) {
            jec = (JobExecutionContext)it.next();
            jobDetail = jec.getJobDetail();
            if (jobName.equals(jobDetail.getName())
                && groupName.equals(jobDetail.getGroup())){
                job = jec.getJobInstance();
                if (job instanceof InterruptableJob) {
                    ((InterruptableJob)job).interrupt();
                    interrupted = true;
                } else {
                    throw new UnableToInterruptJobException(
View Full Code Here

                    "An error occured instantiating job to be executed. job= '"
                            + jobDetail.getFullName() + "'", se);
            throw se;
        }

        this.jec = new JobExecutionContext(scheduler, firedBundle, job);
    }
View Full Code Here

    @Test
    public void execute() throws Exception {
        // prep
        CandlepinPoolManager pm = mock(CandlepinPoolManager.class);
        JobExecutionContext jec = mock(JobExecutionContext.class);
        JobDetail detail = mock(JobDetail.class);
        JobDataMap jdm = mock(JobDataMap.class);

        when(jdm.getString(eq("product_id"))).thenReturn("foobarbaz");
        when(jdm.getBoolean(eq("lazy_regen"))).thenReturn(true);
        when(detail.getJobDataMap()).thenReturn(jdm);
        when(jec.getJobDetail()).thenReturn(detail);

        // test
        RegenProductEntitlementCertsJob recj =
            new RegenProductEntitlementCertsJob(pm);
        recj.execute(jec);
View Full Code Here

    @Test
    public void bindByProductsExec() throws JobExecutionException {
        String[] pids = {"pid1", "pid2", "pid3"};

        JobDetail detail = EntitleByProductsJob.bindByProducts(pids, consumerUuid, null, null);
        JobExecutionContext ctx = mock(JobExecutionContext.class);
        when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());

        List<Entitlement> ents = new ArrayList<Entitlement>();
        when(e.bindByProducts(eq(pids), eq(consumerUuid),
            eq((Date) null), eq((Collection<String>) null))).thenReturn(ents);
View Full Code Here

    }

    @Test
    public void updateWithLargeResult() {
        String longstr = RandomStringUtils.randomAlphanumeric(300);
        JobExecutionContext ctx = mock(JobExecutionContext.class);
        when(ctx.getFireTime()).thenReturn(new Date());
        when(ctx.getJobRunTime()).thenReturn(1000L);
        when(ctx.getResult()).thenReturn(longstr);

        JobStatus status = newJobStatus().owner("terps").create();
        status.update(ctx);
        curator.merge(status);
    }
View Full Code Here

            map.put(JobStatus.TARGET_TYPE, JobStatus.TargetType.OWNER);
            map.put(JobStatus.TARGET_ID, ownerkey);
            JobStatus status = new JobStatus(
                newJob(jobClass).withIdentity(id, PinsetterKernel.SINGLE_JOB_GROUP)
                .usingJobData(map).build());
            JobExecutionContext context = mock(JobExecutionContext.class);
            when(context.getFireTime()).thenReturn(startDt);
            long time = -1;
            if (endDt != null && startDt != null) {
                time = endDt.getTime() - startDt.getTime();
            }
            when(context.getJobRunTime()).thenReturn(time);
            when(context.getResult()).thenReturn(result);
            status.update(context);
            if (state != null) {
                status.setState(state);
            }
            return curator.create(status);
View Full Code Here

        JobStatus status = new JobStatus(detail);

        // store a merge so we can find it in the test run
        curator.merge(status);

        JobExecutionContext ctx = mock(JobExecutionContext.class);
        when(ctx.getMergedJobDataMap()).thenReturn(map);
        when(ctx.getJobDetail()).thenReturn(detail);

        // thing to be tested
        listener.jobWasExecuted(ctx, e);

        // verify the message stored is a substring of the long message
View Full Code Here

    @Test
    public void bindByPoolExec() throws JobExecutionException {
        String pool = "pool10";

        JobDetail detail = EntitlerJob.bindByPool(pool, consumerUuid, 1);
        JobExecutionContext ctx = mock(JobExecutionContext.class);
        when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
        List<Entitlement> ents = new ArrayList<Entitlement>();
        when(e.bindByPool(eq(pool), eq(consumerUuid), eq(1))).thenReturn(ents);

        EntitlerJob job = new EntitlerJob(e, null);
        job.execute(ctx);
View Full Code Here

TOP

Related Classes of org.quartz.JobExecutionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.