diff --git a/build/resources/releasedocs/README.html b/build/resources/releasedocs/README.html index de92dbc8f..f935622c9 100644 --- a/build/resources/releasedocs/README.html +++ b/build/resources/releasedocs/README.html @@ -203,6 +203,36 @@ last release. to use these icons outside of Smack.
  • Third-party source code is licensed as noted in their source files. +
  • Third-party binary code is licensed as follows. +
    + dnsjava (http://dnsjava.org)
    +
    + Copyright (c) 1999-2005, Brian Wellington
    + All rights reserved.
    +	
    + Redistribution and use in source and binary forms, with or without
    + modification, are permitted provided that the following conditions are met:
    +	
    +     * Redistributions of source code must retain the above copyright notice,
    +       this list of conditions and the following disclaimer.
    +     * Redistributions in binary form must reproduce the above copyright notice,
    +       this list of conditions and the following disclaimer in the documentation
    +       and/or other materials provided with the distribution.
    +     * Neither the name of the dnsjava project nor the names of its contributors
    +       may be used to endorse or promote products derived from this software
    +       without specific prior written permission.
    +	
    + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
    + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    +
  • diff --git a/source/org/jivesoftware/smack/util/dns/DNSJavaResolver.java b/source/org/jivesoftware/smack/util/dns/DNSJavaResolver.java index 91db73b1a..dd93fd3ae 100644 --- a/source/org/jivesoftware/smack/util/dns/DNSJavaResolver.java +++ b/source/org/jivesoftware/smack/util/dns/DNSJavaResolver.java @@ -22,18 +22,19 @@ import org.xbill.DNS.Lookup; import org.xbill.DNS.Record; import org.xbill.DNS.Type; -public class DNSJavaResolver extends DNSResolver { +/** + * This implementation uses the dnsjava implementation for resolving DNS addresses. + * + */ +public class DNSJavaResolver implements DNSResolver { - private static DNSJavaResolver instance; + private static DNSJavaResolver instance = new DNSJavaResolver(); private DNSJavaResolver() { } public static DNSResolver getInstance() { - if (instance == null) { - instance = new DNSJavaResolver(); - } return instance; } diff --git a/source/org/jivesoftware/smack/util/dns/DNSResolver.java b/source/org/jivesoftware/smack/util/dns/DNSResolver.java index 2c5dd296c..86f037b6f 100644 --- a/source/org/jivesoftware/smack/util/dns/DNSResolver.java +++ b/source/org/jivesoftware/smack/util/dns/DNSResolver.java @@ -17,8 +17,17 @@ package org.jivesoftware.smack.util.dns; import java.util.List; -public abstract class DNSResolver { +/** + * Implementations of this interface define a class that is capable of resolving DNS addresses. + * + */ +public interface DNSResolver { - public abstract List lookupSRVRecords(String name); + /** + * Gets a list of service records for the specified service. + * @param name The symbolic name of the service. + * @return The list of SRV records mapped to the service name. + */ + List lookupSRVRecords(String name); } diff --git a/source/org/jivesoftware/smack/util/dns/HostAddress.java b/source/org/jivesoftware/smack/util/dns/HostAddress.java index 978a6de69..eb8b07ad7 100644 --- a/source/org/jivesoftware/smack/util/dns/HostAddress.java +++ b/source/org/jivesoftware/smack/util/dns/HostAddress.java @@ -23,10 +23,10 @@ public class HostAddress { /** * Creates a new HostAddress with the given FQDN. The port will be set to the default XMPP client port: 5222 * - * @param fqdn - * @throws IllegalArgumentException + * @param fqdn Fully qualified domain name. + * @throws IllegalArgumentException If the fqdn is null. */ - public HostAddress(String fqdn) throws IllegalArgumentException { + public HostAddress(String fqdn) { if (fqdn == null) throw new IllegalArgumentException("FQDN is null"); if (fqdn.charAt(fqdn.length() - 1) == '.') { @@ -39,7 +39,14 @@ public class HostAddress { this.port = 5222; } - public HostAddress(String fqdn, int port) throws IllegalArgumentException { + /** + * Creates a new HostAddress with the given FQDN. The port will be set to the default XMPP client port: 5222 + * + * @param fqdn Fully qualified domain name. + * @param port The port to connect on. + * @throws IllegalArgumentException If the fqdn is null or port is out of valid range (0 - 65535). + */ + public HostAddress(String fqdn, int port) { this(fqdn); if (port < 0 || port > 65535) throw new IllegalArgumentException( @@ -60,10 +67,12 @@ public class HostAddress { this.exception = e; } + @Override public String toString() { return fqdn + ":" + port; } + @Override public boolean equals(Object o) { if (this == o) { return true; @@ -80,6 +89,13 @@ public class HostAddress { return port == address.port; } + @Override + public int hashCode() { + int result = 1; + result = 37 * result + fqdn.hashCode(); + return result * 37 + port; + } + public String getErrorMessage() { String error; if (exception == null) { diff --git a/source/org/jivesoftware/smack/util/dns/JavaxResolver.java b/source/org/jivesoftware/smack/util/dns/JavaxResolver.java index 4ea361fdf..ae3dbf6f6 100644 --- a/source/org/jivesoftware/smack/util/dns/JavaxResolver.java +++ b/source/org/jivesoftware/smack/util/dns/JavaxResolver.java @@ -28,12 +28,12 @@ import javax.naming.directory.InitialDirContext; import org.jivesoftware.smack.util.DNSUtil; /** - * A DNS resolver (mostly for SRV records), which makes use of the API provided in the javax.* namepsace. + * A DNS resolver (mostly for SRV records), which makes use of the API provided in the javax.* namespace. * * @author Florian Schmaus * */ -public class JavaxResolver extends DNSResolver { +public class JavaxResolver implements DNSResolver { private static JavaxResolver instance; private static DirContext dirContext; @@ -48,14 +48,14 @@ public class JavaxResolver extends DNSResolver { } // Try to set this DNS resolver as primary one - DNSUtil.setDNSResolver(maybeGetInstance()); + DNSUtil.setDNSResolver(getInstance()); } private JavaxResolver() { } - public static DNSResolver maybeGetInstance() { + public static DNSResolver getInstance() { if (instance == null && isSupported()) { instance = new JavaxResolver(); } diff --git a/source/org/jivesoftware/smack/util/dns/SRVRecord.java b/source/org/jivesoftware/smack/util/dns/SRVRecord.java index 87c6e54fc..457e40eca 100644 --- a/source/org/jivesoftware/smack/util/dns/SRVRecord.java +++ b/source/org/jivesoftware/smack/util/dns/SRVRecord.java @@ -29,13 +29,13 @@ public class SRVRecord extends HostAddress implements Comparable { /** * Create a new SRVRecord * - * @param fqdn - * @param port - * @param priority - * @param weight - * @throws IllegalArgumentException + * @param fqdn Fully qualified domain name + * @param port The connection port + * @param priority Priority of the target host + * @param weight Relative weight for records with same priority + * @throws IllegalArgumentException fqdn is null or any other field is not in valid range (0-65535). */ - public SRVRecord(String fqdn, int port, int priority, int weight) throws IllegalArgumentException { + public SRVRecord(String fqdn, int port, int priority, int weight) { super(fqdn, port); if (weight < 0 || weight > 65535) throw new IllegalArgumentException( @@ -60,6 +60,7 @@ public class SRVRecord extends HostAddress implements Comparable { return weight; } + @Override public int compareTo(SRVRecord other) { // According to RFC2782, // "[a] client MUST attempt to contact the target host with the lowest-numbered priority it can reach". @@ -71,6 +72,7 @@ public class SRVRecord extends HostAddress implements Comparable { return res; } + @Override public String toString() { return super.toString() + " prio:" + priority + ":w:" + weight; } diff --git a/test-unit/org/jivesoftware/smack/util/DNSUtilTest.java b/test-unit/org/jivesoftware/smack/util/DNSUtilTest.java index d107f8f0d..2cc7c96c5 100644 --- a/test-unit/org/jivesoftware/smack/util/DNSUtilTest.java +++ b/test-unit/org/jivesoftware/smack/util/DNSUtilTest.java @@ -24,7 +24,7 @@ public class DNSUtilTest { @Test public void xmppClientDomainJavaXTest() { - DNSResolver resolver = JavaxResolver.maybeGetInstance(); + DNSResolver resolver = JavaxResolver.getInstance(); assertNotNull(resolver); DNSUtil.setDNSResolver(resolver); xmppClientDomainTest(); @@ -32,7 +32,7 @@ public class DNSUtilTest { @Test public void xmppServerDomainJavaXTest() { - DNSResolver resolver = JavaxResolver.maybeGetInstance(); + DNSResolver resolver = JavaxResolver.getInstance(); assertNotNull(resolver); DNSUtil.setDNSResolver(resolver); xmppServerDomainTest();