From 41d93d231b0c81eff8a0c9b301f9ea9818440727 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 20 Jan 2014 16:32:41 +0000
Subject: [PATCH] Code review: Matthew Swift

---
 opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java b/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
index b6da837..08eb75e 100644
--- a/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
+++ b/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
@@ -29,6 +29,7 @@
 
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.SocketAddress;
 
 import com.forgerock.opendj.ldap.LDAPConnectionFactoryImpl;
 import com.forgerock.opendj.util.StaticUtils;
@@ -53,6 +54,38 @@
      *            The address of the Directory Server.
      * @throws NullPointerException
      *             If {@code address} was {@code null}.
+     * @deprecated use {@link #LDAPConnectionFactory(InetSocketAddress)} instead
+     */
+    @Deprecated
+    public LDAPConnectionFactory(final SocketAddress address) {
+        this((InetSocketAddress) address, new LDAPOptions());
+    }
+
+    /**
+     * Creates a new LDAP connection factory which can be used to create LDAP
+     * connections to the Directory Server at the provided address.
+     *
+     * @param address
+     *            The address of the Directory Server.
+     * @param options
+     *            The LDAP options to use when creating connections.
+     * @throws NullPointerException
+     *             If {@code address} or {@code options} was {@code null}.
+     * @deprecated use {@link #LDAPConnectionFactory(InetSocketAddress, LDAPOptions)} instead
+     */
+    @Deprecated
+    public LDAPConnectionFactory(final SocketAddress address, final LDAPOptions options) {
+        this((InetSocketAddress) address, options);
+    }
+
+    /**
+     * Creates a new LDAP connection factory which can be used to create LDAP
+     * connections to the Directory Server at the provided address.
+     *
+     * @param address
+     *            The address of the Directory Server.
+     * @throws NullPointerException
+     *             If {@code address} was {@code null}.
      */
     public LDAPConnectionFactory(final InetSocketAddress address) {
         this(address, new LDAPOptions());
@@ -117,7 +150,7 @@
      *         or {@code null} if it is unknown.
      */
     public InetAddress getAddress() {
-        return getSocketAddress().getAddress();
+        return getInetSocketAddress().getAddress();
     }
 
     @Override
@@ -143,9 +176,23 @@
      * will not perform a reverse DNS lookup.
      *
      * @return The host name that this LDAP listener is listening on.
+     * @deprecated use {@link #getHostName()} instead
+     */
+    @Deprecated
+    public String getHostname() {
+        return getHostName();
+    }
+
+    /**
+     * Returns the host name that this LDAP listener is listening on. The
+     * returned host name is the same host name that was provided during
+     * construction and may be an IP address. More specifically, this method
+     * will not perform a reverse DNS lookup.
+     *
+     * @return The host name that this LDAP listener is listening on.
      */
     public String getHostName() {
-        return StaticUtils.getHostName(getSocketAddress());
+        return StaticUtils.getHostName(getInetSocketAddress());
     }
 
     /**
@@ -154,7 +201,7 @@
      * @return The port that this LDAP listener is listening on.
      */
     public int getPort() {
-        return getSocketAddress().getPort();
+        return getInetSocketAddress().getPort();
     }
 
     /**
@@ -162,7 +209,11 @@
      *
      * @return The address that this LDAP listener is listening on.
      */
-    public InetSocketAddress getSocketAddress() {
+    public SocketAddress getSocketAddress() {
+        return getInetSocketAddress();
+    }
+
+    private InetSocketAddress getInetSocketAddress() {
         return impl.getSocketAddress();
     }
 

--
Gitblit v1.10.0