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/org/opends/sdk/LDAPConnectionFactory.java |   92 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/sdk/src/org/opends/sdk/LDAPConnectionFactory.java b/sdk/src/org/opends/sdk/LDAPConnectionFactory.java
index 5cbde4a..a632071 100644
--- a/sdk/src/org/opends/sdk/LDAPConnectionFactory.java
+++ b/sdk/src/org/opends/sdk/LDAPConnectionFactory.java
@@ -29,6 +29,7 @@
 
 
 
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 
@@ -131,8 +132,31 @@
 
 
   /**
+   * Returns the {@code InetAddress} that this LDAP listener is listening on.
+   *
+   * @return The {@code InetAddress} that this LDAP listener is listening on, or
+   *         {@code null} if it is unknown.
+   */
+  public InetAddress getAddress()
+  {
+    final SocketAddress socketAddress = getSocketAddress();
+    if (socketAddress instanceof InetSocketAddress)
+    {
+      final InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
+      return inetSocketAddress.getAddress();
+    }
+    else
+    {
+      return null;
+    }
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
+  @Override
   public FutureResult<AsynchronousConnection> getAsynchronousConnection(
       final ResultHandler<? super AsynchronousConnection> handler)
   {
@@ -144,9 +168,77 @@
   /**
    * {@inheritDoc}
    */
+  @Override
   public Connection getConnection() throws ErrorResultException,
       InterruptedException
   {
     return impl.getConnection();
   }
+
+
+
+  /**
+   * Returns the host name that this LDAP listener is listening on.
+   *
+   * @return The host name that this LDAP listener is listening on, or
+   *         {@code null} if it is unknown.
+   */
+  public String getHostname()
+  {
+    final SocketAddress socketAddress = getSocketAddress();
+    if (socketAddress instanceof InetSocketAddress)
+    {
+      final InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
+      return inetSocketAddress.getHostName();
+    }
+    else
+    {
+      return null;
+    }
+  }
+
+
+
+  /**
+   * Returns the port that this LDAP listener is listening on.
+   *
+   * @return The port that this LDAP listener is listening on, or {@code -1} if
+   *         it is unknown.
+   */
+  public int getPort()
+  {
+    final SocketAddress socketAddress = getSocketAddress();
+    if (socketAddress instanceof InetSocketAddress)
+    {
+      final InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
+      return inetSocketAddress.getPort();
+    }
+    else
+    {
+      return -1;
+    }
+  }
+
+
+
+  /**
+   * Returns the address that this LDAP listener is listening on.
+   *
+   * @return The address that this LDAP listener is listening on.
+   */
+  public SocketAddress getSocketAddress()
+  {
+    return impl.getSocketAddress();
+  }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String toString()
+  {
+    return impl.toString();
+  }
 }

--
Gitblit v1.10.0