org.apache.directory.ldap.client.api.future
Class ResponseFuture<R extends org.apache.directory.api.ldap.model.message.Response>

java.lang.Object
  extended by org.apache.directory.ldap.client.api.future.ResponseFuture<R>
Type Parameters:
R - The result type returned by this Future's get method
All Implemented Interfaces:
Future<org.apache.directory.api.ldap.model.message.Response>
Direct Known Subclasses:
AddFuture, BindFuture, CompareFuture, DeleteFuture, ExtendedFuture, ModifyDnFuture, ModifyFuture, SearchFuture

public class ResponseFuture<R extends org.apache.directory.api.ldap.model.message.Response>
extends Object
implements Future<org.apache.directory.api.ldap.model.message.Response>

A Future implementation used in LdapConnection operations.

Author:
Apache Directory Project

Field Summary
protected  boolean cancelled
          flag to determine if this future is cancelled
protected  Throwable cause
          If the request has been cancelled because of an exception it will be stored here
protected  LdapConnection connection
          The connection used by the request
protected  int messageId
          The messageID for this future
protected  BlockingQueue<R> queue
          the blocking queue holding LDAP responses
 
Constructor Summary
ResponseFuture(LdapConnection connection, int messageId)
          Creates a new instance of ResponseFuture.
 
Method Summary
 void cancel()
          Cancel the Future
 boolean cancel(boolean mayInterruptIfRunning)
          
 R get()
          
 R get(long timeout, TimeUnit unit)
          
 Throwable getCause()
           
 boolean isCancelled()
          
 boolean isDone()
          This operation is not supported in this implementation of Future.
 void set(R response)
          
 void setCause(Throwable cause)
          Associate a cause to the ResponseFuture
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

queue

protected BlockingQueue<R extends org.apache.directory.api.ldap.model.message.Response> queue
the blocking queue holding LDAP responses


cancelled

protected boolean cancelled
flag to determine if this future is cancelled


cause

protected Throwable cause
If the request has been cancelled because of an exception it will be stored here


messageId

protected int messageId
The messageID for this future


connection

protected LdapConnection connection
The connection used by the request

Constructor Detail

ResponseFuture

public ResponseFuture(LdapConnection connection,
                      int messageId)
Creates a new instance of ResponseFuture.

Parameters:
connection - The LdapConnection used by the request
messageId - The associated message ID
Method Detail

cancel

public boolean cancel(boolean mayInterruptIfRunning)

Specified by:
cancel in interface Future<org.apache.directory.api.ldap.model.message.Response>

get

public R get()
                                                                   throws InterruptedException,
                                                                          ExecutionException

Specified by:
get in interface Future<org.apache.directory.api.ldap.model.message.Response>
Throws:
InterruptedException - if the operation has been cancelled by client
ExecutionException

set

public void set(R response)
         throws InterruptedException,
                ExecutionException

Throws:
InterruptedException - if the operation has been cancelled by client
ExecutionException

get

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

Specified by:
get in interface Future<org.apache.directory.api.ldap.model.message.Response>
Throws:
InterruptedException - if the operation has been cancelled by client
ExecutionException
TimeoutException

isCancelled

public boolean isCancelled()

Specified by:
isCancelled in interface Future<org.apache.directory.api.ldap.model.message.Response>

isDone

public boolean isDone()
This operation is not supported in this implementation of Future.

Specified by:
isDone in interface Future<org.apache.directory.api.ldap.model.message.Response>

getCause

public Throwable getCause()
Returns:
the cause

setCause

public void setCause(Throwable cause)
Associate a cause to the ResponseFuture

Parameters:
cause - the cause to set

cancel

public void cancel()
Cancel the Future


toString

public String toString()

Overrides:
toString in class Object


Copyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.