Package org.quartz

Examples of org.quartz.JobDetail


     * Get the job details and job data map of an existing job to
     * make sure that the XStream configuration works.
     */
    public void testJobDetailMap() throws Exception
    {
        JobDetail jobDetail = quartz.getScheduler().getJobDetail(JobKey.jobKey("simpleJob", "TURBINE"));
        assertNotNull(jobDetail);
        assertEquals("simpleJob", jobDetail.getKey().getName());
        assertNotNull(jobDetail.getJobDataMap());
        assertEquals(2, jobDetail.getJobDataMap().size());
    }
View Full Code Here


    public void addTriggers(final Map<Trigger, JobDetail> triggerMap) throws SchedulerException {
        if (triggerMap != null) {
            Set<Map.Entry<Trigger, JobDetail>> entries = triggerMap.entrySet();
            for (Map.Entry<Trigger, JobDetail> entry : entries) {
                Trigger key = entry.getKey();
                JobDetail value = entry.getValue();
                ObjectHelper.notNull(key, "key");
                ObjectHelper.notNull(value, "value");

                addTrigger(key, value);
            }
View Full Code Here

    protected LoadBalancer createLoadBalancer() {
        return new RoundRobinLoadBalancer();
    }

    protected JobDetail createJobDetail() {
        return new JobDetail();
    }
View Full Code Here

public class DefaultQuartzMarshaler extends MarshalerSupport implements QuartzMarshaler {

    public void populateNormalizedMessage(NormalizedMessage message, JobExecutionContext context)
        throws JobExecutionException, MessagingException {

        JobDetail detail = context.getJobDetail();
        JobDataMap dataMap = detail.getJobDataMap();
        for (Iterator iter = dataMap.entrySet().iterator(); iter.hasNext();) {
            Map.Entry entry = (Map.Entry) iter.next();
            String key = (String) entry.getKey();
            if (!key.equals(ServiceMixJob.COMPONENT_NAME) && !key.equals(ServiceMixJob.ENDPOINT_NAME)) {
                Object value = entry.getValue();
                message.setProperty(key, value);
            }
        }
        try {
            Document document = getTransformer().createDocument();
            Element root = document.createElement("timer");
            document.appendChild(root);
            DOMUtil.addChildElement(root, "name", detail.getName());
            DOMUtil.addChildElement(root, "group", detail.getGroup());
            DOMUtil.addChildElement(root, "fullname", detail.getFullName());
            DOMUtil.addChildElement(root, "description", detail.getDescription());
            DOMUtil.addChildElement(root, "fireTime", context.getFireTime());
            message.setContent(new DOMSource(document));
        } catch (ParserConfigurationException e) {
            throw new MessagingException("Failed to create content: " + e, e);
        }
View Full Code Here

            }
        }      
    }

    public void scheduleRoute(Action action, Route route) throws Exception {
        JobDetail jobDetail = createJobDetail(action, route);
        Trigger trigger = createTrigger(action, route);
        updateScheduledRouteDetails(action, jobDetail, trigger, route);
       
        loadCallbackDataIntoSchedulerContext(jobDetail, action, route);
        getScheduler().scheduleJob(jobDetail, trigger);
View Full Code Here

        LOG.debug("Scheduled Job: {}.{} is deleted", jobDetailGroup, jobDetailName);
    }
   
    protected JobDetail createJobDetail(Action action, Route route) throws Exception {
        JobDetail jobDetail = null;
       
        if (action == Action.START) {
            jobDetail = new JobDetail(JOB_START + route.getId(), JOB_GROUP + route.getId(), ScheduledJob.class);
        } else if (action == Action.STOP) {
            jobDetail = new JobDetail(JOB_STOP + route.getId(), JOB_GROUP + route.getId(), ScheduledJob.class);
        } else if (action == Action.SUSPEND) {
            jobDetail = new JobDetail(JOB_SUSPEND + route.getId(), JOB_GROUP + route.getId(), ScheduledJob.class);
        } else if (action == Action.RESUME) {
            jobDetail = new JobDetail(JOB_RESUME + route.getId(), JOB_GROUP + route.getId(), ScheduledJob.class);
        }
       
        return jobDetail;
    }
View Full Code Here

            // give the trigger a random name
            trigger.setName("Trigger" + String.valueOf((new Random()).nextLong()));
            trigger.setGroup("synapse.simple.quartz");
            trigger.setVolatility(true);
            JobDetail jobDetail = new JobDetail();

            // Give the job a name
            jobDetail.setName(name);
            jobDetail.setGroup("synapse.simple.quartz");
            jobDetail.setJobClass(SimpleQuartzJob.class);
            JobDataMap jdm = new JobDataMap();
            jdm.put(SimpleQuartzJob.SYNAPSE_ENVIRONMENT, synapseEnvironment);
            jdm.put(SimpleQuartzJob.CLASSNAME, className);
            jdm.put(SimpleQuartzJob.PROPERTIES, xmlProperties);
            jobDetail.setJobDataMap(jdm);

            sch.scheduleJob(jobDetail, trigger);
            sch.start();
            log.info("Scheduled job " + jobDetail.getFullName() + " for class " + className);

        } catch (Exception e) {
            log.fatal("Error starting up Scheduler", e);
            throw new SynapseException("Error starting up Scheduler", e);
        }
View Full Code Here

        dataMap.put( ContinuumSchedulerConstants.SCHEDULE, schedule );

        // the name + group makes the job unique

        JobDetail jobDetail = new JobDetail( schedule.getName(), group, jobClass );

        jobDetail.setJobDataMap( dataMap );

        jobDetail.setDescription( schedule.getDescription() );

        CronTrigger trigger = new CronTrigger();

        trigger.setName( schedule.getName() );
View Full Code Here

            }
        }      
    }

    public void scheduleRoute(Action action, Route route) throws Exception {
        JobDetail jobDetail = createJobDetail(action, route);
        Trigger trigger = createTrigger(action, route);
        updateScheduledRouteDetails(action, jobDetail, trigger, route);
       
        loadCallbackDataIntoSchedulerContext(jobDetail, action, route);

        boolean isClustered = route.getRouteContext().getCamelContext().getComponent("quartz2", QuartzComponent.class).isClustered();
        if (isClustered) {
            // check to see if the same job has already been setup through another node of the cluster
            JobDetail existingJobDetail = getScheduler().getJobDetail(jobDetail.getKey());
            if (jobDetail.equals(existingJobDetail)) {
                if (LOG.isInfoEnabled()) {
                    LOG.info("Skipping to schedule the job: {} for action: {} on route {} as the job: {} already existing inside the cluster",
                             new Object[] {jobDetail.getKey(), action, route.getId(), existingJobDetail.getKey()});
                }

                // skip scheduling the same job again as one is already existing for the same routeId and action
                return;
            }
View Full Code Here

        LOG.debug("Scheduled job: {} is deleted", jobKey);
    }
   
    protected JobDetail createJobDetail(Action action, Route route) throws Exception {
        JobDetail jobDetail = null;
       
        if (action == Action.START) {
            jobDetail = JobBuilder.newJob(ScheduledJob.class).withIdentity(JOB_START + route.getId(), JOB_GROUP + route.getId()).build();
        } else if (action == Action.STOP) {
            jobDetail = JobBuilder.newJob(ScheduledJob.class).withIdentity(JOB_STOP + route.getId(), JOB_GROUP + route.getId()).build();
View Full Code Here

TOP

Related Classes of org.quartz.JobDetail

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.