All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.process.workitem.wsht.BlockingGetTaskResponseHandler Maven / Gradle / Ivy

There is a newer version: 5.1.1
Show newest version
/**
 *
 */
package org.drools.process.workitem.wsht;

import org.drools.task.Task;
import org.drools.task.service.TaskClientHandler.GetTaskResponseHandler;
import org.drools.task.service.responsehandlers.AbstractBlockingResponseHandler;

public class BlockingGetTaskResponseHandler extends AbstractBlockingResponseHandler implements GetTaskResponseHandler {
    private static final int DEFAULT_WAIT_TIME = 10000;

    private volatile Task task;
    
    public synchronized void execute(Task task) {
        this.task = task;
        setDone(true);
    }

    public Task getTask() {
        // note that this method doesn't need to be synced because if waitTillDone returns true,
        // it means task is available 
        boolean done = waitTillDone(DEFAULT_WAIT_TIME);

        if (!done) {
            throw new RuntimeException("Timeout : unable to retrieve Task");
        }

        return task;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy