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

com.bigdata.service.proxy.RemoteFutureImpl Maven / Gradle / Ivy

package com.bigdata.service.proxy;

import java.io.IOException;
import java.rmi.Remote;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/**
 * A helper object that provides the API of {@link Future} but whose methods
 * throw {@link IOException} and are therefore compatible with
 * {@link Remote} and {@link Exporter}.
 * 
 * @author Bryan Thompson
 * @version $Id$
 * @param 
 */
public class RemoteFutureImpl implements RemoteFuture {

    private final Future future;

    public RemoteFutureImpl(final Future future) {

        if (future == null)
            throw new IllegalArgumentException();

        this.future = future;

    }

    public boolean cancel(boolean mayInterruptIfRunning) throws IOException {
        
        return future.cancel(mayInterruptIfRunning);
        
    }

    public T get() throws InterruptedException, ExecutionException,
            IOException {
        
        return future.get();
        
    }

    public T get(long timeout, TimeUnit unit) throws InterruptedException,
            ExecutionException, TimeoutException, IOException {
        
        return future.get(timeout, unit);
        
    }

    public boolean isCancelled() throws IOException {
        
        return future.isCancelled();
        
    }

    public boolean isDone() throws IOException {
        
        return future.isDone();
        
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy