From a415256cc798baf286d618a2c9ddd427c26a518d Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 14 Dec 2009 13:21:39 +0000
Subject: [PATCH] Remove optional P parameter from result handlers as it is hardly ever needed in practice and just pollutes the APIs.

---
 sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java |   45 ++++++++++++++++++++-------------------------
 1 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java b/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java
index 8b7edc8..42069ae 100644
--- a/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java
+++ b/sdk/src/com/sun/opends/sdk/ldap/LDAPConnectionFactoryImpl.java
@@ -77,7 +77,8 @@
 
 
     @Override
-    protected void removeMessageHandler(com.sun.grizzly.Connection<?> connection)
+    protected void removeMessageHandler(
+        com.sun.grizzly.Connection<?> connection)
     {
       ldapConnectionAttr.remove(connection);
     }
@@ -139,10 +140,10 @@
 
 
 
-  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;
 
@@ -154,20 +155,16 @@
 
     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;
     }
 
 
@@ -258,8 +255,7 @@
       {
         StartTLSRequest startTLS = new StartTLSRequest(options
             .getSSLContext());
-        sslFuture = this.connection.extendedRequest(startTLS, this,
-            null);
+        sslFuture = this.connection.extendedRequest(startTLS, this);
       }
       else if (options.getSSLContext() != null)
       {
@@ -271,7 +267,7 @@
           latch.countDown();
           if (handler != null)
           {
-            handler.handleConnection(p, this.connection);
+            handler.handleConnection(this.connection);
           }
         }
         catch (CancellationException ce)
@@ -285,7 +281,7 @@
           latch.countDown();
           if (handler != null)
           {
-            handler.handleConnectionError(p, exception);
+            handler.handleConnectionError(exception);
           }
         }
       }
@@ -294,7 +290,7 @@
         latch.countDown();
         if (handler != null)
         {
-          handler.handleConnection(p, this.connection);
+          handler.handleConnection(this.connection);
         }
       }
     }
@@ -311,7 +307,7 @@
       latch.countDown();
       if (handler != null)
       {
-        handler.handleConnectionError(p, exception);
+        handler.handleConnectionError(exception);
       }
     }
 
@@ -329,25 +325,25 @@
 
 
     // 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);
       }
     }
   }
@@ -486,12 +482,10 @@
   /**
    * {@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
     {
@@ -590,7 +584,8 @@
       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);
   }

--
Gitblit v1.10.0