There is a tool called JDRING
URL: http://webtools.dyade.fr/jdring/
Below is an article that was published by builder.com about JDRING. The
article includes enough information to get it up and running without
much effort.
SET CRON-LIKE ALARM SCHEDULING WITH JDRING
The UNIX operating system uses the cron daemon to run scripts at certain
times on designated days. Java Development Kit (JDK) 1.3's
java.util.Timer class allows developers to set up tasks to fire every N
milliseconds,
but there's no cron-like structure to specify a particular time of the
day or week.
That gap is currently filled by the JDring package, a Java cron-like
alarm scheduler by Olivier Dedieu. Here are the components within the
JDring
zip file:
* Source code: This isn't critical to keep and can be discarded.
* Javadoc documents: Put these in your docs directory.
* Jar file: This file contains the essential classes that need to be
placed in your classpath.
There are two parts to using JDring. The first requires that you create
an AlarmListener, which is an interface with one method to fulfill:
void handleAlarm(AlarmEntry entry);
The AlarmEntry argument provides details about the time for which the
alarm is set. Here's a simple code example of the AlarmListener:
import com.jalios.jdring.AlarmEntry;
import com.jalios.jdring.AlarmListener;
public class Buzzing implements AlarmListener {
private String buzz;
public Buzzing(String buzz) {
this.buzz = buzz;
}
public void handleAlarm(AlarmEntry entry) {
System.err.println("BUUUZZZZZZZZ");
System.err.println(buzz);
}
}
The second part to using JDring involves telling a central manager when
the AlarmListener should go off. The manager is an instance of
AlarmManager, and it has an empty constructor. Invoking the alarm for a
particular
time is similar to cron, such as:
AlarmManager.addAlarm(minute, hour, day of month, month, day of week,
year,
AlarmListener)
The following sample code shows the alarm set to go off at 20 minutes
past every hour:
import com.jalios.jdring.AlarmManager;
import com.jalios.jdring.PastDateException;
public class SetAlarm {
static public void main(String[ ] args) {
AlarmManager mgr = new AlarmManager( );
mgr.addAlarm(20, -1, -1, -1, -1, -1, new Buzzing( ));
}
}
This example demonstrates the alarm set for 5 P.M. every Friday:
manager.addAlarm(00, 17, -1, -1, Calendar.FRIDAY, -1, new
Buzzing());
// java.util.Calendar
JDring can also be used to remember an anniversary, such as:
manager.addAlarm(00, 12, 20, Calendar.MARCH, -1, -1,
new Buzzing("Remember the anniversary tomorrow!") );
Regards,
Don Keeting
-----Original Message-----
From: wbchmura [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 03, 2002 4:20 PM
To: struts-user
Cc: wbchmura
Subject: How to implement a schedule in my application
Hi All,
I want to implement a schedular in my application. Basically I want to
be able to specifiy events in the application and have it perform
predetermined tasks (such as e-mail a user). I can do all of that, but
I am not sure how to handle the... is it time to do something?
I can make a cron job and go at the database from outside every five
minutes or something... Is that the best way?
Other things like database archiving, status reports, etc...
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>