use of org.wso2.carbon.ntask.core.TaskManager in project carbon-business-process by wso2.
the class TaskCleanupSchedulerUtil method initTaskCleanupJob.
/**
* Initialises the task clean up task.
*
* @throws HumanTaskServerException :
*/
public static void initTaskCleanupJob() throws HumanTaskServerException {
HumanTaskServerConfiguration serverConfig = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getServerConfig();
if (serverConfig.isTaskCleanupEnabled()) {
try {
log.info("Initialising the task cleanup service.....");
HumanTaskCleanupSchedulerServiceComponent.getTaskService().registerTaskType(HumanTaskConstants.HUMANTASK_TASK_TYPE);
TaskManager taskManager = HumanTaskCleanupSchedulerServiceComponent.getTaskService().getTaskManager(HumanTaskConstants.HUMANTASK_TASK_TYPE);
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
triggerInfo.setCronExpression(serverConfig.getTaskCleanupCronExpression());
triggerInfo.setDisallowConcurrentExecution(true);
Map<String, String> propertyMap = new LinkedHashMap<String, String>();
TaskInfo taskInfo = new TaskInfo(HumanTaskConstants.HUMANTASK_CLEANUP_JOB, RemovableTaskCleanupJob.class.getName(), propertyMap, triggerInfo);
taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(HumanTaskConstants.HUMANTASK_CLEANUP_JOB);
} catch (TaskException ex) {
String errMsg = "Error occurred while registering task type : " + HumanTaskConstants.HUMANTASK_TASK_TYPE;
throw new HumanTaskServerException(errMsg, ex);
}
}
}
Aggregations