Modified ThreadService & Scheduler to allow the web server to pass a delegate service such that all webapps will use one service for each function (reduction in threading and debug complexity).

This commit is contained in:
wcrisman
2014-08-30 15:43:30 -07:00
parent fba1f9f9b3
commit fa572dae03
15 changed files with 324 additions and 73 deletions

View File

@@ -0,0 +1,20 @@
package com.foundation.web;
import com.common.thread.Scheduler.ISchedulerDelegate;
import com.foundation.web.interfaces.IScheduler;
public class SchedulerDelegate implements ISchedulerDelegate {
private IScheduler scheduler;
public SchedulerDelegate(IScheduler scheduler) {
this.scheduler = scheduler;
}//SchedulerDelegate()//
public Object addTask(long intervalTime, Runnable taskHandler, boolean runImmediatly) {
return scheduler.addTask(intervalTime, taskHandler, runImmediatly);
}//addTask()//
public void removeTask(Object task) {
scheduler.removeTask(task);
}//removeTask()//
public boolean isRunning() {
return scheduler.isRunning();
}//isRunning()//
}//SchedulerDelegate//

View File

@@ -0,0 +1,28 @@
package com.foundation.web;
import com.common.thread.ThreadService.IThreadServiceDelegate;
import com.foundation.web.interfaces.IThreadService;
public class ThreadServiceDelegate implements IThreadServiceDelegate {
private IThreadService threadService;
public ThreadServiceDelegate(IThreadService threadService) {
this.threadService = threadService;
}//ThreadServiceDelegate()//
public boolean isRunning() {
return threadService.isRunning();
}//isRunning()//
public void run(Runnable target) {
threadService.run(target);
}//run()//
public void run(Runnable target, int priority) {
threadService.run(target, priority);
}//run()//
public Thread run(Runnable target, boolean queueable) {
threadService.run(target, queueable);
return null;
}//run()//
public Thread run(Runnable target, int priority, boolean queueable) {
threadService.run(target, priority, queueable);
return null;
}//run()//
}//ThreadServiceDelegate//

View File

@@ -207,7 +207,7 @@ public class WebApplication implements IWebApplication, IWebServerApplicationDef
//Start the cycle of creating new keys at a regular interval.//
Scheduler.addTask(keyInterval, new Scheduler.Task() {
public void evaluate() {
public void run() {
cycleKeys();
}//evaluate()//
}, false);
@@ -450,7 +450,7 @@ public WebApplication(String name, WebOptions options, Application application)
//Setup the task to check for stale sessions.//
Scheduler.addTask(options.getSessionCheckInterval(), new Scheduler.Task() {
public void evaluate() {
public void run() {
try {
long currentTime = System.currentTimeMillis();
LiteList removed = new LiteList(10, 100);