james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: james-server/src/java/org/apache/mailet HostAddress.java MailetContext.java
Date Sat, 20 Mar 2004 07:50:42 GMT
noel        2004/03/19 23:50:42

  Modified:    src/java/org/apache/james Tag: branch_2_1_fcs James.java
               src/java/org/apache/james/dnsserver Tag: branch_2_1_fcs
                        DNSServer.java
               src/java/org/apache/james/transport/mailets Tag:
                        branch_2_1_fcs RemoteDelivery.java
               src/java/org/apache/mailet Tag: branch_2_1_fcs
                        MailetContext.java
  Added:       src/java/org/apache/mailet Tag: branch_2_1_fcs
                        HostAddress.java
  Removed:     src/java/org/apache/james/dnsserver Tag: branch_2_1_fcs
                        SMTPHostAddressesImpl.java
  Log:
  Switch to a single Iterator that traverses candidate SMTP hosts.  Alternative approach to
fix for JAMES-142.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.35.4.14 +17 -14    james-server/src/java/org/apache/james/James.java
  
  Index: James.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/James.java,v
  retrieving revision 1.35.4.13
  retrieving revision 1.35.4.14
  diff -u -r1.35.4.13 -r1.35.4.14
  --- James.java	15 Mar 2004 03:54:15 -0000	1.35.4.13
  +++ James.java	20 Mar 2004 07:50:42 -0000	1.35.4.14
  @@ -902,18 +902,22 @@
           return success;
       }
   
  -   /**
  -    * Performs DNS lookups as needed to find servers which should or might
  -    * support SMTP.
  -    * Returns one SMTPHostAddresses for each such host discovered
  -    * by DNS.  If no host is found for domainName, the Iterator
  -    * returned will be empty and the first call to hasNext() will return
  -    * false.
  -    * @param domainName the String domain for which SMTP host addresses are
  -    * sought.
  -    * @return an Iterator in which the Objects returned by next()
  -    * are instances of SMTPHostAddresses.
  -    */
  +    /**
  +     * Performs DNS lookups as needed to find servers which should or might
  +     * support SMTP.
  +     * Returns an Iterator over 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.
  +     *
  +     * @see org.apache.james.DNSServer#getSMTPHostAddresses(String)
  +     * @since Mailet API v2.2.0a16-unstable
  +     * @param domainName - the domain for which to find mail servers
  +     * @return an Iterator over HostAddress instances, sorted by priority
  +     */
       public Iterator getSMTPHostAddresses(String domainName) {
           DNSServer dnsServer = null;
           try {
  @@ -924,5 +928,4 @@
           }
           return dnsServer.getSMTPHostAddresses(domainName);
       }
  -    
   }
  
  
  
  No                   revision
  No                   revision
  1.9.4.12  +57 -31    james-server/src/java/org/apache/james/dnsserver/DNSServer.java
  
  Index: DNSServer.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/dnsserver/DNSServer.java,v
  retrieving revision 1.9.4.11
  retrieving revision 1.9.4.12
  diff -u -r1.9.4.11 -r1.9.4.12
  --- DNSServer.java	15 Mar 2004 03:54:15 -0000	1.9.4.11
  +++ DNSServer.java	20 Mar 2004 07:50:42 -0000	1.9.4.12
  @@ -350,38 +350,64 @@
           }
       }
   
  -    /**
  -     * Performs DNS lookups as needed to find servers which should or might
  -     * support SMTP.  Returns one SMTPHostAddresses for each such host
  -     * discovered by DNS.  If no host is found for domainName, the Iterator
  -     * returned will be empty and the first call to hasNext() will return
  -     * false.
  -     * @param domainName the String domain for which SMTP host addresses are
  -     * sought.
  -     * @return an Enumeration in which the Objects returned by next()
  -     * are instances of SMTPHostAddresses.
  +    /*
  +     * 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.
  +     *
  +     * @since v2.2.0a16-unstable
  +     * @param domainName - the domain for which to find mail servers
  +     * @return an Iterator over HostAddress instances, sorted by priority
        */
       public Iterator getSMTPHostAddresses(final String domainName) {
           return new Iterator() {
  -                private Iterator mxHosts = new MxSorter(domainName);
  -                
  -                public boolean hasNext(){
  -                    return mxHosts.hasNext();
  -                }
  -                
  -                public Object next(){
  -                    String nextHostname = (String)mxHosts.next();
  -                    Record[] aRecords = lookup(nextHostname, Type.A);
  -                    return new SMTPHostAddressesImpl(aRecords, nextHostname);
  -                }
  +            private Iterator mxHosts = new MxSorter(domainName);
  +            private Iterator addresses = null;
  +
  +            public boolean hasNext() {
  +                return mxHosts.hasNext();
  +            }
  +
  +            public Object next() {
  +                if (addresses == null || !addresses.hasNext())
  +                {
  +                    final String nextHostname = (String)mxHosts.next();
  +                    addresses = new Iterator() {
  +                        private Record[] aRecords = lookup(nextHostname, Type.A);
  +                        int i = 0;
  +
  +                        public boolean hasNext() {
  +                            return aRecords != null && i < aRecords.length;
  +                        }
  +
  +                        public Object next() {
  +                            return new org.apache.mailet.HostAddress(nextHostname, "smtp://"
+ ((ARecord)aRecords[i++]).getAddress().getHostAddress());
  +                        }
   
  -                public void remove () {
  -                    throw new UnsupportedOperationException ("remove not supported by this
iterator");
  +                        public void remove() {
  +                            throw new UnsupportedOperationException ("remove not supported
by this iterator");
  +                        }
  +                    };
                   }
  -            };
  +                return addresses.next();
  +            }
  +
  +            public void remove() {
  +                throw new UnsupportedOperationException ("remove not supported by this
iterator");
  +            }
  +        };
       }
   
  -    /** A way to get mail hosts to try.  If any MX hosts are found for the
  +    /**
  +     * A way to get mail hosts to try.  If any MX hosts are found for the
        * domain name with which this is constructed, then these MX hostnames
        * are returned in priority sorted order, lowest priority numbers coming
        * first.  And, whenever multiple hosts have the same priority then these
  @@ -396,13 +422,14 @@
        * its hasNext() will return false.
        *
        * This behavior attempts to satisfy the requirements of RFC 2821, Section 5.
  +     * @since v2.2.0a16-unstable
        */
       private class MxSorter implements Iterator {
           private int priorListPriority = Integer.MIN_VALUE;
           private ArrayList equiPriorityList = new ArrayList();
           private Record[] mxRecords;
           private Random rnd = new Random ();
  -        
  +
           /* The implementation of this class attempts to achieve efficiency by
            * performing no more sorting of the rawMxRecords than necessary. In the
            * large majority of cases the first attempt, made by a client of this class
  @@ -424,7 +451,7 @@
                   }
               }
           }
  -        
  +
           /**
            * Sets presentPriorityList to contain all hosts
            * which have the least priority greater than pastPriority.
  @@ -456,7 +483,7 @@
               }
               priorListPriority = leastPriorityFound;
           }
  -        
  +
           public boolean hasNext(){
               if (equiPriorityList.size() > 0){
                   return true;
  @@ -467,7 +494,7 @@
                   return false;
               }
           }
  -        
  +
           public Object next(){
               if (hasNext()){
                   /* this randomization is done to comply with RFC-2821 */
  @@ -480,10 +507,9 @@
                   throw new NoSuchElementException();
               }
           }
  -        
  +
           public void remove () {
               throw new UnsupportedOperationException ("remove not supported by this iterator");
           }
       }
  -    
   }
  
  
  
  No                   revision
  No                   revision
  1.33.4.17 +162 -164  james-server/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
  
  Index: RemoteDelivery.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/RemoteDelivery.java,v
  retrieving revision 1.33.4.16
  retrieving revision 1.33.4.17
  diff -u -r1.33.4.16 -r1.33.4.17
  --- RemoteDelivery.java	15 Mar 2004 03:54:19 -0000	1.33.4.16
  +++ RemoteDelivery.java	20 Mar 2004 07:50:42 -0000	1.33.4.17
  @@ -55,8 +55,8 @@
   import org.apache.james.services.MailStore;
   import org.apache.james.services.SpoolRepository;
   import org.apache.mailet.GenericMailet;
  +import org.apache.mailet.HostAddress;
   import org.apache.mailet.Mail;
  -import org.apache.mailet.MailetContext;
   import org.apache.mailet.MailAddress;
   
   import org.apache.oro.text.regex.MalformedPatternException;
  @@ -200,7 +200,6 @@
       private int connectionTimeout = 60000;  // The amount of time JavaMail will wait before
giving up on a socket connect()
       private int deliveryThreadCount = 1; // default number of delivery threads
       private Collection gatewayServer = null; // the server(s) to send all email to
  -    private String gatewayPort = null;  // the default port of gateway server(s)
       private String bindAddress = null; // JavaMail delivery socket binds to this local
address. If null the JavaMail default will be used.
       private boolean isBindUsed = false; // true, if the bind configuration
                                           // parameter is supplied, RemoteDeliverySocketFactory
  @@ -282,7 +281,7 @@
           sendPartial = (getInitParameter("sendpartial") == null) ? false : new Boolean(getInitParameter("sendpartial")).booleanValue();
   
           String gateway = getInitParameter("gateway");
  -        gatewayPort = getInitParameter("gatewayPort");
  +        String gatewayPort = getInitParameter("gatewayPort");
   
           if (gateway != null) {
               gatewayServer = new ArrayList();
  @@ -295,11 +294,7 @@
                   }
   
                   if (isDebug) log("Adding SMTP gateway: " + server) ;
  -                try {
  -                    gatewayServer.add(new GatewaySMTPHostAddresses(server));
  -                } catch (UnknownHostException uhe) {
  -                    log("Invalid gateway address:" + uhe.getMessage());
  -                }
  +                gatewayServer.add(server);
               }
           }
   
  @@ -400,124 +395,107 @@
                       return failMessage(mail, new MessagingException(exceptionBuffer.toString()),
false);
                   }
               } else {
  -                targetServers = gatewayServer.iterator();
  +                targetServers = getGatewaySMTPHostAddresses(gatewayServer);
               }
   
               MessagingException lastError = null;
   
  -            while ( targetServers.hasNext() ) {
  -                MailetContext.SMTPHostAddresses thisHost = 
  -                    (MailetContext.SMTPHostAddresses)targetServers.next();
  -                String thisHostName = thisHost.getHostname();
  -                InetAddress[] addresses = thisHost.getAddresses();
  -                for (int addressIndex = 0; addressIndex < addresses.length; addressIndex++){
  -                    try {
  -                        InetAddress thisAddress = addresses[addressIndex];
  -                        int thisPort = thisHost.getPort(thisAddress);
  +            while ( targetServers.hasNext()) {
  +                try {
  +                    HostAddress outgoingMailServer = (HostAddress) targetServers.next();
  +                    StringBuffer logMessageBuffer =
  +                        new StringBuffer(256)
  +                        .append("Attempting delivery of ")
  +                        .append(mail.getName())
  +                        .append(" to host ")
  +                        .append(outgoingMailServer.getHostName())
  +                        .append(" at ")
  +                        .append(outgoingMailServer.getHost())
  +                        .append(" to addresses ")
  +                        .append(Arrays.asList(addr));
  +                    log(logMessageBuffer.toString());
   
  -                        StringBuffer outgoingMailServerBuf =
  -                            new StringBuffer(256).append(thisAddress)
  -                            .append(':')
  -                            .append(thisPort);
  -                        if (outgoingMailServerBuf.charAt(0) == '/') {
  -                            outgoingMailServerBuf.deleteCharAt(0);
  -                        }
  -                        String outgoingMailServer = outgoingMailServerBuf.toString();
  -                        
  -                        StringBuffer logMessageBuffer =
  -                            new StringBuffer(256)
  -                            .append("Attempting delivery of ")
  -                            .append(mail.getName())
  -                            .append(" to host ")
  -                            .append(thisHostName)
  -                            .append(" at ")
  -                            .append(outgoingMailServer)
  -                            .append(" to addresses ")
  -                            .append(Arrays.asList(addr));
  -                        log(logMessageBuffer.toString());
  -                        URLName urlname = new URLName("smtp://" + outgoingMailServer);
  -
  -                        Properties props = session.getProperties();
  -                        if (mail.getSender() == null) {
  -                            props.put("mail.smtp.from", "<>");
  -                        } else {
  -                            String sender = mail.getSender().toString();
  -                            props.put("mail.smtp.from", sender);
  -                        }
  -                        
  -                        //Many of these properties are only in later JavaMail versions
  -                        //"mail.smtp.ehlo"  //default true
  -                        //"mail.smtp.auth"  //default false
  -                        //"mail.smtp.dsn.ret"  //default to nothing... appended as RET=
after MAIL FROM line.
  -                        //"mail.smtp.dsn.notify" //default to nothing...appended as NOTIFY=
after RCPT TO line.
  -                        Transport transport = null;
  +                    Properties props = session.getProperties();
  +                    if (mail.getSender() == null) {
  +                        props.put("mail.smtp.from", "<>");
  +                    } else {
  +                        String sender = mail.getSender().toString();
  +                        props.put("mail.smtp.from", sender);
  +                    }
  +
  +                    //Many of these properties are only in later JavaMail versions
  +                    //"mail.smtp.ehlo"  //default true
  +                    //"mail.smtp.auth"  //default false
  +                    //"mail.smtp.dsn.ret"  //default to nothing... appended as RET= after
MAIL FROM line.
  +                    //"mail.smtp.dsn.notify" //default to nothing...appended as NOTIFY=
after RCPT TO line.
  +
  +                    Transport transport = null;
  +                    try {
  +                        transport = session.getTransport(outgoingMailServer);
                           try {
  -                            transport = session.getTransport(urlname);
  -                            try {
  -                                transport.connect();
  -                            } catch (MessagingException me) {
  -                                // Any error on connect should cause the mailet to attempt
  -                                // to connect to the next SMTP server associated with this
  -                                // MX record.  Just log the exception.  We'll worry about
  -                                // failing the message at the end of the loop.
  -                                log(me.getMessage());
  -                                continue;
  -                            }
  -                            transport.sendMessage(message, addr);
  -                        } finally {
  -                            if (transport != null) {
  -                                transport.close();
  -                                transport = null;
  -                            }
  -                        }
  -                        logMessageBuffer =
  -                            new StringBuffer(256)
  -                            .append("Mail (")
  -                            .append(mail.getName())
  -                            .append(") sent successfully to ")
  -                            .append(thisHostName)
  -                            .append(" at ")
  -                            .append(outgoingMailServer);
  -                        log(logMessageBuffer.toString());
  -                        return true;
  -                    } catch (SendFailedException sfe) {
  -                        if (sfe.getValidSentAddresses() == null
  -                            || sfe.getValidSentAddresses().length < 1) {
  -                            if (isDebug) log("Send failed, continuing with any other servers");
  -                            lastError = sfe;
  +                            transport.connect();
  +                        } catch (MessagingException me) {
  +                            // Any error on connect should cause the mailet to attempt
  +                            // to connect to the next SMTP server associated with this
  +                            // MX record.  Just log the exception.  We'll worry about
  +                            // failing the message at the end of the loop.
  +                            log(me.getMessage());
                               continue;
  -                        } else {
  -                            // If any mail was sent then the outgoing
  -                            // server config must be ok, therefore rethrow
  -                            throw sfe;
                           }
  -                    } catch (MessagingException me) {
  -                        //MessagingException are horribly difficult to figure out what
actually happened.
  -                        StringBuffer exceptionBuffer =
  -                            new StringBuffer(256)
  -                            .append("Exception delivering message (")
  -                            .append(mail.getName())
  -                            .append(") - ")
  -                            .append(me.getMessage());
  -                        log(exceptionBuffer.toString());
  -                        if ((me.getNextException() != null) &&
  -                            (me.getNextException() instanceof java.io.IOException)) {
  -                            //This is more than likely a temporary failure
  -                            
  -                            // If it's an IO exception with no nested exception, it's probably
  -                            // some socket or weird I/O related problem.
  -                            lastError = me;
  -                            continue;
  +                        transport.sendMessage(message, addr);
  +                    } finally {
  +                        if (transport != null) {
  +                            transport.close();
  +                            transport = null;
                           }
  -                        // This was not a connection or I/O error particular to one
  -                        // SMTP server of an MX set.  Instead, it is almost certainly
  -                        // a protocol level error.  In this case we assume that this
  -                        // is an error we'd encounter with any of the SMTP servers
  -                        // associated with this MX record, and we pass the exception
  -                        // to the code in the outer block that determines its severity.
  -                        throw me;
                       }
  -                } //end for
  +                    logMessageBuffer =
  +                                      new StringBuffer(256)
  +                                      .append("Mail (")
  +                                      .append(mail.getName())
  +                                      .append(") sent successfully to ")
  +                                      .append(outgoingMailServer.getHostName())
  +                                      .append(" at ")
  +                                      .append(outgoingMailServer.getHost());
  +                    log(logMessageBuffer.toString());
  +                    return true;
  +                } catch (SendFailedException sfe) {
  +                    if (sfe.getValidSentAddresses() == null
  +                          || sfe.getValidSentAddresses().length < 1) {
  +                        if (isDebug) log("Send failed, continuing with any other servers");
  +                        lastError = sfe;
  +                        continue;
  +                    } else {
  +                        // If any mail was sent then the outgoing
  +                        // server config must be ok, therefore rethrow
  +                        throw sfe;
  +                    }
  +                } catch (MessagingException me) {
  +                    //MessagingException are horribly difficult to figure out what actually
happened.
  +                    StringBuffer exceptionBuffer =
  +                        new StringBuffer(256)
  +                        .append("Exception delivering message (")
  +                        .append(mail.getName())
  +                        .append(") - ")
  +                        .append(me.getMessage());
  +                    log(exceptionBuffer.toString());
  +                    if ((me.getNextException() != null) &&
  +                          (me.getNextException() instanceof java.io.IOException)) {
  +                        //This is more than likely a temporary failure
  +
  +                        // If it's an IO exception with no nested exception, it's probably
  +                        // some socket or weird I/O related problem.
  +                        lastError = me;
  +                        continue;
  +                    }
  +                    // This was not a connection or I/O error particular to one
  +                    // SMTP server of an MX set.  Instead, it is almost certainly
  +                    // a protocol level error.  In this case we assume that this
  +                    // is an error we'd encounter with any of the SMTP servers
  +                    // associated with this MX record, and we pass the exception
  +                    // to the code in the outer block that determines its severity.
  +                    throw me;
  +                }
               } // end while
               //If we encountered an exception while looping through,
               //throw the last MessagingException we caught.  We only
  @@ -1075,54 +1053,74 @@
               return buf.toString();
           }
       }
  -
  -    /**
  -     * This implementation of MailetContext.SMTPHostAddresses is used for holding gateway
information
  +    
  +    /*
  +     * 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.  If no host is found, 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 each gateway, and the inner iteration is over
  +     * potentially multiple A records for each gateway.
  +     *
  +     * @see org.apache.james.DNSServer#getSMTPHostAddresses(String)
  +     * @since v2.2.0a16-unstable
  +     * @param gatewayServers - Collection of host[:port] Strings
  +     * @return an Iterator over HostAddress instances, sorted by priority
        */
  -    private class GatewaySMTPHostAddresses implements MailetContext.SMTPHostAddresses
  -    {
  -        protected InetAddress[] ipAddresses;
  -        protected int port;
  -        
  -        /**
  -         * @param server gateway to use the String is of the form "address<:port>"
  -         */
  -        public GatewaySMTPHostAddresses (String server) throws UnknownHostException
  -        {
  -            int idx = server.indexOf(':');
  -            if ( idx > 0) {
  -                port = Integer.parseInt (server.substring(idx+1));
  -                server = server.substring(0,idx);
  -            } else {
  -                port = 25;
  +    private Iterator getGatewaySMTPHostAddresses(final Collection gatewayServers) {
  +        return new Iterator() {
  +            private Iterator gateways = gatewayServers.iterator();
  +            private Iterator addresses = null;
  +
  +            public boolean hasNext() {
  +                return gateways.hasNext();
  +            }
  +
  +            public Object next() {
  +                if (addresses == null || !addresses.hasNext())
  +                {
  +                    String server = (String) gateways.next();
  +                    String port = "25";
  +
  +                    int idx = server.indexOf(':'); 
  +                    if ( idx > 0) { 
  +                        port = server.substring(idx+1); 
  +                        server = server.substring(0,idx);
  +                    }
  +
  +                    final String nextGateway = server;
  +                    final String nextGatewayPort = port;
  +                    try {
  +                        addresses = new Iterator() {
  +                            private InetAddress[] ipAddresses = InetAddress.getAllByName(nextGateway);
  +                            int i = 0;
  +
  +                            public boolean hasNext() {
  +                                return i < ipAddresses.length;
  +                            }
  +
  +                            public Object next() {
  +                                return new org.apache.mailet.HostAddress(nextGateway, "smtp://"
+ (ipAddresses[i++]).getHostAddress() + ":" + nextGatewayPort);
  +                            }
  +
  +                            public void remove() {
  +                                throw new UnsupportedOperationException ("remove not supported
by this iterator");
  +                            }
  +                        };
  +                    }
  +                    catch (java.net.UnknownHostException uhe) {
  +                        log("Unknown gateway host: " + uhe.getMessage().trim());
  +                        log("This could be a DNS server error or configuration error.");
  +                    }
  +                }
  +                return (addresses != null) ? addresses.next() : null;
               }
  -            ipAddresses = new InetAddress[1];
  -            ipAddresses[0] = InetAddress.getByName(server);
  -        }
  -        
  -        /**
  -         *  @return the hostName of the SMTP server (from the MX record lookup)
  -         */
  -        public String getHostname() {
  -            return "Gateway";
  -        }
  -        
  -        /**
  -         * @return an array with the ip addresses of the hostname. An array is
  -         * used because a host can have multiple homes (addresses)
  -         */
  -        public InetAddress[] getAddresses() {
  -            return ipAddresses;
  -        }
  -        
  -        
  -        /**
  -         * @param address for which we need the port to use in SMTP connection
  -         * @return the port number to use for the given address (this will usually be 25
for SMTP)
  -         */
  -        public int getPort(InetAddress address) {
  -            return port;
  -        }
  -    
  +
  +            public void remove() {
  +                throw new UnsupportedOperationException ("remove not supported by this
iterator");
  +            }
  +        };
       }
   }
  
  
  
  No                   revision
  No                   revision
  1.5.4.8   +17 -38    james-server/src/java/org/apache/mailet/MailetContext.java
  
  Index: MailetContext.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/mailet/MailetContext.java,v
  retrieving revision 1.5.4.7
  retrieving revision 1.5.4.8
  diff -u -r1.5.4.7 -r1.5.4.8
  --- MailetContext.java	15 Mar 2004 03:54:24 -0000	1.5.4.7
  +++ MailetContext.java	20 Mar 2004 07:50:42 -0000	1.5.4.8
  @@ -17,11 +17,11 @@
   
   package org.apache.mailet;
   
  -import javax.mail.MessagingException;
  -import javax.mail.internet.MimeMessage;
   import java.util.Collection;
   import java.util.Iterator;
  -import java.net.InetAddress;
  +
  +import javax.mail.MessagingException;
  +import javax.mail.internet.MimeMessage;
   
   /**
    * Defines a set of methods that a mailet or matcher uses to communicate
  @@ -241,6 +241,8 @@
        * Stores the message is in the local repository associated with
        * recipient for later retrieval, e.g., by a POP3 or IMAP service.
        *
  +     * @deprecated - use sparingly.  Service will be replaced with
  +     * resource acquired via JNDI.
        * @param sender - the sender of the incoming message
        * @param recipient - the user who is receiving this message (as a complete email address)
        * @param msg - the MimeMessage to store in a local mailbox
  @@ -249,41 +251,18 @@
       void storeMail(MailAddress sender, MailAddress recipient, MimeMessage msg)
           throws MessagingException;
   
  -   /**
  -    * Performs DNS lookups as needed to find servers which should or might
  -    * support SMTP.
  -    * Returns one SMTPHostAddresses for each such host discovered
  -    * by DNS.  If no host is found for domainName, the Iterator
  -    * returned will be empty and the first call to hasNext() will return
  -    * false.
  -    * @param domainName the String domain for which SMTP host addresses are
  -    * sought.
  -    * @return an Iterator in which the Objects returned by next()
  -    * are instances of SMTPHostAddresses.
  -    */
  -    Iterator getSMTPHostAddresses(String domainName);
  -
       /**
  -     * The Iterator returned by getSMTPHostAddresses(host) holds instances
  -     * of this interface.
  +     * Returns an Iterator over 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.
  +     *
  +     * @since Mailet API v3.0-unstable
  +     * @param domainName - the domain for which to find mail servers
  +     * @return an Iterator over HostAddress instances, sorted by priority
        */
  -    interface SMTPHostAddresses {
  -        /**
  -         *  @return the hostName of the SMTP server (from the MX record lookup)
  -         */
  -        String getHostname();
  -        
  -        /**
  -         * @return an array with the ip addresses of the hostname. An array is
  -         * used because a host can have multiple homes (addresses)
  -         */
  -        InetAddress[] getAddresses();
  -        
  -        /**
  -         * @param address for which we need the port to use in SMTP connection
  -         * @return the port number to use for the given address (this will usually be 25
for SMTP)
  -         */
  -        int getPort(InetAddress address);
  -    }
  -
  +    Iterator getSMTPHostAddresses(String domainName);
   }
  
  
  
  No                   revision
  
  Index: MailetContext.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/mailet/MailetContext.java,v
  retrieving revision 1.5.4.7
  retrieving revision 1.5.4.8
  diff -u -r1.5.4.7 -r1.5.4.8
  --- MailetContext.java	15 Mar 2004 03:54:24 -0000	1.5.4.7
  +++ MailetContext.java	20 Mar 2004 07:50:42 -0000	1.5.4.8
  @@ -17,11 +17,11 @@
   
   package org.apache.mailet;
   
  -import javax.mail.MessagingException;
  -import javax.mail.internet.MimeMessage;
   import java.util.Collection;
   import java.util.Iterator;
  -import java.net.InetAddress;
  +
  +import javax.mail.MessagingException;
  +import javax.mail.internet.MimeMessage;
   
   /**
    * Defines a set of methods that a mailet or matcher uses to communicate
  @@ -241,6 +241,8 @@
        * Stores the message is in the local repository associated with
        * recipient for later retrieval, e.g., by a POP3 or IMAP service.
        *
  +     * @deprecated - use sparingly.  Service will be replaced with
  +     * resource acquired via JNDI.
        * @param sender - the sender of the incoming message
        * @param recipient - the user who is receiving this message (as a complete email address)
        * @param msg - the MimeMessage to store in a local mailbox
  @@ -249,41 +251,18 @@
       void storeMail(MailAddress sender, MailAddress recipient, MimeMessage msg)
           throws MessagingException;
   
  -   /**
  -    * Performs DNS lookups as needed to find servers which should or might
  -    * support SMTP.
  -    * Returns one SMTPHostAddresses for each such host discovered
  -    * by DNS.  If no host is found for domainName, the Iterator
  -    * returned will be empty and the first call to hasNext() will return
  -    * false.
  -    * @param domainName the String domain for which SMTP host addresses are
  -    * sought.
  -    * @return an Iterator in which the Objects returned by next()
  -    * are instances of SMTPHostAddresses.
  -    */
  -    Iterator getSMTPHostAddresses(String domainName);
  -
       /**
  -     * The Iterator returned by getSMTPHostAddresses(host) holds instances
  -     * of this interface.
  +     * Returns an Iterator over 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.
  +     *
  +     * @since Mailet API v3.0-unstable
  +     * @param domainName - the domain for which to find mail servers
  +     * @return an Iterator over HostAddress instances, sorted by priority
        */
  -    interface SMTPHostAddresses {
  -        /**
  -         *  @return the hostName of the SMTP server (from the MX record lookup)
  -         */
  -        String getHostname();
  -        
  -        /**
  -         * @return an array with the ip addresses of the hostname. An array is
  -         * used because a host can have multiple homes (addresses)
  -         */
  -        InetAddress[] getAddresses();
  -        
  -        /**
  -         * @param address for which we need the port to use in SMTP connection
  -         * @return the port number to use for the given address (this will usually be 25
for SMTP)
  -         */
  -        int getPort(InetAddress address);
  -    }
  -
  +    Iterator getSMTPHostAddresses(String domainName);
   }
  
  
  
  No                   revision
  
  Index: MailetContext.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/mailet/MailetContext.java,v
  retrieving revision 1.5.4.7
  retrieving revision 1.5.4.8
  diff -u -r1.5.4.7 -r1.5.4.8
  --- MailetContext.java	15 Mar 2004 03:54:24 -0000	1.5.4.7
  +++ MailetContext.java	20 Mar 2004 07:50:42 -0000	1.5.4.8
  @@ -17,11 +17,11 @@
   
   package org.apache.mailet;
   
  -import javax.mail.MessagingException;
  -import javax.mail.internet.MimeMessage;
   import java.util.Collection;
   import java.util.Iterator;
  -import java.net.InetAddress;
  +
  +import javax.mail.MessagingException;
  +import javax.mail.internet.MimeMessage;
   
   /**
    * Defines a set of methods that a mailet or matcher uses to communicate
  @@ -241,6 +241,8 @@
        * Stores the message is in the local repository associated with
        * recipient for later retrieval, e.g., by a POP3 or IMAP service.
        *
  +     * @deprecated - use sparingly.  Service will be replaced with
  +     * resource acquired via JNDI.
        * @param sender - the sender of the incoming message
        * @param recipient - the user who is receiving this message (as a complete email address)
        * @param msg - the MimeMessage to store in a local mailbox
  @@ -249,41 +251,18 @@
       void storeMail(MailAddress sender, MailAddress recipient, MimeMessage msg)
           throws MessagingException;
   
  -   /**
  -    * Performs DNS lookups as needed to find servers which should or might
  -    * support SMTP.
  -    * Returns one SMTPHostAddresses for each such host discovered
  -    * by DNS.  If no host is found for domainName, the Iterator
  -    * returned will be empty and the first call to hasNext() will return
  -    * false.
  -    * @param domainName the String domain for which SMTP host addresses are
  -    * sought.
  -    * @return an Iterator in which the Objects returned by next()
  -    * are instances of SMTPHostAddresses.
  -    */
  -    Iterator getSMTPHostAddresses(String domainName);
  -
       /**
  -     * The Iterator returned by getSMTPHostAddresses(host) holds instances
  -     * of this interface.
  +     * Returns an Iterator over 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.
  +     *
  +     * @since Mailet API v3.0-unstable
  +     * @param domainName - the domain for which to find mail servers
  +     * @return an Iterator over HostAddress instances, sorted by priority
        */
  -    interface SMTPHostAddresses {
  -        /**
  -         *  @return the hostName of the SMTP server (from the MX record lookup)
  -         */
  -        String getHostname();
  -        
  -        /**
  -         * @return an array with the ip addresses of the hostname. An array is
  -         * used because a host can have multiple homes (addresses)
  -         */
  -        InetAddress[] getAddresses();
  -        
  -        /**
  -         * @param address for which we need the port to use in SMTP connection
  -         * @return the port number to use for the given address (this will usually be 25
for SMTP)
  -         */
  -        int getPort(InetAddress address);
  -    }
  -
  +    Iterator getSMTPHostAddresses(String domainName);
   }
  
  
  
  1.1.2.1   +62 -0     james-server/src/java/org/apache/mailet/Attic/HostAddress.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message