From 388f25a9dc58704ea19a333ba9a28054d48590b1 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Tue, 15 Dec 2009 21:58:47 +0000
Subject: [PATCH] Various changes:
---
sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java | 93 +++++++++++++++++++++++++++++-----------------
1 files changed, 59 insertions(+), 34 deletions(-)
diff --git a/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java b/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java
index 42069ae..9392984 100644
--- a/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java
+++ b/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java
@@ -88,7 +88,7 @@
private static class FailedImpl implements
- ConnectionFuture<AsynchronousConnection>
+ FutureResult<AsynchronousConnection>
{
private volatile ErrorResultException exception;
@@ -136,12 +136,19 @@
{
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>
{
@@ -151,18 +158,18 @@
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;
}
@@ -232,6 +239,13 @@
+ public int getRequestID()
+ {
+ return -1;
+ }
+
+
+
/**
* {@inheritDoc}
*/
@@ -267,7 +281,7 @@
latch.countDown();
if (handler != null)
{
- handler.handleConnection(this.connection);
+ handler.handleResult(this.connection);
}
}
catch (CancellationException ce)
@@ -281,7 +295,7 @@
latch.countDown();
if (handler != null)
{
- handler.handleConnectionError(exception);
+ handler.handleErrorResult(exception);
}
}
}
@@ -290,7 +304,7 @@
latch.countDown();
if (handler != null)
{
- handler.handleConnection(this.connection);
+ handler.handleResult(this.connection);
}
}
}
@@ -307,7 +321,7 @@
latch.countDown();
if (handler != null)
{
- handler.handleConnectionError(exception);
+ handler.handleErrorResult(exception);
}
}
@@ -330,7 +344,7 @@
latch.countDown();
if (handler != null)
{
- handler.handleConnection(connection);
+ handler.handleResult(connection);
}
}
@@ -343,7 +357,7 @@
latch.countDown();
if (handler != null)
{
- handler.handleConnectionError(exception);
+ handler.handleErrorResult(exception);
}
}
}
@@ -363,7 +377,6 @@
if (TCP_NIO_TRANSPORT == null)
{
// Create a default transport using the Grizzly framework.
- //
TCP_NIO_TRANSPORT = TransportFactory.getInstance()
.createTCPTransport();
try
@@ -382,23 +395,7 @@
@Override
public void run()
{
- try
- {
- TCP_NIO_TRANSPORT.stop();
- }
- catch (Exception e)
- {
- // Ignore.
- }
-
- try
- {
- TCP_NIO_TRANSPORT.getWorkerThreadPool().shutdown();
- }
- catch (Exception e)
- {
- // Ignore.
- }
+ ShutdownTCPNIOTransport();
}
});
@@ -408,6 +405,34 @@
+ 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;
@@ -482,10 +507,10 @@
/**
* {@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
{
--
Gitblit v1.10.0