src/share/classes/com/sun/jndi/ldap/ServiceLocator.java
Print this page
@@ -24,25 +24,21 @@
*/
package com.sun.jndi.ldap;
import java.util.Arrays;
-import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.NoSuchElementException;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.List;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.spi.NamingManager;
import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;
-import com.sun.jndi.ldap.LdapURL;
-
/**
* This class discovers the location of LDAP services by querying DNS.
* See http://www.ietf.org/internet-drafts/draft-ietf-ldapext-locate-07.txt
*/
@@ -76,14 +72,14 @@
LdapName ldapName = new LdapName(dn);
// process RDNs left-to-right
//List<Rdn> rdnList = ldapName.getRdns();
- List rdnList = ldapName.getRdns();
+ List<Rdn> rdnList = ldapName.getRdns();
for (int i = rdnList.size() - 1; i >= 0; i--) {
//Rdn rdn = rdnList.get(i);
- Rdn rdn = (Rdn) rdnList.get(i);
+ Rdn rdn = rdnList.get(i);
// single-valued RDN with a DC attribute
if ((rdn.size() == 1) &&
("dc".equalsIgnoreCase(rdn.getType()) )) {
Object attrval = rdn.getValue();
@@ -115,11 +111,11 @@
* @param domainName A string domain name.
* @param environment The possibly null environment of the context.
* @return An ordered list of hostports for the LDAP service or null if
* the service has not been located.
*/
- static String[] getLdapService(String domainName, Hashtable environment) {
+ static String[] getLdapService(String domainName, Hashtable<?,?> environment) {
if (domainName == null || domainName.length() == 0) {
return null;
}
@@ -250,11 +246,11 @@
/**
* This class holds a DNS service (SRV) record.
* See http://www.ietf.org/rfc/rfc2782.txt
*/
-static class SrvRecord implements Comparable {
+static class SrvRecord implements Comparable<SrvRecord> {
int priority;
int weight;
int sum;
String hostport;
@@ -282,12 +278,11 @@
/*
* Sort records in ascending order of priority value. For records with
* equal priority move those with weight 0 to the top of the list.
*/
- public int compareTo(Object o) {
- SrvRecord that = (SrvRecord) o;
+ public int compareTo(SrvRecord that) {
if (priority > that.priority) {
return 1; // this > that
} else if (priority < that.priority) {
return -1; // this < that
} else if (weight == 0 && that.weight != 0) {