Package org.quartz

Examples of org.quartz.JobDetail


        JobWrapper wrapper;

        try {
            String jobClassName = jobElement.getAttribute(ServletJob.ATTRIBUTE_CLASS);
            ServletJob job = ServletJobFactory.createJob(jobClassName);
            JobDetail jobDetail =
                job.load(
                    jobElement,
                    publication.getId(),
                    publication.getServletContext().getAbsolutePath());

            Trigger trigger = null;

            Element triggerElement = helper.getFirstChild(jobElement, "trigger");
            if (triggerElement != null) {
                trigger =
                    TriggerHelper.createTrigger(
                        triggerElement,
                        jobDetail.getName(),
                        jobDetail.getGroup());

                Date now = new GregorianCalendar().getTime();
                if (log.isDebugEnabled()) {
                    DateFormat format = new SimpleDateFormat();
                    log.debug(
View Full Code Here


     *
     * @throws JobExecutionException if there is an exception while executing the job.
     */
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("Executing job");
        JobDetail jobDetail = context.getJobDetail();
       
        DefaultTaskWrapper wrapper = new DefaultTaskWrapper(jobDetail.getJobDataMap());
        try {
            wrapper.execute();
        } catch (ExecutionException e) {
          log.error("Task execution failed: ", e);
        }
View Full Code Here

     * @throws SchedulerException when something went wrong.
     *
     * @return A job details object.
     */
    public JobDetail load(Element jobElement, String jobGroup, String servletContextPath) throws SchedulerException {
        JobDetail jobDetail = super.load(jobElement, jobGroup, servletContextPath);
       
        NamespaceHelper helper = SchedulerStore.getNamespaceHelper();
        DefaultTaskWrapper wrapper = new DefaultTaskWrapper(helper, jobElement);
        wrapper.getTaskParameters().setServletContextPath(servletContextPath);
       
        JobDataMap map = new JobDataMap(wrapper.getParameters());
        jobDetail.setJobDataMap(map);
       
        return jobDetail;
    }
View Full Code Here

    protected void addJob(String jobGroup, Date startTime, Class jobClass, JobDataMap map)
        throws SchedulerException, PublicationException {
        String uniqueJobId = getNextJobId();
        log.debug("Job ID: [" + uniqueJobId + "]");
       
        JobDetail jobDetail = new JobDetail(uniqueJobId, jobGroup, jobClass);
        jobDetail.setJobDataMap(map);
       
        Date now = new GregorianCalendar().getTime();
        if (log.isDebugEnabled()) {
            DateFormat format = new SimpleDateFormat();
            log.debug("Trigger time: [" + format.format(startTime) + "]");
View Full Code Here

        List wrappers = new ArrayList();
        String[] jobNames = getScheduler().getJobNames(jobGroupName);

        for (int nameIndex = 0; nameIndex < jobNames.length; nameIndex++) {
            JobDetail jobDetail = getScheduler().getJobDetail(jobNames[nameIndex], jobGroupName);
            Trigger trigger = getTrigger(jobNames[nameIndex], jobGroupName);
            wrappers.add(new JobWrapper(jobDetail, trigger));
        }

        return (JobWrapper[]) wrappers.toArray(new JobWrapper[wrappers.size()]);
View Full Code Here

     */
    public void modifyJob(String jobId, String jobGroup, Date startTime)
        throws SchedulerException {
        log.debug("Modifying job [" + jobId + "][" + jobGroup + "]");

        JobDetail jobDetail = getScheduler().getJobDetail(jobId, jobGroup);
        if (jobDetail == null) {
            throw new SchedulerException("Job not found!");
        }

        Trigger trigger = getTrigger(jobDetail.getName(), jobGroup);
        if (trigger == null) {
            log.debug("    No trigger found.");
        } else {
            log.debug("    Trigger found. Setting new start time.");
            jobDetail.setDurability(true);
            if (startTime.after(new GregorianCalendar().getTime())) {
                log.debug("    Start time is in future - re-scheduling job.");
                getScheduler().unscheduleJob(trigger.getName(), trigger.getGroup());
                trigger = TriggerHelper.createSimpleTrigger(jobId, jobGroup, startTime);
                getScheduler().scheduleJob(trigger);
View Full Code Here

     * @throws SchedulerException when something went wrong.
     */
    public JobDetail load(Element element, String jobGroup, String servletContextPath)
        throws SchedulerException {
        String jobId = element.getAttribute(ATTRIBUTE_ID);
        JobDetail jobDetail = new JobDetail(jobId, jobGroup, getClass());
        return jobDetail;

    }
View Full Code Here

        this.checkJob(job);

        // if there is already a job with the name, remove it first
        if ( name != null ) {
            try {
                final JobDetail jobdetail = this.scheduler.getJobDetail(name, DEFAULT_QUARTZ_JOB_GROUP);
                if (jobdetail != null) {
                    this.removeJob(name);
                }
            } catch (final SchedulerException ignored) {
            }
        } else {
            name = "Sling Quartz Scheduler " + UUID.randomUUID().toString();
        }

        // create the data map
        final JobDataMap jobDataMap = this.initDataMap(name, job, config, canRunConcurrently);

        final JobDetail detail = this.createJobDetail(name, jobDataMap);

        this.logger.debug("Scheduling job {} with name {} and trigger {}", new Object[] {job, name, trigger});
        this.scheduler.scheduleJob(detail, trigger);
    }
View Full Code Here

     * @param name
     * @param jobDataMap
     * @return
     */
    protected JobDetail createJobDetail(String name, JobDataMap jobDataMap) {
        final JobDetail detail = new JobDetail(name, DEFAULT_QUARTZ_JOB_GROUP, QuartzJobExecutor.class);
        detail.setJobDataMap(jobDataMap);
        return detail;
    }
View Full Code Here

    throws Exception {
        this.checkJob(job);
        final String name = job.getClass().getName();
        final JobDataMap dataMap = this.initDataMap(name, job, config, true);

        final JobDetail detail = this.createJobDetail(name, dataMap);

        final Trigger trigger = new SimpleTrigger(name, DEFAULT_QUARTZ_JOB_GROUP);
        this.scheduler.scheduleJob(detail, trigger);
    }
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.