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

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

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

import org.drools.task.service.TaskClientHandler.AddTaskResponseHandler;

public class BlockingAddTaskResponseHandler extends AbstractBlockingResponseHandler implements AddTaskResponseHandler {
    private volatile long taskId;

    public synchronized void execute(long taskId) {
        synchronized ( this.done ) {        
            this.taskId = taskId;
            this.done = true;
            notifyAll(); 
        }
    }
    
    public synchronized long getTaskId() {
        boolean isDone;
        synchronized ( done ) {
            isDone = this.done;
        }
        if ( !isDone ) {                  
            try {
                wait( 10000 );
            } catch ( InterruptedException e ) {
                // swallow as this is just a notification
            }
        }        
        synchronized ( done ) {
            isDone = this.done;
        }        
        if ( !isDone ) {
            throw new RuntimeException("Timeout : unable to retrieve Task Id" );
        }
        
        return taskId;
    }       
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy