Java Code Examples for org.quartz.JobDetail#getName()

The following examples show how to use org.quartz.JobDetail#getName() . 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: SchedulerServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Builds the job list xml string.
 * 
 * @param toReturn the to return
 * 
 * @return the string
 * 
 * @throws SourceBeanException the source bean exception
 */
public  String buildJobListXmlString(List toReturn) throws SourceBeanException {
	StringBuffer buffer = new StringBuffer("<ROWS>");
	Iterator it = toReturn.iterator();
	while (it.hasNext()) {
		JobDetail job = (JobDetail) it.next();
		String jobName = job.getName();
		String jobGroupName = job.getGroup();
		String jobDescription = job.getDescription();
		String jobClassName = job.getJobClass().getName();
		String jobDurability = job.isDurable() ? "true" : "false";
		String jobRequestRecovery = job.requestsRecovery() ? "true" : "false";
		String jobVolatility = job.isVolatile() ? "true" : "false";
		buffer.append("<ROW ");
		buffer.append(" jobName=\"" + (jobName != null ? jobName : "") + "\"");
		buffer.append(" jobGroupName=\"" + (jobGroupName != null ? jobGroupName : "") + "\"");
		buffer.append(" jobDescription=\"" + (jobDescription != null ? jobDescription : "") + "\"");
		buffer.append(" jobClass=\"" + (jobClassName != null ? jobClassName : "") + "\"");
		buffer.append(" jobDurability=\"" + jobDurability + "\"");
		buffer.append(" jobRequestRecovery=\"" + jobRequestRecovery + "\"");
		buffer.append(" jobVolatility=\"" + jobVolatility + "\"");
		buffer.append(" />");
	}
	buffer.append("</ROWS>");
	return buffer.toString();
}
 
Example 2
Source File: JobDetailSupport.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/**
 * @param jobDetail
 * @return CompositeData
 */
public static CompositeData toCompositeData(JobDetail jobDetail) {
	try {
		return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
				new Object[] {
						jobDetail.getName(),
						jobDetail.getGroup(),
						jobDetail.getDescription(),
						jobDetail.getJobClass().getName(),
						JobDataMapSupport.toTabularData(jobDetail
								.getJobDataMap()), jobDetail.isVolatile(),
						jobDetail.isDurable(),
						jobDetail.requestsRecovery(), });
	} catch (OpenDataException e) {
		throw new RuntimeException(e);
	}
}
 
Example 3
Source File: SchedulerServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
protected boolean shouldScheduleJob(JobDetail jobDetail) {
    try {
        if (scheduler.getTriggersOfJob(jobDetail.getName(), SCHEDULED_GROUP).length > 0) {
            return false;
        }
        for (String dependencyJobName : getJobDependencies(jobDetail.getName()).keySet()) {
            JobDetail dependencyJobDetail = getScheduledJobDetail(dependencyJobName);
            if ( dependencyJobDetail == null ) {
                LOG.error( "Unable to get JobDetail for dependency of " + jobDetail.getName() + " : " + dependencyJobName );
                return false;
            }
            if (!isDependencySatisfiedPositively(jobDetail, dependencyJobDetail)) {
                return false;
            }
        }
    }
    catch (SchedulerException se) {
        throw new RuntimeException("Caught scheduler exception while determining whether to schedule job: " + jobDetail.getName(), se);
    }
    return true;
}
 
Example 4
Source File: CmsTaskAct.java    From Lottery with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 开始任务调度
 * @param task 任务
 * @param taskCode 任务名称
 * @throws ParseException
 * @throws SchedulerException
 * @throws ClassNotFoundException
 */
private void startTask(CmsTask task,String taskCode) throws ParseException, SchedulerException, ClassNotFoundException{
	String cronExpress=manager.getCronExpressionFromDB(task.getId());
	System.out.println(cronExpress);
	if(cronExpress.indexOf("null")==-1){
		JobDetail jobDetail = new JobDetail();
		jobDetail.setName(taskCode);
		jobDetail.setGroup(Scheduler.DEFAULT_GROUP);
		jobDetail.setJobClass(getClassByTask(task.getJobClass()));
		//任务需要参数attr属性 
		jobDetail.setJobDataMap(getJobDataMap(task.getAttr()));
		CronTrigger cronTrigger = new CronTrigger("cron_" + taskCode,Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP);
		cronTrigger.setCronExpression(cronExpress);
		scheduler.scheduleJob(jobDetail, cronTrigger); 
	}
}
 
Example 5
Source File: SchedulerServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void addScheduled(JobDetail job) {
    try {
        job.setGroup(SCHEDULED_GROUP);
        scheduler.addJob(job, true);
    }
    catch (SchedulerException ex) {
        throw new RuntimeException("Unable to add job to scheduled group: " + job.getName(), ex);
    }
}
 
Example 6
Source File: SchedulerServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void addUnscheduled(JobDetail job) {
    try {
        job.setGroup(UNSCHEDULED_GROUP);
        scheduler.addJob(job, true);
    }
    catch (SchedulerException ex) {
        throw new RuntimeException("Unable to add job to unscheduled group: " + job.getName(), ex);
    }
}
 
Example 7
Source File: SchedulerServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Serialize job detail.
 * 
 * @param job the job
 * 
 * @return the string
 * 
 * @throws SourceBeanException the source bean exception
 */
public  String serializeJobDetail(JobDetail job) throws SourceBeanException {
	StringBuffer buffer = new StringBuffer("<JOB_DETAIL ");
	String jobName = job.getName();
	String jobGroupName = job.getGroup();
	String jobDescription = job.getDescription();
	String jobClassName = job.getJobClass().getName();
	String jobDurability = job.isDurable() ? "true" : "false";
	String jobRequestRecovery = job.requestsRecovery() ? "true" : "false";
	String jobVolatility = job.isVolatile() ? "true" : "false";
	JobDataMap jobDataMap = job.getJobDataMap();
	buffer.append(" jobName=\"" + (jobName != null ? jobName : "") + "\"");
	buffer.append(" jobGroupName=\"" + (jobGroupName != null ? jobGroupName : "") + "\"");
	buffer.append(" jobDescription=\"" + (jobDescription != null ? jobDescription : "") + "\"");
	buffer.append(" jobClass=\"" + (jobClassName != null ? jobClassName : "") + "\"");
	buffer.append(" jobDurability=\"" + jobDurability + "\"");
	buffer.append(" jobRequestRecovery=\"" + jobRequestRecovery + "\"");
	buffer.append(" jobVolatility=\"" + jobVolatility + "\"");
	buffer.append(" >");
	buffer.append("<JOB_PARAMETERS>");
	if (jobDataMap != null && !jobDataMap.isEmpty()) {
		String[] keys = jobDataMap.getKeys();
		if (keys != null && keys.length > 0) {
			for (int i = 0; i < keys.length; i++) {
				buffer.append("<JOB_PARAMETER ");
				String key = keys[i];
				String value = jobDataMap.getString(key);
				if (value == null) {
					SpagoBITracer.warning("SCHEDULER", this.getClass().getName(), "loadJobDetailIntoResponse", 
					"Job parameter '" + key + "' has no String value!!");	
				}
				buffer.append(" name=\"" + key + "\"");
				buffer.append(" value=\"" + value + "\"");
				buffer.append(" />");
			}
		}
	}
	buffer.append("</JOB_PARAMETERS>");
	buffer.append("</JOB_DETAIL>");
	return buffer.toString();
}
 
Example 8
Source File: RAMJobStore.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
static String getJobNameKey(JobDetail jobDetail) {
    return jobDetail.getGroup() + "_$x$x$_" + jobDetail.getName();
}
 
Example 9
Source File: QuartzAdapter.java    From javamelody with Apache License 2.0 4 votes vote down vote up
String getJobName(JobDetail jobDetail) {
	return jobDetail.getName();
}