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

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

/**
 * 
 */
package org.drools.process.workitem.wsht;

import org.drools.eventmessaging.EventResponseHandler;
import org.drools.eventmessaging.Payload;

public class BlockingEventResponseHandler extends AbstractBlockingResponseHandler implements EventResponseHandler {
    private volatile Payload payload;

    public synchronized void execute(Payload payload) {
        synchronized ( this.done ) {            
            this.payload = payload;        
            this.done = true;
        }
        notifyAll();        
    }
    
    public synchronized Payload getPayload() {
        boolean isDone;
        synchronized ( done ) {
            isDone = this.done;
        }
        if ( !isDone ) {                  
            try {
                wait( 1000000 );
            } catch ( InterruptedException e ) {
                // swallow as this is just a notification
            }
        }        
        synchronized ( done ) {
            isDone = this.done;
        }        
        if ( !isDone ) {
            throw new RuntimeException("Timeout : unable to retrieve event payload" );
        }
        
        return payload;
    }       
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy