remoting/src/main/java/org/springframework/security/remoting/dns/JndiDnsResolver.java
private String resolveServiceEntry(String serviceType, String domain,
			DirContext ctx) {
		String result = null;
		try {
			String query = new StringBuilder("_").append(serviceType).append("._tcp.")
					.append(domain).toString();
			Attribute dnsRecord = lookup(query, ctx, "SRV");
			// There are maybe more records defined, we will return the one
			// with the highest priority (lowest number) and the highest weight
			// (highest number)
			int highestPriority = -1;
			int highestWeight = -1;

			for (NamingEnumeration<?> recordEnum = dnsRecord.getAll(); recordEnum
					.hasMoreElements();) {
				String[] record = recordEnum.next().toString().split(" ");
				if (record.length != 4) {
					throw new DnsLookupException("Wrong service record for query " + query
							+ ": [" + Arrays.toString(record) + "]");
				}
				int priority = Integer.parseInt(record[0]);
				int weight = Integer.parseInt(record[1]);
				// we have a new highest Priority, so forget also the highest weight
				if (priority < highestPriority || highestPriority == -1) {
					highestPriority = priority;
					highestWeight = weight;
					result = record[3].trim();
				}
				// same priority, but higher weight
				if (priority == highestPriority && weight > highestWeight) {
					highestWeight = weight;
					result = record[3].trim();
				}
			}
		}
		catch (NamingException e) {
			throw new DnsLookupException(
					"DNS lookup failed for service " + serviceType + " at " + domain, e);
		}

		// remove the "." at the end
		if (result.endsWith(".")) {
			result = result.substring(0, result.length() - 1);
		}
		return result;
	}
private String resolveServiceEntry(String serviceType, String domain,
			DirContext ctx) {
		String result = null;
		try {
			String query = new StringBuilder("_").append(serviceType).append("._tcp.")
					.append(domain).toString();
			Attribute dnsRecord = lookup(query, ctx, "SRV");
			// There are maybe more records defined, we will return the one
			// with the highest priority (lowest number) and the highest weight
			// (highest number)
			int highestPriority = -1;
			int highestWeight = -1;

			for (NamingEnumeration<?> recordEnum = dnsRecord.getAll(); recordEnum
					.hasMoreElements();) {
				String[] record = recordEnum.next().toString().split(" ");
				if (record.length != 4) {
					throw new DnsLookupException("Wrong service record for query " + query
							+ ": [" + Arrays.toString(record) + "]");
				}
				int priority = Integer.parseInt(record[0]);
				int weight = Integer.parseInt(record[1]);
				// we have a new highest Priority, so forget also the highest weight
				if (priority < highestPriority || highestPriority == -1) {
					highestPriority = priority;
					highestWeight = weight;
					result = record[3].trim();
				}
				// same priority, but higher weight
				if (priority == highestPriority && weight > highestWeight) {
					highestWeight = weight;
					result = record[3].trim();
				}
			}
		}
		catch (NamingException e) {
			throw new DnsLookupException(
					"DNS lookup failed for service " + serviceType + " at " + domain, e);
		}

		// remove the "." at the end
		if (result.endsWith(".")) {
			result = result.substring(0, result.length() - 1);
		}
		return result;
	}
private String resolveServiceEntry ( String serviceType , String domain , DirContext ctx ) { String result = null ; try { String query = new StringBuilder ( "_" ) . append ( serviceType ) . append ( "._tcp." ) . append ( domain ) . toString ( ) ; Attribute dnsRecord = lookup ( query , ctx , "SRV" ) ; // There are maybe more records defined, we will return the one // with the highest priority (lowest number) and the highest weight // (highest number) int highestPriority = - 1 ; int highestWeight = - 1 ; for ( NamingEnumeration < ? > recordEnum = dnsRecord . getAll ( ) ; recordEnum . hasMoreElements ( ) ; ) { String [ ] record = recordEnum . next ( ) . toString ( ) . split ( " " ) ; if ( record . length != 4 ) { throw new DnsLookupException ( "Wrong service record for query " + query + ": [" + Arrays . toString ( record ) + "]" ) ; } int priority = Integer . parseInt ( record [ 0 ] ) ; int weight = Integer . parseInt ( record [ 1 ] ) ; // we have a new highest Priority, so forget also the highest weight if ( priority < highestPriority || highestPriority == - 1 ) { highestPriority = priority ; highestWeight = weight ; result = record [ 3 ] . trim ( ) ; } // same priority, but higher weight if ( priority == highestPriority && weight > highestWeight ) { highestWeight = weight ; result = record [ 3 ] . trim ( ) ; } } } catch ( NamingException e ) { throw new DnsLookupException ( "DNS lookup failed for service " + serviceType + " at " + domain , e ) ; } // remove the "." at the end if ( result . endsWith ( "." ) ) { result = result . substring ( 0 , result . length ( ) - 1 ) ; } return result ; }
resolveServiceIpAddress().
resolveServiceIpAddress () .