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

org.drools.process.workitem.wsht.AbstractBlockingResponseHandler 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.BaseMinaHandler.ResponseHandler;

public abstract class AbstractBlockingResponseHandler
    implements
    ResponseHandler {
    protected volatile Boolean done = Boolean.FALSE;
    private String error;
    
    public boolean hasError() {
        return error != null;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public boolean isDone() {
        synchronized ( done ) {
            return done;
        }
    }

    public boolean waitTillDone(long time) {
        long totalWaitTime = 0;
        try {
            while ( true ) {
                synchronized ( done ) {
                    if ( done ) {
                        return true;
                    }
                }
                if ( totalWaitTime >= time ) {
                    break;
                }
                Thread.sleep( 250 );
                totalWaitTime += 250;
            }
        } catch ( Exception e ) {
            // swallow, as we are either true or false
        }
        return false;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy