Package org.quartz

Examples of org.quartz.JobDataMap


   * @return the cron trigger
   */
  private MyCronTrigger getCronTrigger(String key)
  {
    JobDetail jobDetail = new JobDetail();
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("process", _wp);
    jobDetail.setJobDataMap(jobDataMap);
    jobDetail.setName(key);

    Class jobClass = getJobClass(key);
    if (jobClass == null)
View Full Code Here


   * @return the simple trigger
   */
  private MySimpleTrigger getSimpleTrigger(String key)
  {
    JobDetail jobDetail = new JobDetail();
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("process", _wp);
    jobDetail.setJobDataMap(jobDataMap);

    Class jobClass = getJobClass(key);
    if (jobClass == null)
      return null;
View Full Code Here

   * @return the cron trigger
   */
  private MyCronTrigger getCronTrigger(String key)
  {
    JobDetail jobDetail = new JobDetail();
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("process", _wp);
    jobDetail.setJobDataMap(jobDataMap);
    jobDetail.setName(key);

    Class jobClass = getJobClass(key);
    if (jobClass == null)
View Full Code Here

        String jobName = ctx.getJobDetail().getFullName();
        if (log.isDebugEnabled()) {
            log.debug("Executing task : " + jobName);
        }
        JobDataMap jdm = ctx.getMergedJobDataMap();
        String jobClassName = (String) jdm.get(CLASSNAME);
        if (jobClassName == null) {
            handleException("No " + CLASSNAME + " in JobDetails");
        }

        Task task = null;
        try {
            task = (Task) getClass().getClassLoader().loadClass(jobClassName).newInstance();
        } catch (Exception e) {
            handleException("Cannot instantiate task : " + jobClassName, e);
        }

        Set properties = (Set) jdm.get(PROPERTIES);
        for (Object property : properties) {
            OMElement prop = (OMElement) property;
            log.debug("Found Property : " + prop.toString());
            PropertyHelper.setStaticProperty(prop, task);
        }

        // 1. Initialize
        SynapseEnvironment se = (SynapseEnvironment) jdm.get("SynapseEnvironment");
        if (task instanceof ManagedLifecycle && se != null) {
            ((ManagedLifecycle) task).init(se);
        }

        // 2. Execute
View Full Code Here

            jobDetail.setGroup(group);
        } else {
            jobDetail.setGroup(TaskDescription.DEFAULT_GROUP);
        }

        JobDataMap jobDataMap = new JobDataMap(resources);

        String className = taskDescription.getTaskClass();
        if (className != null && !"".equals(className)) {
            jobDataMap.put(TaskDescription.CLASSNAME, className);
        }

        Set xmlProperties = taskDescription.getProperties();
        if (xmlProperties != null) {
            jobDataMap.put(TaskDescription.PROPERTIES, xmlProperties);
        }
        jobDetail.setJobDataMap(jobDataMap);

        return jobDetail;
    }
View Full Code Here

     */
    private JobDataMap initDataMap(final Long    bundleId,
                                   final String  jobName,
                                   final Object  job,
                                   final InternalScheduleOptions options) {
        final JobDataMap jobDataMap = new JobDataMap();

        jobDataMap.put(DATA_MAP_OBJECT, job);

        jobDataMap.put(DATA_MAP_NAME, jobName);
        jobDataMap.put(DATA_MAP_LOGGER, this.logger);
        if ( bundleId != null ) {
            jobDataMap.put(DATA_MAP_BUNDLE_ID, bundleId);
        }
        if ( options.configuration != null ) {
            jobDataMap.put(DATA_MAP_CONFIGURATION, options.configuration);
        }
        if ( options.runOn != null) {
            jobDataMap.put(DATA_MAP_RUN_ON, options.runOn);
        }

        return jobDataMap;
    }
View Full Code Here

            }

            final Trigger trigger = opts.trigger.withIdentity(name).build();

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

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

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

    /**
     * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
     */
    public void execute(final JobExecutionContext context) throws JobExecutionException {

        final JobDataMap data = context.getJobDetail().getJobDataMap();
        final Object job = data.get(QuartzScheduler.DATA_MAP_OBJECT);
        final Logger logger = (Logger)data.get(QuartzScheduler.DATA_MAP_LOGGER);

        // check run on information
        final String[] runOn = (String[])data.get(QuartzScheduler.DATA_MAP_RUN_ON);
        if ( runOn != null ) {
            if ( runOn.length == 1 && Scheduler.VALUE_RUN_ON_LEADER.equals(runOn[0])
                 || runOn.length == 1 && Scheduler.VALUE_RUN_ON_SINGLE.equals(runOn[0]) ) {
                if ( DISCOVERY_INFO_AVAILABLE.get() ) {
                    if ( !IS_LEADER.get() ) {
                        logger.debug("Excluding job {} with name {} and config {}.",
                                new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), runOn[0]});
                        return;
                    }
                } else {
                    logger.warn("No discovery info available. Executing job {} with name {} and config {} anyway.",
                            new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), runOn[0]});
                }
            } else { // sling IDs
                final String myId = SLING_ID;
                boolean schedule = false;
                if ( myId == null ) {
                    logger.warn("No Sling ID available. Executing job {} with name {} and config {} anyway.",
                            new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), Arrays.toString(runOn)});
                    schedule = true;
                } else {
                    for(final String id : runOn ) {
                        if ( myId.equals(id) ) {
                            schedule = true;
                            break;
                        }
                    }
                }
                if ( !schedule ) {
                    logger.debug("Excluding job {} with name {} and config {}.",
                            new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), Arrays.toString(runOn)});
                    return;
                }
            }
        }

        try {
            logger.debug("Executing job {} with name {}", job, data.get(QuartzScheduler.DATA_MAP_NAME));
            if (job instanceof org.apache.sling.commons.scheduler.Job) {
                @SuppressWarnings("unchecked")
                final Map<String, Serializable> configuration = (Map<String, Serializable>) data.get(QuartzScheduler.DATA_MAP_CONFIGURATION);
                final String name = (String) data.get(QuartzScheduler.DATA_MAP_NAME);

                final JobContext jobCtx = new JobContextImpl(name, configuration);
                ((org.apache.sling.commons.scheduler.Job) job).execute(jobCtx);
            } else if (job instanceof Runnable) {
                ((Runnable) job).run();
View Full Code Here

     * @param jobDetail The job for which the jobData map shall be updated
     * @param endpointUri URI of the endpoint name, if any. May be {@code null}
     */
    public static void updateJobDataMap(CamelContext camelContext, JobDetail jobDetail, String endpointUri) {
        // Store this camelContext name into the job data
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        String camelContextName = QuartzHelper.getQuartzContextName(camelContext);
        LOG.debug("Adding camelContextName={}, endpointUri={} into job data map.", camelContextName, endpointUri);
        jobDataMap.put(QuartzConstants.QUARTZ_CAMEL_CONTEXT_NAME, camelContextName);
        jobDataMap.put(QuartzConstants.QUARTZ_ENDPOINT_URI, endpointUri);
    }
View Full Code Here

      public QuartzJob() { }

      public void execute(JobExecutionContext context)
          throws JobExecutionException
      {
         JobDataMap dataMap = context.getJobDetail().getJobDataMap();
         async = (Asynchronous)dataMap.get("async");
         QuartzTriggerHandle handle = new QuartzTriggerHandle(context.getTrigger().getName());
         try
         {
            async.execute(handle);
         }
View Full Code Here

TOP

Related Classes of org.quartz.JobDataMap

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.