Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
 
 
Search All Tutorials
  

 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 
Tutorials
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

More About Simple Trigger

                         

Simple trigger can be used to one shot execution or fire a job and in other words, we can say that just a single execution of job to the specified time. Sometimes, we wish to execute or fire a job at the specified time that has till 'N' repetition times with delay between 'T' executions of jobs that means if you need to have a job execute exactly once at a specific time, or at a specific moment in time that is followed by repeats at a specified time interval.

The SimpleTrigger properties contains: a start-time and end-time, a repeat count and a repeat interval. The repeat count properties can be zero, a positive integer or the constant value SimpleTrigger.REPEAT_INDEFINITELY. The repeat interval property must be zero or a positive long value that represents a number of milliseconds. The end-time property over-rides the repeat count property that can be used for creating a trigger which fires every some specified time (20 seconds). It has to compute the number of times that would be repeated between the start-time and end-time, if we want to specify the end-time then we can use a repeat count of REPEAT_INDEFINITELY.

We are going to implement a SimpleTrigger constructor to following types:

public SimpleTrigger(String name, String group, Date startTime, Date endTime, int repeatCount, long repeatInterval);
     
This is the constructor of java.org.quartz.SimpleTrigger class. Which fires or executes at the specified time and repeat at the specified number of times. It takes following arguments like this:

            name: This is the name of Simple Trigger.
            group:
This is the name of scheduler group.
            startTime: 
This is the time for firing or executing the Trigger.
            endTime:
This is the time for the Trigger to drop repeat firing or executing. 
            repeatCount:
This is the number of repeat firing or executing the Trigger by using the REPEAT_INDEFINITELY  for no any foundation of time.
            repeatInterval:
This is the time (milliseconds) for stopping or pausing the repeat firing.

There are following examples for implementing the SimpleTrigger:

1. Example SimpleTrigger : Create a simple trigger which fires exactly once, 20 seconds from now:

long startTime = System.currentTimeMillis() + (20L*1000L);

SimpleTrigger strigger  =  new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, new Date(startTime), null, 0, 0L);

2. Example SimpleTrigger : Create a simple trigger that fires quickly and repeats every 20 seconds:

SimpleTrigger strigger  =  new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, 20L * 1000L);

3. Example SimpleTrigger: Create a Simple Trigger that fires quickly and repeats every 10 seconds until 50 seconds from now:

long endTime = System.currentTimeMillis() + (50L * 1000L);

SimpleTrigger strigger  =  new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, new Date(), new Date(endTime), SimpleTrigger.REPEAT_INDEFINITELY, 10L * 1000L);

4. Example SimpleTrigger: Create a Simple Trigger that fires on February 19 of the year 2007 at accurately 9:15 am, and repeats 10 times with 20 seconds delay between each firing.

java.util.Calendar cal = new java.util.GregorianCalendar(2007,cal.FEB, 19);
cal.set(cal.HOUR, 9);
cal.set(cal.MINUTE, 15);
cal.set(cal.SECOND, 0);
cal.set(cal.MILLISECOND, 0);

Data startTime = cal.getTime();

SimpleTrigger trigger = new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, startTime, 10, 20L*1000L);

Simple Trigger Misfire Instructions

When the misfire instruction occurs then what should to do the Quartz. There are following misfire instructions to use for informing the Quartz.

    MISFIRE_INSTRUCTION_FIRE_NOW

     MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT

   MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT

   MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT

   MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_EXISTING_COUNT

Here is the also mis-fire instruction that have used for all trigger types:

   Trigger.MISFIRE_INSTRUCTION_SMART_POLICY

When we will use the "smart policy" misfire instruction with the triggers then the SimpleTrigger determine between its various types of mis-fire instructions that depends upon the configuration and state of the specified SimpleTrigger instance. The JavaDOC has the SimpleTrigger.updateAfterMisfire() method that describes the brief description of this dynamic behavior.

                         

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (post your own) View All Comments Latest 10 Comments:

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.