| | |
| | | |
| | | |
| | | @Override |
| | | protected void removeMessageHandler(com.sun.grizzly.Connection<?> connection) |
| | | protected void removeMessageHandler( |
| | | com.sun.grizzly.Connection<?> connection) |
| | | { |
| | | ldapConnectionAttr.remove(connection); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | private class ConnectionFutureImpl<P> implements |
| | | private class ConnectionFutureImpl implements |
| | | ConnectionFuture<AsynchronousConnection>, |
| | | com.sun.grizzly.CompletionHandler<com.sun.grizzly.Connection>, |
| | | ResultHandler<Result, Void> |
| | | ResultHandler<Result> |
| | | { |
| | | private volatile AsynchronousConnection connection; |
| | | |
| | |
| | | |
| | | private final CountDownLatch latch = new CountDownLatch(1); |
| | | |
| | | private final ConnectionResultHandler<? super AsynchronousConnection, P> handler; |
| | | private final ConnectionResultHandler<? super AsynchronousConnection> handler; |
| | | |
| | | private boolean cancelled; |
| | | |
| | | private final P p; |
| | | |
| | | |
| | | |
| | | private ConnectionFutureImpl( |
| | | ConnectionResultHandler<? super AsynchronousConnection, P> handler, |
| | | P p) |
| | | ConnectionResultHandler<? super AsynchronousConnection> handler) |
| | | { |
| | | this.handler = handler; |
| | | this.p = p; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | StartTLSRequest startTLS = new StartTLSRequest(options |
| | | .getSSLContext()); |
| | | sslFuture = this.connection.extendedRequest(startTLS, this, |
| | | null); |
| | | sslFuture = this.connection.extendedRequest(startTLS, this); |
| | | } |
| | | else if (options.getSSLContext() != null) |
| | | { |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnection(p, this.connection); |
| | | handler.handleConnection(this.connection); |
| | | } |
| | | } |
| | | catch (CancellationException ce) |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnectionError(p, exception); |
| | | handler.handleConnectionError(exception); |
| | | } |
| | | } |
| | | } |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnection(p, this.connection); |
| | | handler.handleConnection(this.connection); |
| | | } |
| | | } |
| | | } |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnectionError(p, exception); |
| | | handler.handleConnectionError(exception); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | // This is called when the StartTLS request is successful |
| | | public void handleResult(Void v, Result result) |
| | | public void handleResult(Result result) |
| | | { |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnection(p, connection); |
| | | handler.handleConnection(connection); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // This is called when the StartTLS request is not successful |
| | | public void handleErrorResult(Void v, ErrorResultException error) |
| | | public void handleErrorResult(ErrorResultException error) |
| | | { |
| | | exception = error; |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnectionError(p, exception); |
| | | handler.handleConnectionError(exception); |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <P> ConnectionFuture<AsynchronousConnection> getAsynchronousConnection( |
| | | ConnectionResultHandler<? super AsynchronousConnection, P> handler, |
| | | P p) |
| | | public ConnectionFuture<AsynchronousConnection> getAsynchronousConnection( |
| | | ConnectionResultHandler<? super AsynchronousConnection> handler) |
| | | { |
| | | ConnectionFutureImpl<P> future = new ConnectionFutureImpl<P>( |
| | | handler, p); |
| | | ConnectionFutureImpl future = new ConnectionFutureImpl(handler); |
| | | |
| | | try |
| | | { |
| | |
| | | t = t.getCause(); |
| | | } |
| | | |
| | | Result result = Responses.newResult(ResultCode.CLIENT_SIDE_CONNECT_ERROR).setCause(t) |
| | | Result result = Responses.newResult( |
| | | ResultCode.CLIENT_SIDE_CONNECT_ERROR).setCause(t) |
| | | .setDiagnosticMessage(t.getMessage()); |
| | | return ErrorResultException.wrap(result); |
| | | } |