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:
@@ -0,0 +1,25 @@
|
||||
package com.foundation.web.application;
|
||||
|
||||
import com.common.thread.Scheduler;
|
||||
import com.foundation.web.interfaces.IScheduler;
|
||||
|
||||
/**
|
||||
* Wrappers the web server's framework scheduler such that all webapps can use the same scheduler.
|
||||
*/
|
||||
public class SchedulerWrapper implements IScheduler {
|
||||
public SchedulerWrapper() {
|
||||
}//SchedulerWrapper()//
|
||||
public Object addTask(long intervalTime, final Runnable taskHandler, boolean runImmediatly) {
|
||||
return Scheduler.addTask(intervalTime, new Scheduler.Task() {
|
||||
public void run() {
|
||||
taskHandler.run();
|
||||
}//run()//
|
||||
}, runImmediatly);
|
||||
}//addTask()//
|
||||
public void removeTask(Object task) {
|
||||
Scheduler.removeTask(task);
|
||||
}//removeTask()//
|
||||
public boolean isRunning() {
|
||||
return Scheduler.isRunning();
|
||||
}//isRunning()//
|
||||
}//SchedulerWrapper//
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.foundation.web.application;
|
||||
|
||||
import com.common.thread.ThreadService;
|
||||
import com.foundation.web.interfaces.IThreadService;
|
||||
|
||||
/**
|
||||
* Wrappers the web server's framework thread service such that all webapps can use the same scheduler.
|
||||
*/
|
||||
public class ThreadServiceWrapper implements IThreadService {
|
||||
public ThreadServiceWrapper() {
|
||||
}//ThreadServiceWrapper()//
|
||||
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) {
|
||||
return ThreadService.run(target, queueable);
|
||||
}//run()//
|
||||
public Thread run(Runnable target, int priority, boolean queueable) {
|
||||
return ThreadService.run(target, priority, queueable);
|
||||
}//run()//
|
||||
}//ThreadServiceWrapper//
|
||||
@@ -1130,7 +1130,7 @@ protected void loadWebApplications(final WebappBundle metadata) throws IOExcepti
|
||||
IWebApplicationFactory webApplicationFactory = (IWebApplicationFactory) cls.newInstance();
|
||||
IAppLog appLog = new AppLog();
|
||||
|
||||
metadata.setWebApplications(webApplicationFactory.createWebApplications(metadata.getBaseDirectory(), externalApp == null || externalApp.externalBaseDirectory == null ? null : new File(externalApp.externalBaseDirectory), externalApp == null || externalApp.cacheBaseDirectory == null ? null : new File(externalApp.cacheBaseDirectory), appLog, externalApp == null ? new Properties(System.getProperties()) : externalApp.properties));
|
||||
metadata.setWebApplications(webApplicationFactory.createWebApplications(metadata.getBaseDirectory(), externalApp == null || externalApp.externalBaseDirectory == null ? null : new File(externalApp.externalBaseDirectory), externalApp == null || externalApp.cacheBaseDirectory == null ? null : new File(externalApp.cacheBaseDirectory), appLog, new ThreadServiceWrapper(), new SchedulerWrapper(), externalApp == null ? new Properties(System.getProperties()) : externalApp.properties));
|
||||
metadata.setWebApplicationFactory(webApplicationFactory);
|
||||
|
||||
if(metadata.getWebApplications() == null) {
|
||||
|
||||
Reference in New Issue
Block a user