From 3f7ddbf313aaabbfba4650cb2036cb41e51a9bde Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 18 Apr 2013 11:37:28 +0000
Subject: [PATCH] Fix OPENDJ-838: Add ConnectionFactory.close() method to facilitate resource cleanup after application exit
---
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java
index 3be6d5c..af6bf07 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java
@@ -22,11 +22,13 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011-2012 ForgeRock AS.
+ * Portions copyright 2011-2013 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
+import java.io.Closeable;
+
/**
* A connection factory provides an interface for obtaining a connection to a
* Directory Server. Connection factories can be used to wrap other connection
@@ -49,7 +51,28 @@
* should aim to close connections as soon as possible in order to avoid
* resource contention.
*/
-public interface ConnectionFactory {
+public interface ConnectionFactory extends Closeable {
+
+ /**
+ * Releases any resources associated with this connection factory. Depending
+ * on the implementation a factory may:
+ * <ul>
+ * <li>do nothing
+ * <li>close underlying connection factories (e.g. load-balancers)
+ * <li>close pooled connections (e.g. connection pools)
+ * <li>shutdown IO event service and related thread pools (e.g. Grizzly).
+ * </ul>
+ * Calling {@code close} on a connection factory which is already closed has
+ * no effect.
+ * <p>
+ * Applications should avoid closing connection factories while there are
+ * remaining active connections in use or connection attempts in progress.
+ *
+ * @see Connections#uncloseable(ConnectionFactory)
+ */
+ @Override
+ public void close();
+
/**
* Asynchronously obtains a connection to the Directory Server associated
* with this connection factory. The returned {@code FutureResult} can be
--
Gitblit v1.10.0