Java Code Examples for org.quartz.impl.JobDetailImpl#setDescription()

The following examples show how to use org.quartz.impl.JobDetailImpl#setDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobBuilder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Produce the <code>JobDetail</code> instance defined by this 
 * <code>JobBuilder</code>.
 * 
 * @return the defined JobDetail.
 */
public JobDetail build() {

    JobDetailImpl job = new JobDetailImpl();
    
    job.setJobClass(jobClass);
    job.setDescription(description);
    if(key == null)
        key = new JobKey(Key.createUniqueName(null), null);
    job.setKey(key); 
    job.setDurability(durability);
    job.setRequestsRecovery(shouldRecover);
    
    
    if(!jobDataMap.isEmpty())
        job.setJobDataMap(jobDataMap);
    
    return job;
}
 
Example 2
Source File: JobDetailSupport.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param cData
 * @return JobDetail
 */
public static JobDetail newJobDetail(CompositeData cData)
  throws ClassNotFoundException
{
    JobDetailImpl jobDetail = new JobDetailImpl();

    int i = 0;
    jobDetail.setName((String) cData.get(ITEM_NAMES[i++]));
    jobDetail.setGroup((String) cData.get(ITEM_NAMES[i++]));
    jobDetail.setDescription((String) cData.get(ITEM_NAMES[i++]));
    Class<?> jobClass = Class.forName((String) cData.get(ITEM_NAMES[i++]));
    @SuppressWarnings("unchecked")
    Class<? extends Job> jobClassTyped = (Class<? extends Job>)jobClass;
    jobDetail.setJobClass(jobClassTyped);
    jobDetail.setJobDataMap(JobDataMapSupport.newJobDataMap((TabularData) cData.get(ITEM_NAMES[i++])));
    jobDetail.setDurability((Boolean) cData.get(ITEM_NAMES[i++]));
    jobDetail.setRequestsRecovery((Boolean) cData.get(ITEM_NAMES[i++]));

    return jobDetail;
}
 
Example 3
Source File: DefaultExceptionServiceImpl.java    From rice with Educational Community License v2.0 6 votes vote down vote up
public void scheduleExecution(Throwable throwable, PersistedMessageBO message, String description) throws Exception {
	KSBServiceLocator.getMessageQueueService().delete(message);
       PersistedMessageBO messageCopy = message.copy();
	Scheduler scheduler = KSBServiceLocator.getScheduler();
	JobDataMap jobData = new JobDataMap();
	jobData.put(MessageServiceExecutorJob.MESSAGE_KEY, messageCopy);
	JobDetailImpl jobDetail = new JobDetailImpl("Exception_Message_Job " + Math.random(), "Exception Messaging",
		MessageServiceExecutorJob.class);
	jobDetail.setJobDataMap(jobData);

       if (!StringUtils.isBlank(description)) {
	    jobDetail.setDescription(description);
	}

       scheduler.getListenerManager().addJobListener( new MessageServiceExecutorJobListener());

       SimpleTriggerImpl trigger = new SimpleTriggerImpl("Exception_Message_Trigger " + Math.random(), "Exception Messaging", messageCopy
		.getQueueDate());
	trigger.setJobDataMap(jobData);// 1.6 bug required or derby will choke

       scheduler.scheduleJob(jobDetail, trigger);
}
 
Example 4
Source File: JobDetailFactoryBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	Assert.notNull(this.jobClass, "Property 'jobClass' is required");

	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.applicationContextJobDataKey != null) {
		if (this.applicationContext == null) {
			throw new IllegalStateException(
					"JobDetailBean needs to be set up in an ApplicationContext " +
					"to be able to handle an 'applicationContextJobDataKey'");
		}
		getJobDataMap().put(this.applicationContextJobDataKey, this.applicationContext);
	}

	JobDetailImpl jdi = new JobDetailImpl();
	jdi.setName(this.name != null ? this.name : toString());
	jdi.setGroup(this.group);
	jdi.setJobClass(this.jobClass);
	jdi.setJobDataMap(this.jobDataMap);
	jdi.setDurability(this.durability);
	jdi.setRequestsRecovery(this.requestsRecovery);
	jdi.setDescription(this.description);
	this.jobDetail = jdi;
}
 
Example 5
Source File: JobDetailFactoryBean.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	Assert.notNull(this.jobClass, "Property 'jobClass' is required");

	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.applicationContextJobDataKey != null) {
		if (this.applicationContext == null) {
			throw new IllegalStateException(
					"JobDetailBean needs to be set up in an ApplicationContext " +
					"to be able to handle an 'applicationContextJobDataKey'");
		}
		getJobDataMap().put(this.applicationContextJobDataKey, this.applicationContext);
	}

	JobDetailImpl jdi = new JobDetailImpl();
	jdi.setName(this.name != null ? this.name : toString());
	jdi.setGroup(this.group);
	jdi.setJobClass(this.jobClass);
	jdi.setJobDataMap(this.jobDataMap);
	jdi.setDurability(this.durability);
	jdi.setRequestsRecovery(this.requestsRecovery);
	jdi.setDescription(this.description);
	this.jobDetail = jdi;
}
 
Example 6
Source File: JobDetailFactoryBean.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.applicationContextJobDataKey != null) {
		if (this.applicationContext == null) {
			throw new IllegalStateException(
				"JobDetailBean needs to be set up in an ApplicationContext " +
				"to be able to handle an 'applicationContextJobDataKey'");
		}
		getJobDataMap().put(this.applicationContextJobDataKey, this.applicationContext);
	}

	JobDetailImpl jdi = new JobDetailImpl();
	jdi.setName(this.name);
	jdi.setGroup(this.group);
	jdi.setJobClass((Class) this.jobClass);
	jdi.setJobDataMap(this.jobDataMap);
	jdi.setDurability(this.durability);
	jdi.setRequestsRecovery(this.requestsRecovery);
	jdi.setDescription(this.description);
	this.jobDetail = jdi;
}
 
Example 7
Source File: JobDetailSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attrMap the attributes that define the job
 * @return JobDetail
 */
public static JobDetail newJobDetail(Map<String, Object> attrMap)
    throws ClassNotFoundException
{
    JobDetailImpl jobDetail = new JobDetailImpl();

    int i = 0;
    jobDetail.setName((String) attrMap.get(ITEM_NAMES[i++]));
    jobDetail.setGroup((String) attrMap.get(ITEM_NAMES[i++]));
    jobDetail.setDescription((String) attrMap.get(ITEM_NAMES[i++]));
    Class<?> jobClass = Class.forName((String) attrMap.get(ITEM_NAMES[i++]));
    @SuppressWarnings("unchecked")
    Class<? extends Job> jobClassTyped = (Class<? extends Job>)jobClass;
    jobDetail.setJobClass(jobClassTyped);
    if(attrMap.containsKey(ITEM_NAMES[i])) {
        @SuppressWarnings("unchecked")
        Map<String, Object> map = (Map<String, Object>)attrMap.get(ITEM_NAMES[i]); 
        jobDetail.setJobDataMap(JobDataMapSupport.newJobDataMap(map));
    }
    i++;
    if(attrMap.containsKey(ITEM_NAMES[i])) {
        jobDetail.setDurability((Boolean) attrMap.get(ITEM_NAMES[i]));
    }
    i++;
    if(attrMap.containsKey(ITEM_NAMES[i])) {
        jobDetail.setRequestsRecovery((Boolean) attrMap.get(ITEM_NAMES[i]));
    }
    i++;
    
    return jobDetail;
}
 
Example 8
Source File: JobDetailFactoryBean.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.applicationContextJobDataKey != null) {
		if (this.applicationContext == null) {
			throw new IllegalStateException(
				"JobDetailBean needs to be set up in an ApplicationContext " +
				"to be able to handle an 'applicationContextJobDataKey'");
		}
		getJobDataMap().put(this.applicationContextJobDataKey, this.applicationContext);
	}

	JobDetailImpl jdi = new JobDetailImpl();
	jdi.setName(this.name);
	jdi.setGroup(this.group);
	jdi.setJobClass((Class) this.jobClass);
	jdi.setJobDataMap(this.jobDataMap);
	jdi.setDurability(this.durability);
	jdi.setRequestsRecovery(this.requestsRecovery);
	jdi.setDescription(this.description);
	this.jobDetail = jdi;
}