本文整理汇总了Java中org.quartz.Scheduler.getJobDetail方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.getJobDetail方法的具体用法?Java Scheduler.getJobDetail怎么用?Java Scheduler.getJobDetail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.Scheduler
的用法示例。
在下文中一共展示了Scheduler.getJobDetail方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrapScheduleJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
private void wrapScheduleJob(ScheduleJob scheduleJob,Scheduler scheduler,JobKey jobKey,Trigger trigger){
try {
scheduleJob.setJobName(jobKey.getName());
scheduleJob.setJobGroup(jobKey.getGroup());
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
ScheduleJob job = (ScheduleJob)jobDetail.getJobDataMap().get("scheduleJob");
scheduleJob.setDesc(job.getDesc());
scheduleJob.setJobId(job.getJobId());
Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
scheduleJob.setJobStatus(triggerState.name());
if(trigger instanceof CronTrigger){
CronTrigger cronTrigger = (CronTrigger)trigger;
String cronExpression = cronTrigger.getCronExpression();
scheduleJob.setCronExpression(cronExpression);
}
} catch (SchedulerException e) {
e.printStackTrace();
}
}
示例2: wrapScheduleJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 封装ScheduleJob对象
*
* @param scheduleJob
* @param scheduler
* @param jobKey
* @param trigger
*/
private void wrapScheduleJob(ScheduleJobEntity scheduleJob,
Scheduler scheduler, JobKey jobKey, Trigger trigger) {
try {
scheduleJob.setJobName(jobKey.getName());
scheduleJob.setJobGroup(jobKey.getGroup());
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
scheduleJob.setJobClass(jobDetail.getJobClass());
scheduleJob.setJobDesc(jobDetail.getDescription());
Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
scheduleJob.setTriggerStatus(triggerState.name());
if (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger) trigger;
TriggerKey triggerKey = cronTrigger.getKey();
scheduleJob.setTriggerName(triggerKey.getName());
scheduleJob.setTriggerGroup(triggerKey.getGroup());
scheduleJob.setNextFireTime(cronTrigger.getNextFireTime());
scheduleJob.setCronExpression(cronTrigger.getCronExpression());
scheduleJob.setStartDate(cronTrigger.getStartTime());
scheduleJob.setEndDate(cronTrigger.getEndTime());
}
} catch (SchedulerException e) {
logger.error("获取触发器状态失败", e);
throw new ServiceException(e);
}
}
示例3: getAllJobsOfScheduler
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 获取scheduler下所有的jobDetail
* @param scheduler
* @return
* @throws SchedulerException
*/
public static List<JobDetail> getAllJobsOfScheduler(Scheduler scheduler) throws SchedulerException {
List<JobDetail> result = new ArrayList<JobDetail>();
List<String> jobGroupNames = scheduler.getJobGroupNames();
for (String groupName : jobGroupNames) {
Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.<JobKey>groupEquals(groupName));
for (JobKey jobKey : jobKeys) {
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
result.add(jobDetail);
}
}
return result;
}
示例4: getJobState
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Get the current state of job
*/
public String getJobState(String jobName) {
System.out.println("JobServiceImpl.getJobState()");
try {
String groupKey = "SampleGroup";
JobKey jobKey = new JobKey(jobName, groupKey);
Scheduler scheduler = schedulerFactoryBean.getScheduler();
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobDetail.getKey());
if(triggers != null && triggers.size() > 0){
for (Trigger trigger : triggers) {
TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
if (TriggerState.PAUSED.equals(triggerState)) {
return "PAUSED";
}else if (TriggerState.BLOCKED.equals(triggerState)) {
return "BLOCKED";
}else if (TriggerState.COMPLETE.equals(triggerState)) {
return "COMPLETE";
}else if (TriggerState.ERROR.equals(triggerState)) {
return "ERROR";
}else if (TriggerState.NONE.equals(triggerState)) {
return "NONE";
}else if (TriggerState.NORMAL.equals(triggerState)) {
return "SCHEDULED";
}
}
}
} catch (SchedulerException e) {
System.out.println("SchedulerException while checking job with name and group exist:"+e.getMessage());
e.printStackTrace();
}
return null;
}
示例5: showScheduledEmails
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Renders a page listing all scheduled emails.
*/
public ActionForward showScheduledEmails(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, SchedulerException {
getUserManagementService();
Scheduler scheduler = getScheduler();
TreeSet<EmailScheduleMessageJobDTO> scheduleList = new TreeSet<EmailScheduleMessageJobDTO>();
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true);
boolean isLessonNotifications = (lessonId != null);
Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true);
if (isLessonNotifications) {
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(),
"show scheduled lesson email notifications", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the lesson");
return null;
}
} else {
if (!getSecurityService().isGroupMonitor(organisationId, getCurrentUser().getUserID(),
"show scheduled course email notifications", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the organisation");
return null;
}
}
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.startsWith(EmailNotificationsAction.TRIGGER_PREFIX_NAME)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
// filter triggers
if (isLessonNotifications) {
Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
if ((jobLessonId == null) || (!lessonId.equals(jobLessonId))) {
continue;
}
} else {
Object jobOrganisationId = jobDataMap.get(AttributeNames.PARAM_ORGANISATION_ID);
if ((jobOrganisationId == null) || (!organisationId.equals(jobOrganisationId))) {
continue;
}
}
Date triggerDate = trigger.getNextFireTime();
String emailBody = WebUtil.convertNewlines((String) jobDataMap.get("emailBody"));
int searchType = (Integer) jobDataMap.get("searchType");
EmailScheduleMessageJobDTO emailScheduleJobDTO = new EmailScheduleMessageJobDTO();
emailScheduleJobDTO.setTriggerName(triggerName);
emailScheduleJobDTO.setTriggerDate(triggerDate);
emailScheduleJobDTO.setEmailBody(emailBody);
emailScheduleJobDTO.setSearchType(searchType);
scheduleList.add(emailScheduleJobDTO);
}
}
request.setAttribute("scheduleList", scheduleList);
request.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId);
request.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, organisationId);
return mapping.findForward("scheduledEmailList");
}
示例6: getEmailProgressDates
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Gets learners or monitors of the lesson and organisation containing it.
*
* @throws SchedulerException
*/
public ActionForward getEmailProgressDates(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, JSONException, SchedulerException {
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), "get class members", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
return null;
}
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
JSONObject responseJSON = new JSONObject();
JSONArray datesJSON = new JSONArray();
// find all the current dates set up to send the emails
Scheduler scheduler = getScheduler();
String triggerPrefix = getTriggerPrefix(lessonId);
SortedSet<Date> currentDatesSet = new TreeSet<Date>();
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.startsWith(triggerPrefix)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
// get only the trigger for the current lesson
Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
if (lessonId.equals(jobLessonId)) {
Date triggerDate = trigger.getNextFireTime();
currentDatesSet.add(triggerDate);
}
}
}
for (Date date : currentDatesSet) {
datesJSON.put(createDateJSON(request.getLocale(), user, date, null));
}
responseJSON.put("dates", datesJSON);
response.setContentType("application/json;charset=utf-8");
response.getWriter().write(responseJSON.toString());
return null;
}
示例7: execute
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Get all waitting queue jobs scheduled in Quartz table and display job name, job start time and description. The
* description will be in format "Lesson Name":"the lesson creator", or "The gate name":"The relatived lesson name".
*
* @param mapping
* The ActionMapping used to select this instance
* @param actionForm
* The optional ActionForm bean for this request (if any)
* @param request
* The HTTP request we are processing
* @param response
* The HTTP response we are creating
*
* @exception IOException
* if an input/output error occurs
* @exception ServletException
* if a servlet exception occurs
*
*/
@SuppressWarnings("unchecked")
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
WebApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(this.getServlet().getServletContext());
Scheduler scheduler = (Scheduler) ctx.getBean("scheduler");
ArrayList<ScheduledJobDTO> jobList = new ArrayList<ScheduledJobDTO>();
try {
Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(Scheduler.DEFAULT_GROUP));
for (JobKey jobKey : jobKeys) {
ScheduledJobDTO jobDto = new ScheduledJobDTO();
JobDetail detail = scheduler.getJobDetail(jobKey);
jobDto.setName(jobKey.getName());
jobDto.setDescription(detail.getDescription());
List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey);
for (Trigger trigger : triggers) {
jobDto.setStartDate(trigger.getStartTime());
jobList.add(jobDto);
}
}
} catch (SchedulerException e) {
ScheduledJobListAction.log.equals("Failed get job names:" + e.getMessage());
}
request.setAttribute("jobList", jobList);
return mapping.findForward("list");
}
示例8: getPlanJobList
import org.quartz.Scheduler; //导入方法依赖的package包/类
@Override
public List<ScheduleJobEntity> getPlanJobList() {
List<ScheduleJobEntity> jobList = new ArrayList<>();
Scheduler scheduler = schedulerFactoryBean.getScheduler();
try {
GroupMatcher<JobKey> matcher = GroupMatcher.anyJobGroup();
Set<JobKey> jobKeySet = scheduler.getJobKeys(matcher);
for (JobKey jobKey : jobKeySet) {
/*
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
for (Trigger trigger : triggers) {
ScheduleJobEntity scheduleJob = new ScheduleJobEntity();
this.wrapScheduleJob(scheduleJob, scheduler, jobKey, trigger);
jobList.add(scheduleJob);
}
*/
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
ScheduleJobEntity scheduleJob = new ScheduleJobEntity();
scheduleJob.setJobName(jobKey.getName());
scheduleJob.setJobGroup(jobKey.getGroup());
scheduleJob.setJobClassName(jobDetail.getJobClass().getName());
scheduleJob.setJobDesc(jobDetail.getDescription());
jobList.add(scheduleJob);
}
} catch (SchedulerException e) {
logger.error("获取计划任务列表失败", e);
throw new ServiceException("获取计划任务列表失败", e);
}
return jobList;
}
示例9: doHandleRequest
import org.quartz.Scheduler; //导入方法依赖的package包/类
@Override
protected ModelAndView doHandleRequest(HttpServletRequest req,HttpServletResponse res) throws Exception {
SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Scheduler scheduler=instanceDetection.getScheduler();
StringBuffer sb=new StringBuffer();
sb.append("<strong>Status</strong>:");
if(scheduler.isInStandbyMode()){
sb.append("Standby");
}
if(scheduler.isShutdown()){
sb.append("Shutdown");
}
if(scheduler.isStarted()){
sb.append("Started");
}
sb.append("<br>");
for (String groupName : scheduler.getJobGroupNames()) {
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
JobDetail jobDetail=scheduler.getJobDetail(jobKey);
sb.append("<strong>JobClass:</strong>");
sb.append(jobDetail.getJobClass().getName());
Trigger trigger=scheduler.getTriggersOfJob(jobDetail.getKey()).get(0);
sb.append("<br><strong>PreviousFireDate:</strong>");
if(trigger.getPreviousFireTime()!=null){
sb.append(sd.format(trigger.getPreviousFireTime()));
}
sb.append("<br><strong>NextFireDate:</strong>");
if(sd.format(trigger.getNextFireTime())!=null){
sb.append(sd.format(trigger.getNextFireTime()));
}
if(trigger instanceof CronTriggerImpl){
CronTriggerImpl cron=(CronTriggerImpl)trigger;
sb.append("<br><strong>CronExpression:</strong>");
sb.append(cron.getCronExpression());
}
}
}
res.setContentType("text/html; charset=utf-8");
PrintWriter pw=res.getWriter();
pw.write(sb.toString());
pw.flush();
pw.close();
return null;
}
示例10: jobs
import org.quartz.Scheduler; //导入方法依赖的package包/类
@Override
public Collection<JobDetailInfo> jobs() throws SchedulerException {
List<JobDetailInfo> jobDetailInfoes = new ArrayList<>();
Scheduler scheduler = schedulerFactoryBean.getScheduler();
GroupMatcher<JobKey> jobMatcher = GroupMatcher.anyJobGroup();
Set<JobKey> jobKeys = scheduler.getJobKeys(jobMatcher);
for (JobKey jobKey : jobKeys) {
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
for (Trigger trigger : triggers) {
JobDetailInfo jobDetailInfo = new JobDetailInfo();
jobDetailInfo.setJobName(jobKey.getName());
jobDetailInfo.setJobGroupName(jobKey.getGroup());
jobDetailInfo.setJobDescription(jobDetail.getDescription());
jobDetailInfo.setJobClassName(jobDetail.getJobClass().getName());
jobDetailInfo.setTriggerName(trigger.getKey().getName());
jobDetailInfo.setTriggerGroupName(trigger.getKey().getGroup());
jobDetailInfo.setTriggerDescription(trigger.getDescription());
CronTrigger cronTrigger = (CronTrigger) trigger;
jobDetailInfo.setTriggerCronExpression(cronTrigger.getCronExpression());
jobDetailInfo.setStartTime(new DateTime(trigger.getStartTime()).toString("yyyy-MM-dd HH:mm:ss"));
jobDetailInfo.setEndTime(new DateTime(trigger.getEndTime()).toString("yyyy-MM-dd HH:mm:ss"));
jobDetailInfo
.setFinalFireTime(new DateTime(trigger.getFinalFireTime()).toString("yyyy-MM-dd HH:mm:ss"));
jobDetailInfo.setPreviousFireTime(
new DateTime(trigger.getPreviousFireTime()).toString("yyyy-MM-dd HH:mm:ss"));
jobDetailInfo.setNextFireTime(new DateTime(trigger.getNextFireTime()).toString("yyyy-MM-dd HH:mm:ss"));
jobDetailInfo.setMisfireInstruction(trigger.getMisfireInstruction());
TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
jobDetailInfo.setJobState(triggerState.name());
jobDetailInfoes.add(jobDetailInfo);
}
}
return jobDetailInfoes;
}
示例11: deleteNotification
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Delete a scheduled emails.
*
* @throws JSONException
*/
public ActionForward deleteNotification(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, SchedulerException, JSONException {
String inputTriggerName = WebUtil.readStrParam(request, "triggerName");
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true);
Integer userId = getCurrentUser().getUserID();
boolean isLessonNotifications = (lessonId != null);
Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true);
IMonitoringService monitoringService = MonitoringServiceProxy
.getMonitoringService(getServlet().getServletContext());
getUserManagementService();
Scheduler scheduler = getScheduler();
JSONObject jsonObject = new JSONObject();
String error = null;
try {
// if this method throws an Exception, there will be no deleteNotification=true in the JSON reply
if (isLessonNotifications) {
if (!getSecurityService().isLessonMonitor(lessonId, userId, "show scheduled lesson email notifications",
false)) {
error = "Unable to delete notification: the user is not a monitor in the lesson";
}
} else {
if (!getSecurityService().isGroupMonitor(organisationId, userId,
"show scheduled course course email notifications", false)) {
error = "Unable to delete notification: the user is not a monitor in the organisation";
}
}
if (error == null) {
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.equals(inputTriggerName)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobKey jobKey = trigger.getJobKey();
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
getAuditService().log(MonitoringConstants.MONITORING_MODULE_NAME,
"Deleting unsent scheduled notification " + jobKey + " "
+ jobDataMap.getString("emailBody"));
scheduler.deleteJob(jobKey);
}
}
}
} catch (Exception e) {
String[] msg = new String[1];
msg[0] = e.getMessage();
error = monitoringService.getMessageService().getMessage("error.system.error", msg);
}
jsonObject.put("deleteNotification", error == null ? "true" : error);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(jsonObject);
return null;
}
示例12: loadScheduerInfo
import org.quartz.Scheduler; //导入方法依赖的package包/类
@DataProvider
public SchedulerInfo loadScheduerInfo() throws Exception{
SchedulerInfo info=new SchedulerInfo();
info.setRunJob(schedulerService.isRunJobInCurrentInstance());
Scheduler scheduler=schedulerService.getCurrentScheduler();
if(scheduler!=null){
if(scheduler.isStarted()){
info.setState(SchedulerState.started);
}else if(scheduler.isShutdown()){
info.setState(SchedulerState.shutdown);
}else if(scheduler.isInStandbyMode()){
info.setState(SchedulerState.standby);
}
info.setJobInstanceName(schedulerService.getJobInstanceName());
List<JobInfo> jobs=new ArrayList<JobInfo>();
for (String groupName : scheduler.getJobGroupNames()) {
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
JobInfo jobInfo=new JobInfo();
JobDetail jobDetail=scheduler.getJobDetail(jobKey);
if(jobDetail instanceof SpringBeanJobExecutorDetail){
SpringBeanJobExecutorDetail springBeanDetail=(SpringBeanJobExecutorDetail)jobDetail;
jobInfo.setTargetJobInfo("SpringBean:"+springBeanDetail.getTargetJobBeanId());
jobInfo.setType(JobType.definition);
}else if(jobDetail instanceof ScanJobExecutorDetail){
jobInfo.setType(JobType.scan);
jobInfo.setTargetJobInfo(jobDetail.getJobClass().getName());
}
Trigger trigger=scheduler.getTriggersOfJob(jobKey).get(0);
jobInfo.setName(jobDetail.getKey().getName());
jobInfo.setGroup(jobDetail.getKey().getGroup());
jobInfo.setNextFireDate(trigger.getNextFireTime());
jobInfo.setPreviousFireDate(trigger.getPreviousFireTime());
if(trigger instanceof CronTriggerImpl){
CronTriggerImpl cron=(CronTriggerImpl)trigger;
jobInfo.setTriggerInfo("Cron表达式类型触发器["+cron.getCronExpression()+"]");
}else{
jobInfo.setTriggerInfo("触发器类型:"+trigger.getClass());
}
jobs.add(jobInfo);
}
info.setJobs(jobs);
}
}
return info;
}
示例13: getJobFromScheduler
import org.quartz.Scheduler; //导入方法依赖的package包/类
public JobDetail getJobFromScheduler(String jobDefId,String companyId) throws SchedulerException {
Scheduler scheduler=schedulerService.retrieveScheduler();
return scheduler.getJobDetail(new JobKey(JOB_PREFIX+jobDefId,companyId));
}
示例14: getJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 获取job信息
* @param scheduler
* @param jobName
* @param jobGroup
* @return
* @throws SchedulerException
*/
public static JobDetail getJob(Scheduler scheduler, String jobName, String jobGroup) throws SchedulerException {
JobKey jobKey = getJobKey(jobName, jobGroup);
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
return jobDetail;
}