Package org.silverpeas.core.thread.task
Class RequestTaskManager
- java.lang.Object
-
- org.silverpeas.core.thread.task.RequestTaskManager
-
@Technical @Singleton @Bean public class RequestTaskManager extends Object
This manager handles the threading side ofAbstractRequestTask
processing.The aim is to avoid the developer to think about how to write rightly the consummation of a list of request to process.
To process a request, an
AbstractRequestTask
must be implemented and this implementation must push request to process by usingpush(Class, Request)
method.- Author:
- silveryocha
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RequestTaskManager
get()
<T extends AbstractRequestTask<C>,C extends AbstractRequestTask.ProcessContext>
booleanisTaskNotRunning(Class<T> taskClass)
This method permits to know if the task isn't running anymore.<T extends AbstractRequestTask<C>,C extends AbstractRequestTask.ProcessContext>
booleanisTaskRunning(Class<T> taskClass)
This method permits to know if the task is running.<T extends AbstractRequestTask<C>,C extends AbstractRequestTask.ProcessContext>
voidpush(Class<T> taskClass, AbstractRequestTask.Request<C> newRequest)
This method is the only entry point to add a request to process.protected void
shutdownAllTasks()
-
-
-
Method Detail
-
get
public static RequestTaskManager get()
-
isTaskRunning
public <T extends AbstractRequestTask<C>,C extends AbstractRequestTask.ProcessContext> boolean isTaskRunning(Class<T> taskClass)
This method permits to know if the task is running.- Type Parameters:
T
- the type of the task.- Parameters:
taskClass
- the class of theAbstractRequestTask
implementation which provides theAbstractRequestTask.Request
.
-
isTaskNotRunning
public <T extends AbstractRequestTask<C>,C extends AbstractRequestTask.ProcessContext> boolean isTaskNotRunning(Class<T> taskClass)
This method permits to know if the task isn't running anymore.- Type Parameters:
T
- the type of the task.- Parameters:
taskClass
- the class of theAbstractRequestTask
implementation which provides theAbstractRequestTask.Request
.
-
push
public <T extends AbstractRequestTask<C>,C extends AbstractRequestTask.ProcessContext> void push(Class<T> taskClass, AbstractRequestTask.Request<C> newRequest)
This method is the only entry point to add a request to process.There is three synchronized steps performed into this method:
- first, starting the consummation task if exists at least one request into the queue and if the task is not running
- then, acquiring a semaphore access if the queue size is limited
- finally, adding the request into the queue and starting the task if it is not running
- Type Parameters:
T
- the type of the task.C
- the type of the task process context.- Parameters:
taskClass
- the class of theAbstractRequestTask
implementation which provides theAbstractRequestTask.Request
.newRequest
- the request to process.
-
shutdownAllTasks
@PreDestroy protected void shutdownAllTasks()
-
-