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,22 @@
package com.foundation.web.interfaces;
public interface IScheduler {
/**
* Adds a task to be executed at regular intervals.
* @param intervalTime long The amount of time in milliseconds between handler calls. How accurate the scheduler is depends on its' interval time.
* @param taskHandler Task The handler to be called at <code>intervalTime</code> intervals. If the handler takes more than a few milliseconds to complete it should start a thread of execution.
* @param runImmediatly boolean A flag that lets the scheduler know that the task should be run for the first time as soon as possible.
* @return A task reference that should be used to remove the task handler from the scheduled task list.
*/
public Object addTask(long intervalTime, Runnable taskHandler, boolean runImmediatly);
/**
* Removes a task handler so that the task will no longer be scheduled to execute.
* @param task The task to remove.
*/
public void removeTask(Object task);
/**
* Gets the running status of the scheduler.
* @return True if the scheduler is running.
*/
public boolean isRunning();
}//IScheduler//

View File

@@ -0,0 +1,39 @@
package com.foundation.web.interfaces;
public interface IThreadService {
/**
* Gets the status of the thread service.
* @return True if the thread service is running.
*/
public boolean isRunning();
/**
* Runs the target within a thread that can be reused.
* <p>CAUTION: Such methods as Thread.join() will *NOT* work properly!</p>
* @param target The target runnable given to the thread.
*/
public void run(Runnable target);
/**
* Runs the target within a thread that can be reused.
* <p>CAUTION: Such methods as Thread.join() will *NOT* work properly!</p>
* @param target The target runnable given to the thread.
* @param priority The thread priority.
*/
public void run(Runnable target, int priority);
/**
* Runs the target within a thread that can be reused.
* <p>CAUTION: Such methods as Thread.join() will *NOT* work properly!</p>
* @param target The target runnable given to the thread.
* @param queueable Whether the thread request can be queued if there are not threads immediatly available. If the thread request is queued then the return value will be null.
* @return The reference to the thread executing the target, or null if the target was queued until a thread becomes available.
*/
public Thread run(Runnable target, boolean queueable);
/**
* Runs the target within a thread that can be reused.
* <p>CAUTION: Such methods as Thread.join() will *NOT* work properly!</p>
* @param target The target runnable given to the thread.
* @param priority The thread priority.
* @param queueable Whether the thread request can be queued if there are not threads immediatly available. If the thread request is queued then the return value will be null.
* @return The reference to the thread executing the target, or null if the target was queued until a thread becomes available.
*/
public Thread run(Runnable target, int priority, boolean queueable);
}//IThreadService//

View File

@@ -13,7 +13,7 @@ public interface IWebApplicationFactory {
* @param appProperties The property map containing custom properties for the web application.
* @return The web application.
*/
public IWebApplication[] createWebApplications(File baseDirectory, File externalBaseDirectory, File cacheBaseDirectory, IAppLog log, Properties appProperties);
public IWebApplication[] createWebApplications(File baseDirectory, File externalBaseDirectory, File cacheBaseDirectory, IAppLog log, IThreadService threadService, IScheduler scheduler, Properties appProperties);
/**
* Provides the factory a chance to shutdown any shared resources between the web applications, such as an Application class or thread service.
*/