?
Solved

Quartz Scheduler - How to get cron expression given job name and group name?

Posted on 2010-09-03
4
Medium Priority
?
1,224 Views
Last Modified: 2012-06-27
Hi,

I'm using Quartz Scheduler v.1.8.0.

How do I get the cron expression which was assigned/attached to a Job and scheduled using CronTrigger?  I have the job name and group name in this case.  Though many Triggers can point to the same Job, in my case it is only one.

There is a method available in Scheduler class, Scheduler.getTriggersOfJob(jobName, groupName), but it returns only Trigger array.

NOTE: Class CronTrigger extends Trigger
0
Comment
Question by:Zoniac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
gremwell earned 300 total points
ID: 33602377
If there only one trigger per job, I would expect the array returned by getTriggersOfJob() contain one entry only. You can probably cast it (the first element of the array, not the array itself) to CronTrigger and invoke CronTrigger's getCronExpression() method.
0
 
LVL 1

Author Comment

by:Zoniac
ID: 33602559
> I would expect the array returned by getTriggersOfJob() contain one entry only

Yes, you're right.  In my case, it is only one trigger per job.
0
 
LVL 1

Author Comment

by:Zoniac
ID: 33602565
> You can probably cast it (the first element of the array, not the array  itself) to CronTrigger and invoke CronTrigger's getCronExpression()  method.

Yes, it works.

Code example shown below:

Trigger[] triggers = scheduler.getTriggersOfJob(jobName, groupName);
for (Trigger trigger : triggers) {
    if (trigger instanceof CronTrigger) {
        CronTrigger cronTrigger = (CronTrigger) trigger;
        String cronExpr = cronTrigger.getCronExpression();
    }
}

Open in new window

0
 
LVL 1

Author Closing Comment

by:Zoniac
ID: 33602631
Solution arrived.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question