From 7057e430ce059963724928296ff166e68b4e2ebb Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 09 Apr 2013 09:58:22 +0000
Subject: [PATCH] Partial fix for OPENDJ-856: Make Rest2LDAP close the cached authenticated connection

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnectionWrapper.java |   53 ++++++++++++++++++++++-------------------------------
 1 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnectionWrapper.java
similarity index 93%
rename from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java
rename to opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnectionWrapper.java
index e865863..5de8c93 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnectionWrapper.java
@@ -25,21 +25,10 @@
  *      Portions copyright 2011-2013 ForgeRock AS
  */
 
-package com.forgerock.opendj.util;
+package org.forgerock.opendj.ldap;
 
 import java.util.Collection;
 
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.Connection;
-import org.forgerock.opendj.ldap.ConnectionEventListener;
-import org.forgerock.opendj.ldap.DN;
-import org.forgerock.opendj.ldap.Entry;
-import org.forgerock.opendj.ldap.ErrorResultException;
-import org.forgerock.opendj.ldap.FutureResult;
-import org.forgerock.opendj.ldap.IntermediateResponseHandler;
-import org.forgerock.opendj.ldap.ResultHandler;
-import org.forgerock.opendj.ldap.SearchResultHandler;
-import org.forgerock.opendj.ldap.SearchScope;
 import org.forgerock.opendj.ldap.requests.AbandonRequest;
 import org.forgerock.opendj.ldap.requests.AddRequest;
 import org.forgerock.opendj.ldap.requests.BindRequest;
@@ -60,24 +49,26 @@
 import org.forgerock.opendj.ldif.ChangeRecord;
 import org.forgerock.opendj.ldif.ConnectionEntryReader;
 
+import com.forgerock.opendj.util.Validator;
+
 /**
- * A base class from which connection decorators may be easily implemented. The
- * default implementation of each method is to delegate to the decorated
- * connection.
+ * An abstract base class from which connection wrappers may be easily
+ * implemented. The default implementation of each method is to delegate to the
+ * wrapped connection.
  */
-public abstract class ConnectionDecorator implements Connection {
+public abstract class AbstractConnectionWrapper implements Connection {
     /**
-     * The decorated connection.
+     * The wrapped connection.
      */
     protected final Connection connection;
 
     /**
-     * Creates a new connection decorator.
+     * Creates a new connection wrapper.
      *
      * @param connection
-     *            The connection to be decorated.
+     *            The connection to be wrapped.
      */
-    protected ConnectionDecorator(final Connection connection) {
+    protected AbstractConnectionWrapper(final Connection connection) {
         Validator.ensureNotNull(connection);
         this.connection = connection;
     }
@@ -140,7 +131,17 @@
      * The default implementation is to delegate.
      */
     @Override
-    public Result applyChange(ChangeRecord request) throws ErrorResultException {
+    public void addConnectionEventListener(final ConnectionEventListener listener) {
+        connection.addConnectionEventListener(listener);
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * The default implementation is to delegate.
+     */
+    @Override
+    public Result applyChange(final ChangeRecord request) throws ErrorResultException {
         return connection.applyChange(request);
     }
 
@@ -162,16 +163,6 @@
      * The default implementation is to delegate.
      */
     @Override
-    public void addConnectionEventListener(final ConnectionEventListener listener) {
-        connection.addConnectionEventListener(listener);
-    }
-
-    /**
-     * {@inheritDoc}
-     * <p>
-     * The default implementation is to delegate.
-     */
-    @Override
     public BindResult bind(final BindRequest request) throws ErrorResultException {
         return connection.bind(request);
     }

--
Gitblit v1.10.0