| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <P> ConnectionFuture<AuthenticatedAsynchronousConnection> getAsynchronousConnection( |
| | | ConnectionResultHandler<? super AuthenticatedAsynchronousConnection, P> handler, |
| | | P p) |
| | | public ConnectionFuture<AuthenticatedAsynchronousConnection> getAsynchronousConnection( |
| | | ConnectionResultHandler<? super AuthenticatedAsynchronousConnection> handler) |
| | | { |
| | | // TODO: bug here? if allowRebind= false then bind will never |
| | | // happen |
| | | ConnectionFutureImpl<P> future = new ConnectionFutureImpl<P>( |
| | | allowRebinds ? request : null, handler, p); |
| | | future.connectFuture = parentFactory.getAsynchronousConnection( |
| | | future, null); |
| | | ConnectionFutureImpl future = new ConnectionFutureImpl( |
| | | allowRebinds ? request : null, handler); |
| | | future.connectFuture = parentFactory |
| | | .getAsynchronousConnection(future); |
| | | return future; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public <P> ResultFuture<Result> add(AddRequest request, |
| | | ResultHandler<Result, P> handler, P p) |
| | | public ResultFuture<Result> add(AddRequest request, |
| | | ResultHandler<Result> handler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.add(request, handler, p); |
| | | return connection.add(request, handler); |
| | | } |
| | | |
| | | |
| | |
| | | * connections. This method will always throw {@code |
| | | * UnsupportedOperationException}. |
| | | */ |
| | | public <P> ResultFuture<BindResult> bind(BindRequest request, |
| | | ResultHandler<? super BindResult, P> handler, P p) |
| | | public ResultFuture<BindResult> bind(BindRequest request, |
| | | ResultHandler<? super BindResult> handler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | public <P> ResultFuture<CompareResult> compare( |
| | | CompareRequest request, |
| | | ResultHandler<? super CompareResult, P> handler, P p) |
| | | public ResultFuture<CompareResult> compare(CompareRequest request, |
| | | ResultHandler<? super CompareResult> handler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.compare(request, handler, p); |
| | | return connection.compare(request, handler); |
| | | } |
| | | |
| | | |
| | | |
| | | public <P> ResultFuture<Result> delete(DeleteRequest request, |
| | | ResultHandler<Result, P> handler, P p) |
| | | public ResultFuture<Result> delete(DeleteRequest request, |
| | | ResultHandler<Result> handler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.delete(request, handler, p); |
| | | return connection.delete(request, handler); |
| | | } |
| | | |
| | | |
| | | |
| | | public <R extends Result, P> ResultFuture<R> extendedRequest( |
| | | ExtendedRequest<R> request, |
| | | ResultHandler<? super R, P> handler, P p) |
| | | public <R extends Result> ResultFuture<R> extendedRequest( |
| | | ExtendedRequest<R> request, ResultHandler<? super R> handler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.extendedRequest(request, handler, p); |
| | | return connection.extendedRequest(request, handler); |
| | | } |
| | | |
| | | |
| | | |
| | | public <P> ResultFuture<Result> modify(ModifyRequest request, |
| | | ResultHandler<Result, P> handler, P p) |
| | | public ResultFuture<Result> modify(ModifyRequest request, |
| | | ResultHandler<Result> handler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.modify(request, handler, p); |
| | | return connection.modify(request, handler); |
| | | } |
| | | |
| | | |
| | | |
| | | public <P> ResultFuture<Result> modifyDN(ModifyDNRequest request, |
| | | ResultHandler<Result, P> handler, P p) |
| | | public ResultFuture<Result> modifyDN(ModifyDNRequest request, |
| | | ResultHandler<Result> handler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.modifyDN(request, handler, p); |
| | | return connection.modifyDN(request, handler); |
| | | } |
| | | |
| | | |
| | |
| | | * associated with this connection. If re-authentication fails for |
| | | * some reason then this connection will be automatically closed. |
| | | * |
| | | * @param <P> |
| | | * The type of the additional parameter to the handler's |
| | | * methods. |
| | | * @param handler |
| | | * A result handler which can be used to asynchronously |
| | | * process the operation result when it is received, may be |
| | | * {@code null}. |
| | | * @param p |
| | | * Optional additional handler parameter. |
| | | * @return A future representing the result of the operation. |
| | | * @throws UnsupportedOperationException |
| | | * If this connection does not support rebind operations. |
| | |
| | | * If this connection has already been closed, i.e. if |
| | | * {@code isClosed() == true}. |
| | | */ |
| | | public <P> ResultFuture<BindResult> rebind( |
| | | ResultHandler<? super BindResult, P> handler, P p) |
| | | public ResultFuture<BindResult> rebind( |
| | | ResultHandler<? super BindResult> handler) |
| | | throws UnsupportedOperationException, IllegalStateException |
| | | { |
| | | if (request == null) |
| | |
| | | |
| | | // Wrap the client handler so that we can update the connection |
| | | // state. |
| | | final ResultHandler<? super BindResult, P> clientHandler = handler; |
| | | final P clientParameter = p; |
| | | final ResultHandler<? super BindResult> clientHandler = handler; |
| | | |
| | | ResultHandler<BindResult, Void> handlerWrapper = new ResultHandler<BindResult, Void>() |
| | | ResultHandler<BindResult> handlerWrapper = new ResultHandler<BindResult>() |
| | | { |
| | | |
| | | public void handleErrorResult(Void p, ErrorResultException error) |
| | | public void handleErrorResult(ErrorResultException error) |
| | | { |
| | | // This connection is now unauthenticated so prevent |
| | | // further use. |
| | |
| | | |
| | | if (clientHandler != null) |
| | | { |
| | | clientHandler.handleErrorResult(clientParameter, error); |
| | | clientHandler.handleErrorResult(error); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public void handleResult(Void p, BindResult result) |
| | | public void handleResult(BindResult result) |
| | | { |
| | | // Save the result. |
| | | AuthenticatedAsynchronousConnection.this.result = result; |
| | | |
| | | if (clientHandler != null) |
| | | { |
| | | clientHandler.handleResult(clientParameter, result); |
| | | clientHandler.handleResult(result); |
| | | } |
| | | } |
| | | |
| | | }; |
| | | |
| | | return connection.bind(request, handlerWrapper, null); |
| | | return connection.bind(request, handlerWrapper); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public <P> ResultFuture<Result> search(SearchRequest request, |
| | | ResultHandler<Result, P> resultHandler, |
| | | SearchResultHandler<P> searchResulthandler, P p) |
| | | public ResultFuture<Result> search(SearchRequest request, |
| | | ResultHandler<Result> resultHandler, |
| | | SearchResultHandler searchResulthandler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.search(request, resultHandler, |
| | | searchResulthandler, p); |
| | | searchResulthandler); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <P> ResultFuture<RootDSE> readRootDSE( |
| | | ResultHandler<RootDSE, P> handler, P p) |
| | | public ResultFuture<RootDSE> readRootDSE( |
| | | ResultHandler<RootDSE> handler) |
| | | throws UnsupportedOperationException, IllegalStateException |
| | | { |
| | | return connection.readRootDSE(handler, p); |
| | | return connection.readRootDSE(handler); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <P> ResultFuture<SearchResultEntry> readEntry(DN name, |
| | | public ResultFuture<SearchResultEntry> readEntry(DN name, |
| | | Collection<String> attributeDescriptions, |
| | | ResultHandler<? super SearchResultEntry, P> resultHandler, P p) |
| | | ResultHandler<? super SearchResultEntry> resultHandler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.readEntry(name, attributeDescriptions, |
| | | resultHandler, p); |
| | | resultHandler); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <P> ResultFuture<SearchResultEntry> searchSingleEntry( |
| | | public ResultFuture<SearchResultEntry> searchSingleEntry( |
| | | SearchRequest request, |
| | | ResultHandler<? super SearchResultEntry, P> resultHandler, P p) |
| | | ResultHandler<? super SearchResultEntry> resultHandler) |
| | | throws UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException |
| | | { |
| | | return connection.searchSingleEntry(request, resultHandler, p); |
| | | return connection.searchSingleEntry(request, resultHandler); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <P> ResultFuture<Schema> readSchemaForEntry(DN name, |
| | | ResultHandler<Schema, P> handler, P p) |
| | | public ResultFuture<Schema> readSchemaForEntry(DN name, |
| | | ResultHandler<Schema> handler) |
| | | throws UnsupportedOperationException, IllegalStateException |
| | | { |
| | | return connection.readSchemaForEntry(name, handler, p); |
| | | return connection.readSchemaForEntry(name, handler); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <P> ResultFuture<Schema> readSchema(DN name, |
| | | ResultHandler<Schema, P> handler, P p) |
| | | public ResultFuture<Schema> readSchema(DN name, |
| | | ResultHandler<Schema> handler) |
| | | throws UnsupportedOperationException, IllegalStateException |
| | | { |
| | | return connection.readSchema(name, handler, p); |
| | | return connection.readSchema(name, handler); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | private static final class ConnectionFutureImpl<P> implements |
| | | private static final class ConnectionFutureImpl implements |
| | | ConnectionFuture<AuthenticatedAsynchronousConnection>, |
| | | ConnectionResultHandler<AsynchronousConnection, Void>, |
| | | ResultHandler<BindResult, Void> |
| | | ConnectionResultHandler<AsynchronousConnection>, |
| | | ResultHandler<BindResult> |
| | | { |
| | | private volatile AuthenticatedAsynchronousConnection authenticatedConnection; |
| | | |
| | |
| | | |
| | | private final CountDownLatch latch = new CountDownLatch(1); |
| | | |
| | | private final ConnectionResultHandler<? super AuthenticatedAsynchronousConnection, P> handler; |
| | | |
| | | private final P p; |
| | | private final ConnectionResultHandler<? super AuthenticatedAsynchronousConnection> handler; |
| | | |
| | | private boolean cancelled; |
| | | |
| | |
| | | |
| | | private ConnectionFutureImpl( |
| | | BindRequest request, |
| | | ConnectionResultHandler<? super AuthenticatedAsynchronousConnection, P> handler, |
| | | P p) |
| | | ConnectionResultHandler<? super AuthenticatedAsynchronousConnection> handler) |
| | | { |
| | | this.request = request; |
| | | this.handler = handler; |
| | | this.p = p; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public void handleConnection(Void v, |
| | | AsynchronousConnection connection) |
| | | public void handleConnection(AsynchronousConnection connection) |
| | | { |
| | | this.connection = connection; |
| | | this.bindFuture = this.connection.bind(request, this, null); |
| | | this.bindFuture = this.connection.bind(request, this); |
| | | } |
| | | |
| | | |
| | | |
| | | public void handleConnectionError(Void v, ErrorResultException error) |
| | | public void handleConnectionError(ErrorResultException error) |
| | | { |
| | | exception = error; |
| | | latch.countDown(); |
| | |
| | | |
| | | |
| | | |
| | | public void handleResult(Void v, BindResult result) |
| | | public void handleResult(BindResult result) |
| | | { |
| | | // FIXME: should make the result unmodifiable. |
| | | authenticatedConnection = new AuthenticatedAsynchronousConnection( |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnection(p, authenticatedConnection); |
| | | handler.handleConnection(authenticatedConnection); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public void handleErrorResult(Void v, ErrorResultException error) |
| | | public void handleErrorResult(ErrorResultException error) |
| | | { |
| | | // Ensure that the connection is closed. |
| | | try |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnectionError(p, exception); |
| | | handler.handleConnectionError(exception); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | public <P> ConnectionFuture<AuthenticatedAsynchronousConnection> getAsynchronousConnection( |
| | | ConnectionResultHandler<? super AuthenticatedAsynchronousConnection, P> handler, |
| | | P p) |
| | | public ConnectionFuture<AuthenticatedAsynchronousConnection> getAsynchronousConnection( |
| | | ConnectionResultHandler<? super AuthenticatedAsynchronousConnection> handler) |
| | | { |
| | | return impl.getAsynchronousConnection(handler, p); |
| | | return impl.getAsynchronousConnection(handler); |
| | | } |
| | | |
| | | |