Author: bago Date: Mon Jan 10 15:09:53 2011 New Revision: 1057232 URL: http://svn.apache.org/viewvc?rev=1057232&view=rev Log: Introducing a dnsservice-library module trying to reduce dependency layers (JAMES-1181) Make sure mailetcontainer-library does not depends on dnsservice-library (libraries should not depend on libraries). (Moved some logic higher in the camel function.)
Added: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetContext.java (with props) Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1057232&r1=1057231&r2=1057232&view=diff ============================================================================== --- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml (original) +++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml Mon Jan 10 15:09:53 2011 @@ -190,7 +190,7 @@ otherwise LogEnabled injection via LogEnabledBeanPostProcessor will not occur before it is used - Seems like a Spring bug. --> - <bean id="mailetcontext" class="org.apache.james.mailetcontainer.lib.JamesMailetContext"/> + <bean id="mailetcontext" class="org.apache.james.mailetcontainer.camel.CamelMailetContext"/> <bean id="mailspooler" class="org.apache.james.mailetcontainer.lib.JamesMailSpooler"/> <!-- Added: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetContext.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetContext.java?rev=1057232&view=auto ============================================================================== --- james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetContext.java (added) +++ james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetContext.java Mon Jan 10 15:09:53 2011 @@ -0,0 +1,58 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james.mailetcontainer.camel; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; + +import org.apache.james.dnsservice.api.TemporaryResolutionException; +import org.apache.james.mailetcontainer.lib.JamesMailetContext; +import org.apache.james.util.MXHostAddressIterator; +import org.apache.mailet.HostAddress; + +public class CamelMailetContext extends JamesMailetContext { + + + /** + * 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.dnsservice.api.DNSService#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<HostAddress> getSMTPHostAddresses(String domainName) { + try { + 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 + return Collections.unmodifiableCollection(new ArrayList<HostAddress>(0)).iterator(); + } + } + +} Propchange: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetContext.java ------------------------------------------------------------------------------ svn:mime-type = text/plain 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=1057232&r1=1057231&r2=1057232&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 Mon Jan 10 15:09:53 2011 @@ -53,22 +53,21 @@ 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; import org.apache.mailet.MailetContext; import org.apache.mailet.base.RFC2822Headers; -public class JamesMailetContext implements MailetContext, LogEnabled, Configurable { +public abstract class JamesMailetContext implements MailetContext, LogEnabled, Configurable { /** * A hash table of server attributes These are the MailetContext attributes */ private Hashtable<String, Object> attributes = new Hashtable<String, Object>(); - private DNSService dns; + protected DNSService dns; - private Log log; + protected Log log; private UsersRepository localusers; @@ -318,15 +317,7 @@ public class JamesMailetContext implemen * - the domain for which to find mail servers * @return an Iterator over HostAddress instances, sorted by priority */ - public Iterator<HostAddress> getSMTPHostAddresses(String domainName) { - try { - 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 - return Collections.unmodifiableCollection(new ArrayList<HostAddress>(0)).iterator(); - } - } + public abstract Iterator<HostAddress> getSMTPHostAddresses(String domainName); /* * (non-Javadoc) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org