本文整理匯總了Java中org.quartz.JobDataMap.getLong方法的典型用法代碼示例。如果您正苦於以下問題:Java JobDataMap.getLong方法的具體用法?Java JobDataMap.getLong怎麽用?Java JobDataMap.getLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.quartz.JobDataMap
的用法示例。
在下文中一共展示了JobDataMap.getLong方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.quartz.JobDataMap; //導入方法依賴的package包/類
/**
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
*/
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap mergedJobDataMap = context.getMergedJobDataMap();
SchedulerContext schedCtxt = null;
try {
schedCtxt = context.getScheduler().getContext();
} catch (SchedulerException e) {
throw new JobExecutionException("Error obtaining scheduler context.", e, false);
}
String fileName = mergedJobDataMap.getString(FILE_NAME);
String listenerName = mergedJobDataMap.getString(FILE_SCAN_LISTENER_NAME);
if(fileName == null) {
throw new JobExecutionException("Required parameter '" +
FILE_NAME + "' not found in merged JobDataMap");
}
if(listenerName == null) {
throw new JobExecutionException("Required parameter '" +
FILE_SCAN_LISTENER_NAME + "' not found in merged JobDataMap");
}
FileScanListener listener = (FileScanListener)schedCtxt.get(listenerName);
if(listener == null) {
throw new JobExecutionException("FileScanListener named '" +
listenerName + "' not found in SchedulerContext");
}
long lastDate = -1;
if(mergedJobDataMap.containsKey(LAST_MODIFIED_TIME)) {
lastDate = mergedJobDataMap.getLong(LAST_MODIFIED_TIME);
}
long newDate = getLastModifiedDate(fileName);
if(newDate < 0) {
log.warn("File '"+fileName+"' does not exist.");
return;
}
if(lastDate > 0 && (newDate != lastDate)) {
// notify call back...
log.info("File '"+fileName+"' updated, notifying listener.");
listener.fileUpdated(fileName);
} else if (log.isDebugEnabled()) {
log.debug("File '"+fileName+"' unchanged.");
}
// It is the JobDataMap on the JobDetail which is actually stateful
context.getJobDetail().getJobDataMap().put(LAST_MODIFIED_TIME, newDate);
}