Search in sources :

Example 1 with HumanTaskServer

use of org.wso2.carbon.humantask.core.HumanTaskServer in project carbon-business-process by wso2.

the class HumanTaskServer method initScheduler.

/**
 * Scheduler initialisation.
 */
private void initScheduler() {
    ThreadFactory threadFactory = new ThreadFactory() {

        private int threadNumber = 0;

        public Thread newThread(Runnable r) {
            threadNumber += 1;
            Thread t = new Thread(r, "HumanTaskServer-" + threadNumber);
            t.setDaemon(true);
            return t;
        }
    };
    ExecutorService executorService = Executors.newFixedThreadPool(serverConfig.getThreadPoolMaxSize(), threadFactory);
    SimpleScheduler simpleScheduler = new SimpleScheduler(new GUID().toString());
    simpleScheduler.setExecutorService(executorService);
    simpleScheduler.setTransactionManager(tnxManager);
    taskEngine.setScheduler(simpleScheduler);
    simpleScheduler.setJobProcessor(new JobProcessorImpl());
    // Start the scheduler within the HumanTaskSchedulerInitializer to ensure that all the tasks are deployed
    // when the scheduler actually starts.
    // simpleScheduler.start();
    scheduler = simpleScheduler;
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) GUID(org.wso2.carbon.humantask.core.utils.GUID) SimpleScheduler(org.wso2.carbon.humantask.core.scheduler.SimpleScheduler) JobProcessorImpl(org.wso2.carbon.humantask.core.scheduler.JobProcessorImpl)

Example 2 with HumanTaskServer

use of org.wso2.carbon.humantask.core.HumanTaskServer in project carbon-business-process by wso2.

the class HumanTaskDeployer method init.

public void init(ConfigurationContext configurationContext) {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    log.info("Initializing HumanTask Deployer for tenant " + tenantId + ".");
    try {
        HumanTaskDeployerServiceComponent.getTenantRegistryLoader().loadTenantRegistry(tenantId);
        createHumanTaskRepository(configurationContext);
        HumanTaskServer humantaskServer = HumanTaskDeployerServiceComponent.getHumanTaskServer();
        humanTaskStore = humantaskServer.getTaskStoreManager().createHumanTaskStoreForTenant(tenantId, configurationContext);
    } catch (DeploymentException e) {
        log.warn(String.format("Human Task Repository creation failed for tenant id [%d]", tenantId), e);
    } catch (RegistryException e) {
        log.warn("Initializing HumanTask Deployer failed for tenant " + tenantId, e);
    }
}
Also used : HumanTaskServer(org.wso2.carbon.humantask.core.HumanTaskServer) DeploymentException(org.apache.axis2.deployment.DeploymentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 3 with HumanTaskServer

use of org.wso2.carbon.humantask.core.HumanTaskServer in project carbon-business-process by wso2.

the class DeployedTasks method getAlldeployedTasks.

public String[] getAlldeployedTasks(int tenantID) {
    String[] noTask = { "No deployed task for the specified tenant" };
    String[] noStore = { "No Human Tasks Store found for the given tenantID" };
    HumanTaskServer humanTaskServer = HumanTaskServiceComponent.getHumanTaskServer();
    HumanTaskStore humanTaskStore = humanTaskServer.getTaskStoreManager().getHumanTaskStore(tenantID);
    if (humanTaskStore == null) {
        return noStore;
    }
    List<HumanTaskBaseConfiguration> humanTaskConfigurations = humanTaskStore.getTaskConfigurations();
    deployedTasks = new String[humanTaskConfigurations.size()];
    for (int i = 0; i < humanTaskConfigurations.size(); i++) {
        deployedTasks[i] = humanTaskConfigurations.get(i).getName() + "\t" + humanTaskConfigurations.get(i).getDefinitionName() + "\t" + humanTaskConfigurations.get(i).getOperation();
    }
    if (deployedTasks.length == 0) {
        return noTask;
    }
    return deployedTasks;
}
Also used : HumanTaskStore(org.wso2.carbon.humantask.core.store.HumanTaskStore) HumanTaskServer(org.wso2.carbon.humantask.core.HumanTaskServer) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)

Example 4 with HumanTaskServer

use of org.wso2.carbon.humantask.core.HumanTaskServer in project carbon-business-process by wso2.

the class HumanTaskPackageManagementSkeleton method getTenantTaskStore.

// Returns the task store for the tenant.
private HumanTaskStore getTenantTaskStore() {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    HumanTaskServer server = HumanTaskServiceComponent.getHumanTaskServer();
    return server.getTaskStoreManager().getHumanTaskStore(tenantId);
}
Also used : HumanTaskServer(org.wso2.carbon.humantask.core.HumanTaskServer)

Aggregations

HumanTaskServer (org.wso2.carbon.humantask.core.HumanTaskServer)3 ExecutorService (java.util.concurrent.ExecutorService)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 DeploymentException (org.apache.axis2.deployment.DeploymentException)1 JobProcessorImpl (org.wso2.carbon.humantask.core.scheduler.JobProcessorImpl)1 SimpleScheduler (org.wso2.carbon.humantask.core.scheduler.SimpleScheduler)1 HumanTaskBaseConfiguration (org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)1 HumanTaskStore (org.wso2.carbon.humantask.core.store.HumanTaskStore)1 GUID (org.wso2.carbon.humantask.core.utils.GUID)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1