From 72650d4cc41c64136d064967d7fec3726d850fee Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 14 Oct 2010 11:52:28 +0000
Subject: [PATCH] Multiple enhancements and bug fixes to the SDK (update from OpenDS by matthew_swift):

---
 sdk/src/com/sun/opends/sdk/ldap/GlobalTransportFactory.java |   48 +++++++++++++++++++++---------------------------
 1 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/sdk/src/com/sun/opends/sdk/ldap/GlobalTransportFactory.java b/sdk/src/com/sun/opends/sdk/ldap/GlobalTransportFactory.java
index 85d102d..a4d92bc 100644
--- a/sdk/src/com/sun/opends/sdk/ldap/GlobalTransportFactory.java
+++ b/sdk/src/com/sun/opends/sdk/ldap/GlobalTransportFactory.java
@@ -31,11 +31,11 @@
 
 import java.io.IOException;
 
-import com.sun.grizzly.TransportFactory;
-import com.sun.grizzly.nio.NIOTransportFactory;
-import com.sun.grizzly.nio.transport.TCPNIOTransport;
-import com.sun.grizzly.nio.transport.UDPNIOTransport;
-import com.sun.grizzly.threadpool.ThreadPoolConfig;
+import org.glassfish.grizzly.TransportFactory;
+import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
+import org.glassfish.grizzly.nio.transport.UDPNIOTransport;
+import org.glassfish.grizzly.threadpool.ThreadPoolConfig;
+
 import com.sun.opends.sdk.util.StaticUtils;
 
 
@@ -43,9 +43,9 @@
 /**
  * A static Grizzly transport that can be used by default globally in the SDK.
  */
-public final class GlobalTransportFactory extends NIOTransportFactory
+public final class GlobalTransportFactory extends TransportFactory
 {
-  private static final GlobalTransportFactory INSTANCE = new GlobalTransportFactory();
+  private static boolean isInitialized = false;
 
 
 
@@ -54,22 +54,14 @@
    *
    * @return The global Grizzly transport factory.
    */
-  public static TransportFactory getInstance()
+  public static synchronized TransportFactory getInstance()
   {
-    return INSTANCE;
-  }
-
-
-
-  /**
-   * Sets the global Grizzly transport factory.
-   *
-   * @param factory
-   *          The global Grizzly transport factory.
-   */
-  public static void setInstance(final TransportFactory factory)
-  {
-    throw new UnsupportedOperationException("not yet implemented");
+    if (!isInitialized)
+    {
+      TransportFactory.setInstance(new GlobalTransportFactory());
+      isInitialized = true;
+    }
+    return TransportFactory.getInstance();
   }
 
 
@@ -94,7 +86,7 @@
 
 
   /**
-   * Close the {@link com.sun.grizzly.TransportFactory} and release all
+   * Close the {@link org.glassfish.grizzly.TransportFactory} and release all
    * resources.
    */
   @Override
@@ -118,9 +110,9 @@
 
 
   /**
-   * Create instance of TCP {@link com.sun.grizzly.Transport}.
+   * Create instance of TCP {@link org.glassfish.grizzly.Transport}.
    *
-   * @return instance of TCP {@link com.sun.grizzly.Transport}.
+   * @return instance of TCP {@link org.glassfish.grizzly.Transport}.
    */
   @Override
   public synchronized TCPNIOTransport createTCPTransport()
@@ -149,8 +141,9 @@
 
 
   /**
-   * Creating an UDP transport is unsupported with this factory. A {@code
-   * UnsupportedOperationException} will be thrown when this method is called.
+   * Creating an UDP transport is unsupported with this factory. A
+   * {@code UnsupportedOperationException} will be thrown when this method is
+   * called.
    *
    * @return This method will always throw {@code UnsupportedOperationException}
    *         .
@@ -210,4 +203,5 @@
 
     super.initialize();
   }
+
 }

--
Gitblit v1.10.0