[Red5commits] [2233] Added patch from Carl to allow a quartz task with an initial delay
pgregoire
luke at codegent.com
Sun Aug 19 21:30:17 PDT 2007
Added patch from Carl to allow a quartz task with an initial delay
Timestamp: 08/19/07 23:20:34 EST (less than one hour ago)
Change: 2233
Author: pgregoire
Files (see diff or trac for details):
java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java
java/server/trunk/src/org/red5/server/api/scheduling/ISchedulingService.java
java/server/trunk/src/org/red5/server/scheduling/QuartzSchedulingService.java
Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/2233
Index: /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java
===================================================================
--- /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java (revision 1947)
+++ /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java (revision 2233)
@@ -904,4 +904,24 @@
return service.addScheduledOnceJob(date, job);
}
+
+ /**
+ * Adds a scheduled job which starts after the specified
+ * delay period and fires periodically.
+ *
+ * @param interval
+ * time in milliseconds between two notifications of the job
+ * @param job
+ * the job to trigger periodically
+ * @param delay
+ * time in milliseconds to pass before first execution.
+ * @return
+ * the name of the scheduled job
+ */
+ public String addScheduledJobAfterDelay(int interval, IScheduledJob job, int delay) {
+ ISchedulingService service = (ISchedulingService) getScopeService(
+ scope, ISchedulingService.class, QuartzSchedulingService.class,
+ false);
+ return service.addScheduledJobAfterDelay(interval, job, delay);
+ }
/**
@@ -1039,5 +1059,6 @@
* Cleans up ghost connections
*/
- protected void killGhostConnections() {
+ @SuppressWarnings("unchecked")
+ protected void killGhostConnections() {
Iterator iter = getConnectionsIter();
while(iter.hasNext()) {
Index: /java/server/trunk/src/org/red5/server/scheduling/QuartzSchedulingService.java
===================================================================
--- /java/server/trunk/src/org/red5/server/scheduling/QuartzSchedulingService.java (revision 1993)
+++ /java/server/trunk/src/org/red5/server/scheduling/QuartzSchedulingService.java (revision 2233)
@@ -101,4 +101,18 @@
+ timeDelta), job);
}
+
+ /** {@inheritDoc} */
+ public String addScheduledJobAfterDelay(int interval, IScheduledJob job, int delay) {
+ String result = getJobName();
+ // Initialize the start time to now and add the delay.
+ long startTime = System.currentTimeMillis() + delay;
+ // Create trigger that fires indefinitely every <internval> milliseconds.
+ SimpleTrigger trigger = new SimpleTrigger("Trigger_" + result,
+ null, new Date(startTime), null, SimpleTrigger.REPEAT_INDEFINITELY, interval);
+ // Schedule the job with Quartz.
+ scheduleJob(result, trigger, job);
+ // Return the job name.
+ return result;
+ }
/**
Index: /java/server/trunk/src/org/red5/server/api/scheduling/ISchedulingService.java
===================================================================
--- /java/server/trunk/src/org/red5/server/api/scheduling/ISchedulingService.java (revision 1698)
+++ /java/server/trunk/src/org/red5/server/api/scheduling/ISchedulingService.java (revision 2233)
@@ -71,4 +71,18 @@
*/
public String addScheduledOnceJob(Date date, IScheduledJob job);
+
+ /**
+ * Schedule a job for periodic execution which will start after the specifed delay.
+ *
+ * @param interval
+ * time in milliseconds between two notifications of the job
+ * @param job
+ * the job to trigger periodically
+ * @param delay
+ * time in milliseconds to pass before first execution.
+ * @return
+ * the name of the scheduled job
+ */
+ public String addScheduledJobAfterDelay(int interval, IScheduledJob job, int delay);
/**
Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.
More information about the Red5commits
mailing list