| | |
| | | |
| | | |
| | | private static class FailedImpl implements |
| | | ConnectionFuture<AsynchronousConnection> |
| | | FutureResult<AsynchronousConnection> |
| | | { |
| | | private volatile ErrorResultException exception; |
| | | |
| | |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | public int getRequestID() |
| | | { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private class ConnectionFutureImpl implements |
| | | ConnectionFuture<AsynchronousConnection>, |
| | | private class ResultFutureImpl implements |
| | | FutureResult<AsynchronousConnection>, |
| | | com.sun.grizzly.CompletionHandler<com.sun.grizzly.Connection>, |
| | | ResultHandler<Result> |
| | | { |
| | |
| | | |
| | | private volatile Future<com.sun.grizzly.Connection> connectFuture; |
| | | |
| | | private volatile ResultFuture<?> sslFuture; |
| | | private volatile FutureResult<?> sslFuture; |
| | | |
| | | private final CountDownLatch latch = new CountDownLatch(1); |
| | | |
| | | private final ConnectionResultHandler<? super AsynchronousConnection> handler; |
| | | private final ResultHandler<? super AsynchronousConnection> handler; |
| | | |
| | | private boolean cancelled; |
| | | |
| | | |
| | | |
| | | private ConnectionFutureImpl( |
| | | ConnectionResultHandler<? super AsynchronousConnection> handler) |
| | | private ResultFutureImpl( |
| | | ResultHandler<? super AsynchronousConnection> handler) |
| | | { |
| | | this.handler = handler; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | public int getRequestID() |
| | | { |
| | | return -1; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnection(this.connection); |
| | | handler.handleResult(this.connection); |
| | | } |
| | | } |
| | | catch (CancellationException ce) |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnectionError(exception); |
| | | handler.handleErrorResult(exception); |
| | | } |
| | | } |
| | | } |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnection(this.connection); |
| | | handler.handleResult(this.connection); |
| | | } |
| | | } |
| | | } |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnectionError(exception); |
| | | handler.handleErrorResult(exception); |
| | | } |
| | | } |
| | | |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnection(connection); |
| | | handler.handleResult(connection); |
| | | } |
| | | } |
| | | |
| | |
| | | latch.countDown(); |
| | | if (handler != null) |
| | | { |
| | | handler.handleConnectionError(exception); |
| | | handler.handleErrorResult(exception); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (TCP_NIO_TRANSPORT == null) |
| | | { |
| | | // Create a default transport using the Grizzly framework. |
| | | // |
| | | TCP_NIO_TRANSPORT = TransportFactory.getInstance() |
| | | .createTCPTransport(); |
| | | try |
| | |
| | | @Override |
| | | public void run() |
| | | { |
| | | try |
| | | { |
| | | TCP_NIO_TRANSPORT.stop(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Ignore. |
| | | } |
| | | |
| | | try |
| | | { |
| | | TCP_NIO_TRANSPORT.getWorkerThreadPool().shutdown(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Ignore. |
| | | } |
| | | ShutdownTCPNIOTransport(); |
| | | } |
| | | |
| | | }); |
| | |
| | | |
| | | |
| | | |
| | | private synchronized static void ShutdownTCPNIOTransport() |
| | | { |
| | | if (TCP_NIO_TRANSPORT != null) |
| | | { |
| | | try |
| | | { |
| | | TCP_NIO_TRANSPORT.stop(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Ignore. |
| | | } |
| | | |
| | | // try |
| | | // { |
| | | // TCP_NIO_TRANSPORT.getWorkerThreadPool().shutdown(); |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // // Ignore. |
| | | // } |
| | | |
| | | TCP_NIO_TRANSPORT = null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private final Attribute<LDAPConnection> ldapConnectionAttr; |
| | | |
| | | private final InetSocketAddress socketAddress; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConnectionFuture<AsynchronousConnection> getAsynchronousConnection( |
| | | ConnectionResultHandler<? super AsynchronousConnection> handler) |
| | | public FutureResult<AsynchronousConnection> getAsynchronousConnection( |
| | | ResultHandler<? super AsynchronousConnection> handler) |
| | | { |
| | | ConnectionFutureImpl future = new ConnectionFutureImpl(handler); |
| | | ResultFutureImpl future = new ResultFutureImpl(handler); |
| | | |
| | | try |
| | | { |