From 97491bcdb796a35879477018ea768c1be2c989e4 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 22 Oct 2010 06:52:25 +0000
Subject: [PATCH] Sync commit by matthew_swift Expose Grizzly transport configuration in LDAPOptions and LDAPListenerOptions in order to allow better customization of transport.

---
 sdk/src/org/opends/sdk/LDAPOptions.java |   50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/sdk/src/org/opends/sdk/LDAPOptions.java b/sdk/src/org/opends/sdk/LDAPOptions.java
index 6e5a5d7..ac0acaa 100644
--- a/sdk/src/org/opends/sdk/LDAPOptions.java
+++ b/sdk/src/org/opends/sdk/LDAPOptions.java
@@ -29,11 +29,14 @@
 
 
 
-import java.util.*;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
 
+import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
+
 import com.sun.opends.sdk.util.Validator;
 
 
@@ -41,7 +44,7 @@
 /**
  * Common options for LDAP client connections.
  */
-public class LDAPOptions
+public final class LDAPOptions
 {
   private SSLContext sslContext;
 
@@ -61,6 +64,8 @@
    */
   private List<String> enabledProtocols = new LinkedList<String>();
 
+  private TCPNIOTransport transport;
+
 
 
   /**
@@ -69,11 +74,11 @@
    */
   public LDAPOptions()
   {
-    super();
     this.sslContext = null;
     this.timeoutInMillis = 0;
     this.useStartTLS = false;
     this.decodeOptions = new DecodeOptions();
+    this.transport = null;
   }
 
 
@@ -93,6 +98,7 @@
     this.decodeOptions = new DecodeOptions(options.decodeOptions);
     this.enabledCipherSuites.addAll(options.getEnabledCipherSuites());
     this.enabledProtocols.addAll(options.getEnabledProtocols());
+    this.transport = options.transport;
   }
 
 
@@ -130,6 +136,23 @@
 
 
   /**
+   * Returns the Grizzly TCP transport which will be used when initiating
+   * connections with the Directory Server. By default this method will return
+   * {@code null} indicating that the default transport factory should be used
+   * to obtain a TCP transport.
+   *
+   * @return The Grizzly TCP transport which will be used when initiating
+   *         connections with the Directory Server, or {@code null} if the
+   *         default transport factory should be used to obtain a TCP transport.
+   */
+  public final TCPNIOTransport getTCPNIOTransport()
+  {
+    return transport;
+  }
+
+
+
+  /**
    * Returns the operation timeout in the specified unit.
    *
    * @param unit
@@ -186,6 +209,27 @@
 
 
   /**
+   * Sets the Grizzly TCP transport which will be used when initiating
+   * connections with the Directory Server. By default this method will return
+   * {@code null} indicating that the default transport factory will be used to
+   * obtain a TCP transport.
+   *
+   * @param transport
+   *          The Grizzly TCP transport which will be used when initiating
+   *          connections with the Directory Server, or {@code null} if the
+   *          default transport factory should be used to obtain a TCP
+   *          transport.
+   * @return A reference to this LDAP connection options.
+   */
+  public final LDAPOptions setTCPNIOTransport(final TCPNIOTransport transport)
+  {
+    this.transport = transport;
+    return this;
+  }
+
+
+
+  /**
    * Sets the operation timeout. If the response is not received from the
    * Directory Server in the timeout period, the operation will be abandoned and
    * an error result returned. A timeout setting of 0 disables timeout limits.

--
Gitblit v1.10.0