com.sun.sgs.impl.util
Class AbstractCompletionFuture<T>

java.lang.Object
  extended by com.sun.sgs.impl.util.AbstractCompletionFuture<T>
Type Parameters:
T - the future's result type
All Implemented Interfaces:
Future<T>
Direct Known Subclasses:
ClientSessionHandler.SetupCompletionFuture

public abstract class AbstractCompletionFuture<T>
extends Object
implements Future<T>

This future is an abstract implementation for the futures passed to the RequestCompletionHandler used by the ProtocolListener and SessionProtocolHandler APIs.


Constructor Summary
protected AbstractCompletionFuture(RequestCompletionHandler<T> completionHandler)
          Constructs an instance with the specified completionHandler.
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
          
protected  void done()
          Indicates that the operation associated with this future is complete and notifies the associated completion handler.
 T get()
          
 T get(long timeout, TimeUnit unit)
          
protected abstract  T getValue()
          Returns the value associated with this future.
 boolean isCancelled()
          
 boolean isDone()
          
protected  void setException(Throwable throwable)
          Sets the exception cause for this future to the specified throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCompletionFuture

protected AbstractCompletionFuture(RequestCompletionHandler<T> completionHandler)
Constructs an instance with the specified completionHandler.

Parameters:
completionHandler - a completion handler
Method Detail

getValue

protected abstract T getValue()
Returns the value associated with this future.

Returns:
the value for this future

cancel

public boolean cancel(boolean mayInterruptIfRunning)

Specified by:
cancel in interface Future<T>

get

public T get()
      throws InterruptedException,
             ExecutionException

Specified by:
get in interface Future<T>
Throws:
InterruptedException
ExecutionException

get

public T get(long timeout,
             TimeUnit unit)
      throws InterruptedException,
             ExecutionException,
             TimeoutException

Specified by:
get in interface Future<T>
Throws:
InterruptedException
ExecutionException
TimeoutException

isCancelled

public boolean isCancelled()

Specified by:
isCancelled in interface Future<T>

setException

protected void setException(Throwable throwable)
Sets the exception cause for this future to the specified throwable. The given exception will be used as the cause of the ExecutionException thrown by this future's get methods.

Parameters:
throwable - an exception cause

isDone

public boolean isDone()

Specified by:
isDone in interface Future<T>

done

protected void done()
Indicates that the operation associated with this future is complete and notifies the associated completion handler. Subsequent invocations to isDone will return true.

Throws:
IllegalStateException - if this method has already been invoked

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved