Author: norman
Date: Fri Jan 7 19:56:39 2011
New Revision: 1056477
URL: http://svn.apache.org/viewvc?rev=1056477&view=rev
Log:
Remove DNSService.getSMTPHostAddresses(String domainName) throws
TemporaryResolutionException from DNSService API. See JAMES-1178
Modified:
james/server/trunk/dnsservice-api/pom.xml
james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java
james/server/trunk/dnsservice-dnsjava/pom.xml
james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
james/server/trunk/mailetcontainer-library/pom.xml
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerDNSServiceAdapter.java
Modified: james/server/trunk/dnsservice-api/pom.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/dnsservice-api/pom.xml?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
--- james/server/trunk/dnsservice-api/pom.xml (original)
+++ james/server/trunk/dnsservice-api/pom.xml Fri Jan 7 19:56:39 2011
@@ -63,15 +63,6 @@
<dependencies>
<dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>apache-mailet</artifactId>
- </dependency>
- <!-- needed for javax.mail.URLname (Iterable<HostAddress> ?) -->
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified:
james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
---
james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java
(original)
+++
james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java
Fri Jan 7 19:56:39 2011
@@ -21,9 +21,7 @@ package org.apache.james.dnsservice.api;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collection;
-import java.util.Iterator;
-import org.apache.mailet.HostAddress;
/**
* Provides abstraction for DNS resolutions. The interface is Mail specific.
@@ -56,25 +54,7 @@ public interface DNSService {
Collection<String> findTXTRecords(String hostname);
- /**
- * Returns an Iterator over org.apache.mailet.HostAddress, a
- * specialized subclass of javax.mail.URLName, which provides
- * location information for servers that are specified as mail
- * handlers for the given hostname. This is done using MX records,
- * and the HostAddress instances are returned sorted by MX priority.
- * If no host is found for domainName, the Iterator returned will be
- * empty and the first call to hasNext() will return false. The
- * Iterator is a nested iterator: the outer iteration is over the
- * results of the MX record lookup, and the inner iteration is over
- * potentially multiple A records for each MX record. DNS lookups
- * are deferred until actually needed.
- *
- * @param domainName - the domain for which to find mail servers
- * @return an Iterator over HostAddress instances, sorted by priority
- * @throws TemporaryResolutionException get thrown on temporary problems
- */
- Iterator<HostAddress> getSMTPHostAddresses(String domainName) throws
TemporaryResolutionException;
-
+
/**
* Resolve the given hostname to an array of InetAddress based on the DNS
Server.
* It should not take into account the hostnames defined in the local
Modified: james/server/trunk/dnsservice-dnsjava/pom.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/pom.xml?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
--- james/server/trunk/dnsservice-dnsjava/pom.xml (original)
+++ james/server/trunk/dnsservice-dnsjava/pom.xml Fri Jan 7 19:56:39 2011
@@ -66,19 +66,11 @@
<groupId>org.apache.james</groupId>
<artifactId>james-server-dnsservice-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>apache-mailet</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>james-server-lifecycle-api</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-util</artifactId>
- </dependency>
- <dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
</dependency>
Modified:
james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
---
james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
(original)
+++
james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
Fri Jan 7 19:56:39 2011
@@ -38,8 +38,6 @@ import org.apache.james.dnsservice.api.D
import org.apache.james.dnsservice.api.TemporaryResolutionException;
import org.apache.james.lifecycle.api.Configurable;
import org.apache.james.lifecycle.api.LogEnabled;
-import org.apache.james.util.MXHostAddressIterator;
-import org.apache.mailet.HostAddress;
import org.xbill.DNS.ARecord;
import org.xbill.DNS.Cache;
import org.xbill.DNS.Credibility;
@@ -100,12 +98,6 @@ public class DNSJavaService implements D
* The MX Comparator used in the MX sort.
*/
private Comparator<MXRecord> mxComparator = new MXRecordComparator();
-
- /**
- * If true than the DNS server will return only a single IP per each MX
record
- * when looking up SMTPServers
- */
- private boolean singleIPPerMX;
/**
* If true register this service as the default resolver/cache for DNSJava
static
@@ -163,7 +155,7 @@ public class DNSJavaService implements D
}
}
- singleIPPerMX = configuration.getBoolean( "singleIPperMX", false );
+ //singleIPPerMX = configuration.getBoolean( "singleIPperMX", false );
setAsDNSJavaDefault = configuration.getBoolean( "setAsDNSJavaDefault"
,true );
@@ -441,13 +433,6 @@ public class DNSJavaService implements D
}
}
- /**
- * @see
org.apache.james.dnsservice.api.DNSService#getSMTPHostAddresses(String)
- */
- public Iterator<HostAddress> getSMTPHostAddresses(final String domainName)
throws TemporaryResolutionException {
- Iterator<String> mxHosts = findMXRecords(domainName).iterator();
- return new MXHostAddressIterator(mxHosts, this, singleIPPerMX, logger);
- }
/* java.net.InetAddress.get[All]ByName(String) allows an IP literal
* to be passed, and will recognize it even with a trailing '.'.
Modified:
james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
---
james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
(original)
+++
james/server/trunk/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
Fri Jan 7 19:56:39 2011
@@ -22,7 +22,6 @@ package org.apache.james.dnsservice.dnsj
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.james.dnsservice.dnsjava.DNSJavaService;
-import org.apache.mailet.HostAddress;
import org.xbill.DNS.Cache;
import org.xbill.DNS.DClass;
import org.xbill.DNS.Lookup;
@@ -39,7 +38,6 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Collection;
-import java.util.Iterator;
import junit.framework.TestCase;
@@ -68,8 +66,8 @@ public class DNSJavaServiceTest extends
assertEquals(1, records.size());
assertEquals("badhost.dnstest.com.", records.iterator()
.next());
- Iterator<HostAddress> it =
dnsServer.getSMTPHostAddresses("badmx.dnstest.com.");
- assertFalse(it.hasNext());
+ //Iterator<HostAddress> it =
dnsServer.getSMTPHostAddresses("badmx.dnstest.com.");
+ // assertFalse(it.hasNext());
}
public void testINARecords() throws Exception {
@@ -98,15 +96,16 @@ public class DNSJavaServiceTest extends
assertEquals("mail.test-zone.com.",res.iterator().next());
}
+ /*
public void testCNAMEasMXrecords() throws Exception {
// Zone z = loadZone("brandilyncollins.com.");
dnsServer.setResolver(null);
dnsServer.setCache(new ZoneCache("brandilyncollins.com."));
// dnsServer.setLookupper(new ZoneLookupper(z));
- Iterator<HostAddress> records =
dnsServer.getSMTPHostAddresses("brandilyncollins.com.");
- assertEquals(true, records.hasNext());
+ //Iterator<HostAddress> records =
dnsServer.getSMTPHostAddresses("brandilyncollins.com.");
+ //assertEquals(true, records.hasNext());
}
-
+*/
protected void setUp() throws Exception {
dnsServer = new TestableDNSServer();
DefaultConfigurationBuilder db = new DefaultConfigurationBuilder();
Modified: james/server/trunk/mailetcontainer-library/pom.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/pom.xml?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/pom.xml (original)
+++ james/server/trunk/mailetcontainer-library/pom.xml Fri Jan 7 19:56:39 2011
@@ -85,6 +85,10 @@
<groupId>org.apache.james</groupId>
<artifactId>james-server-dnsservice-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-util</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
Modified:
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
---
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java
(original)
+++
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java
Fri Jan 7 19:56:39 2011
@@ -53,6 +53,7 @@ import org.apache.james.lifecycle.api.Lo
import org.apache.james.mailetcontainer.api.MailProcessor;
import org.apache.james.user.api.UsersRepository;
import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.util.MXHostAddressIterator;
import org.apache.mailet.HostAddress;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
@@ -76,7 +77,8 @@ public class JamesMailetContext implemen
private DomainList domains;
private MailAddress postmaster;
-
+
+
@Resource(name="mailprocessor")
public void setMailProcessor(MailProcessor processorList) {
@@ -318,7 +320,7 @@ public class JamesMailetContext implemen
*/
public Iterator<HostAddress> getSMTPHostAddresses(String domainName) {
try {
- return dns.getSMTPHostAddresses(domainName);
+ return new
MXHostAddressIterator(dns.findMXRecords(domainName).iterator(), dns, false,
log);
} catch (TemporaryResolutionException e) {
// TODO: We only do this to not break backward compatiblity. Should
// fixed later
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
---
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
(original)
+++
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
Fri Jan 7 19:56:39 2011
@@ -835,7 +835,7 @@ public class RemoteDelivery extends Gene
//Lookup the possible targets
try {
- targetServers = dnsServer.getSMTPHostAddresses(host);
+ targetServers = new
MXHostAddressIterator(dnsServer.findMXRecords(host).iterator(), dnsServer,
false, logAdapter);
} catch (TemporaryResolutionException e) {
log("Temporary problem looking up mail server for host: "
+ host);
StringBuilder exceptionBuffer =
Modified:
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerDNSServiceAdapter.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerDNSServiceAdapter.java?rev=1056477&r1=1056476&r2=1056477&view=diff
==============================================================================
---
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerDNSServiceAdapter.java
(original)
+++
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerDNSServiceAdapter.java
Fri Jan 7 19:56:39 2011
@@ -23,13 +23,17 @@ import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Iterator;
+import org.apache.commons.logging.Log;
+import org.apache.james.lifecycle.api.LogEnabled;
import org.apache.james.protocols.smtp.DNSService;
import org.apache.james.protocols.smtp.TemporaryResolutionException;
+import org.apache.james.util.MXHostAddressIterator;
import org.apache.mailet.HostAddress;
-public class SMTPServerDNSServiceAdapter implements DNSService{
+public class SMTPServerDNSServiceAdapter implements DNSService, LogEnabled{
private org.apache.james.dnsservice.api.DNSService dns;
+ private Log log;
public
SMTPServerDNSServiceAdapter(org.apache.james.dnsservice.api.DNSService dns) {
this.dns = dns;
@@ -85,11 +89,14 @@ public class SMTPServerDNSServiceAdapter
* @see
org.apache.james.protocols.smtp.DNSService#getSMTPHostAddresses(java.lang.String)
*/
public Iterator<HostAddress> getSMTPHostAddresses(String domainName)
throws TemporaryResolutionException {
- try {
- return dns.getSMTPHostAddresses(domainName);
- } catch (org.apache.james.dnsservice.api.TemporaryResolutionException
e) {
- throw new TemporaryResolutionException(e.getMessage());
- }
+ return new MXHostAddressIterator(findMXRecords(domainName).iterator(),
dns, false, log);
+ }
+
+ /*
+ *
+ */
+ public void setLog(Log log) {
+ this.log = log;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]