From 6bef18d19414f3680165472e37dc4444da765f13 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 11 Jan 2010 14:23:49 +0000
Subject: [PATCH] Fix SDK issue 4421: Remove generic AsynchronousConnection parameter from ConnectionFactory.

---
 sdk/src/com/sun/opends/sdk/tools/AuthenticatedConnectionFactory.java |   97 ++++++++++++------------------------------------
 1 files changed, 25 insertions(+), 72 deletions(-)

diff --git a/sdk/src/com/sun/opends/sdk/tools/AuthenticatedConnectionFactory.java b/sdk/src/com/sun/opends/sdk/tools/AuthenticatedConnectionFactory.java
index 82675de..af0a786 100644
--- a/sdk/src/com/sun/opends/sdk/tools/AuthenticatedConnectionFactory.java
+++ b/sdk/src/com/sun/opends/sdk/tools/AuthenticatedConnectionFactory.java
@@ -67,69 +67,15 @@
  * then the connection attempt will fail and an {@code
  * ErrorResultException} will be thrown.
  */
-final class AuthenticatedConnectionFactory
-    implements
-    ConnectionFactory<AuthenticatedConnectionFactory.AuthenticatedAsynchronousConnection>
+final class AuthenticatedConnectionFactory extends
+    AbstractConnectionFactory implements ConnectionFactory
 {
-  // We implement the factory using the pimpl idiom in order have
-  // cleaner Javadoc which does not expose implementation methods from
-  // AbstractConnectionFactory.
 
-  private static final class Impl
-      extends
-      AbstractConnectionFactory<AuthenticatedConnectionFactory.AuthenticatedAsynchronousConnection>
-      implements
-      ConnectionFactory<AuthenticatedConnectionFactory.AuthenticatedAsynchronousConnection>
-  {
-    private final BindRequest request;
+  private final BindRequest request;
 
-    private final ConnectionFactory<?> parentFactory;
+  private final ConnectionFactory parentFactory;
 
-    private boolean allowRebinds = false;
-
-
-
-    private Impl(ConnectionFactory<?> factory, BindRequest request)
-        throws NullPointerException
-    {
-      Validator.ensureNotNull(factory, request);
-      this.parentFactory = factory;
-
-      // FIXME: should do a defensive copy.
-      this.request = request;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public FutureResult<AuthenticatedAsynchronousConnection> getAsynchronousConnection(
-        ResultHandler<? super AuthenticatedAsynchronousConnection> handler)
-    {
-      FutureResultImpl future = new FutureResultImpl(request, handler);
-      future.futureConnectionResult.setFutureResult(parentFactory
-          .getAsynchronousConnection(future.futureConnectionResult));
-      return future.futureBindResult;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public AuthenticatedConnection getConnection()
-        throws ErrorResultException
-    {
-      return new AuthenticatedConnection(
-          blockingGetAsynchronousConnection());
-    }
-
-  }
-
-
-
-  private final Impl impl;
+  private boolean allowRebinds = false;
 
 
 
@@ -555,17 +501,21 @@
    * @throws NullPointerException
    *           If {@code factory} or {@code request} was {@code null}.
    */
-  public AuthenticatedConnectionFactory(ConnectionFactory<?> factory,
+  public AuthenticatedConnectionFactory(ConnectionFactory factory,
       BindRequest request) throws NullPointerException
   {
-    impl = new Impl(factory, request);
+    Validator.ensureNotNull(factory, request);
+    this.parentFactory = factory;
+
+    // FIXME: should do a defensive copy.
+    this.request = request;
   }
 
 
 
   private static final class FutureResultImpl
   {
-    private final FutureResultTransformer<BindResult, AuthenticatedAsynchronousConnection> futureBindResult;
+    private final FutureResultTransformer<BindResult, AsynchronousConnection> futureBindResult;
 
     private final RecursiveFutureResult<AsynchronousConnection, BindResult> futureConnectionResult;
 
@@ -575,12 +525,11 @@
 
 
 
-    private FutureResultImpl(
-        BindRequest request,
-        ResultHandler<? super AuthenticatedAsynchronousConnection> handler)
+    private FutureResultImpl(BindRequest request,
+        ResultHandler<AsynchronousConnection> handler)
     {
       this.bindRequest = request;
-      this.futureBindResult = new FutureResultTransformer<BindResult, AuthenticatedAsynchronousConnection>(
+      this.futureBindResult = new FutureResultTransformer<BindResult, AsynchronousConnection>(
           handler)
       {
 
@@ -647,7 +596,7 @@
   public AuthenticatedConnectionFactory setRebindAllowed(
       boolean allowRebinds)
   {
-    impl.allowRebinds = allowRebinds;
+    this.allowRebinds = allowRebinds;
     return this;
   }
 
@@ -666,15 +615,18 @@
    */
   public boolean isRebindAllowed()
   {
-    return impl.allowRebinds;
+    return allowRebinds;
   }
 
 
 
-  public FutureResult<AuthenticatedAsynchronousConnection> getAsynchronousConnection(
-      ResultHandler<? super AuthenticatedAsynchronousConnection> handler)
+  public FutureResult<AsynchronousConnection> getAsynchronousConnection(
+      ResultHandler<AsynchronousConnection> handler)
   {
-    return impl.getAsynchronousConnection(handler);
+    FutureResultImpl future = new FutureResultImpl(request, handler);
+    future.futureConnectionResult.setFutureResult(parentFactory
+        .getAsynchronousConnection(future.futureConnectionResult));
+    return future.futureBindResult;
   }
 
 
@@ -682,7 +634,8 @@
   public AuthenticatedConnection getConnection()
       throws ErrorResultException
   {
-    return impl.getConnection();
+    return new AuthenticatedConnection(
+        (AuthenticatedAsynchronousConnection) blockingGetAsynchronousConnection());
   }
 
 }

--
Gitblit v1.10.0