You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2009/11/23 15:56:00 UTC
svn commit: r883358 [1/2] - in /james/server/trunk:
imapserver-function/src/main/java/org/apache/james/imapserver/sieve/
mailets-function/src/main/java/org/apache/james/transport/mailets/
mailets-function/src/main/java/org/apache/james/transport/matche...
Author: norman
Date: Mon Nov 23 14:55:58 2009
New Revision: 883358
URL: http://svn.apache.org/viewvc?rev=883358&view=rev
Log:
More decoupling of Avalon to move to Guice (JAMES-893)
Modified:
james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/sieve/SieveMailet.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListserv.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListservManager.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifySender.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Redirect.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Retry.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/ToRepository.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java
james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/mailets/StandardRemoteDeliveryTestable.java
james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java
james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java
james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/RemoteDeliveryTestable.java
james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/Tester.java
james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/remotedeliverytester/TesterMailetConfig.java
james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
james/server/trunk/pop3server-function/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractAvalonJamesLoader.java
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/LinearProcessor.java
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/StateAwareProcessorList.java
james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMailetLoader.xinfo
james/server/trunk/spoolmanager-function/src/main/resources/org/apache/james/transport/AvalonJamesMatcherLoader.xinfo
Modified: james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/sieve/SieveMailet.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/sieve/SieveMailet.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/sieve/SieveMailet.java (original)
+++ james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/sieve/SieveMailet.java Mon Nov 23 14:55:58 2009
@@ -35,7 +35,7 @@
setLocator(new ResourceLocatorImpl());
}
- @Resource(name="imapserver")
+ @Resource(name="org.apache.jsieve.mailet.Poster")
@Override
public void setPoster(Poster poster) {
super.setPoster(poster);
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java Mon Nov 23 14:55:58 2009
@@ -63,15 +63,15 @@
return;
}
- Collection recipientsToRemove = new HashSet();
- Collection recipientsToAddLocal = new ArrayList();
- Collection recipientsToAddForward = new ArrayList();
+ Collection<MailAddress> recipientsToRemove = new HashSet<MailAddress>();
+ Collection<MailAddress> recipientsToAddLocal = new ArrayList<MailAddress>();
+ Collection<MailAddress> recipientsToAddForward = new ArrayList<MailAddress>();
- Collection recipients = mail.getRecipients();
- Map recipientsMap = new HashMap(recipients.size());
+ Collection<MailAddress> recipients = mail.getRecipients();
+ Map<MailAddress,String> recipientsMap = new HashMap<MailAddress,String>(recipients.size());
- for (Iterator iter = recipients.iterator(); iter.hasNext(); ) {
- MailAddress address = (MailAddress)iter.next();
+ for (Iterator<MailAddress> iter = recipients.iterator(); iter.hasNext(); ) {
+ MailAddress address = iter.next();
// Assume all addresses are non-virtual at start
recipientsMap.put(address, null);
@@ -79,9 +79,9 @@
mapRecipients(recipientsMap);
- for (Iterator iter = recipientsMap.keySet().iterator(); iter.hasNext(); ) {
- MailAddress source = (MailAddress)iter.next();
- String targetString = (String)recipientsMap.get(source);
+ for (Iterator<MailAddress> iter = recipientsMap.keySet().iterator(); iter.hasNext(); ) {
+ MailAddress source = iter.next();
+ String targetString = recipientsMap.get(source);
// Only non-null mappings are translated
if(targetString != null) {
@@ -115,7 +115,7 @@
// We need to separate local and remote
// recipients. This is explained below.
- if (getMailetContext().isLocalServer(target.getHost())) {
+ if (getMailetContext().isLocalServer(target.getDomain())) {
recipientsToAddLocal.add(target);
} else {
recipientsToAddForward.add(target);
@@ -195,7 +195,7 @@
* @param recipientsMap the mapping of virtual to real recipients, as
* <code>MailAddress</code>es to <code>String</code>s.
*/
- protected abstract void mapRecipients(Map recipientsMap) throws MessagingException;
+ protected abstract void mapRecipients(Map<MailAddress,String> recipientsMap) throws MessagingException;
/**
* Sends the message for DSN processing
@@ -208,11 +208,13 @@
// parse "error:<code> <msg>"
int msgPos = error.indexOf(' ');
try {
+ @SuppressWarnings("unused")
Integer code = Integer.valueOf(error.substring("error:".length(),msgPos));
} catch (NumberFormatException e) {
log("Cannot send DSN. Exception parsing DSN code from: " + error, e);
return;
}
+ @SuppressWarnings("unused")
String msg = error.substring(msgPos + 1);
// process bounce for "source" address
try {
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListserv.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListserv.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListserv.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListserv.java Mon Nov 23 14:55:58 2009
@@ -21,13 +21,11 @@
package org.apache.james.transport.mailets;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.api.user.UsersRepository;
import org.apache.james.api.user.UsersStore;
import org.apache.mailet.MailAddress;
+import javax.annotation.Resource;
import javax.mail.internet.ParseException;
import java.util.Collection;
import java.util.Iterator;
@@ -100,6 +98,13 @@
*/
private UsersRepository members;
+ private UsersStore usersStore;
+
+ @Resource(name="org.apache.james.api.user.UsersStore")
+ public void setUsersStore(UsersStore usersStore) {
+ this.usersStore = usersStore;
+ }
+
/**
* Initialize the mailet
*/
@@ -127,23 +132,19 @@
// Ignore any exceptions, default to true
}
- ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
try {
- UsersStore usersStore = (UsersStore)compMgr.lookup(UsersStore.ROLE);
String repName = getInitParameter("repositoryName");
members = (UsersRepository)usersStore.getRepository( repName );
- } catch (ServiceException cnfe) {
- log("Failed to retrieve Store component:" + cnfe.getMessage());
} catch (Exception e) {
log("Failed to retrieve Store component:" + e.getMessage());
}
}
- public Collection getMembers() throws ParseException {
- Collection reply = new ArrayList();
- for (Iterator it = members.list(); it.hasNext(); ) {
- String member = it.next().toString();
+ public Collection<MailAddress> getMembers() throws ParseException {
+ Collection<MailAddress> reply = new ArrayList<MailAddress>();
+ for (Iterator<String> it = members.list(); it.hasNext(); ) {
+ String member = it.next();
try {
reply.add(new MailAddress(member));
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListservManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListservManager.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListservManager.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/AvalonListservManager.java Mon Nov 23 14:55:58 2009
@@ -21,9 +21,8 @@
package org.apache.james.transport.mailets;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
+import javax.annotation.Resource;
+
import org.apache.james.api.user.UsersRepository;
import org.apache.james.api.user.UsersStore;
import org.apache.mailet.MailAddress;
@@ -42,18 +41,21 @@
private UsersRepository members;
+ private UsersStore usersStore;
+
+ @Resource(name="org.apache.james.api.user.UsersStore")
+ public void setUsersStore(UsersStore usersStore) {
+ this.usersStore = usersStore;
+ }
+
/**
* Initialize the mailet
*/
public void init() {
- ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
try {
- UsersStore usersStore = (UsersStore) compMgr.lookup(UsersStore.ROLE);
String repName = getInitParameter("repositoryName");
members = (UsersRepository) usersStore.getRepository(repName);
- } catch (ServiceException cnfe) {
- log("Failed to retrieve Store component:" + cnfe.getMessage());
} catch (Exception e) {
log("Failed to retrieve Store component:" + e.getMessage());
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java Mon Nov 23 14:55:58 2009
@@ -21,20 +21,6 @@
package org.apache.james.transport.mailets;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
-import org.apache.james.util.bayesian.JDBCBayesianAnalyzer;
-import org.apache.james.util.sql.JDBCUtil;
-import org.apache.mailet.base.GenericMailet;
-import org.apache.mailet.Mail;
-import org.apache.mailet.base.RFC2822Headers;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.StringReader;
@@ -43,6 +29,19 @@
import java.util.Collection;
import java.util.Iterator;
+import javax.annotation.Resource;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
+import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.james.util.bayesian.JDBCBayesianAnalyzer;
+import org.apache.james.util.sql.JDBCUtil;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
+import org.apache.mailet.base.RFC2822Headers;
+
/**
* <P>Spam detection mailet using bayesian analysis techniques.</P>
*
@@ -155,6 +154,8 @@
* Holds value of property lastCorpusLoadTime.
*/
private long lastCorpusLoadTime;
+
+ private DataSourceSelector selector;
/**
* Getter for property maxSize.
@@ -183,6 +184,11 @@
return this.lastCorpusLoadTime;
}
+ @Resource(name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")
+ public void setDataSourceSelector(DataSourceSelector selector) {
+ this.selector = selector;
+ }
+
/**
* Sets lastCorpusLoadTime to System.currentTimeMillis().
*/
@@ -225,26 +231,21 @@
initDb();
- CorpusLoader corpusLoader = new CorpusLoader(this);
- corpusLoader.setDaemon(true);
- corpusLoader.start();
+ CorpusLoader corpusLoader = new CorpusLoader(this);
+ corpusLoader.setDaemon(true);
+ corpusLoader.start();
}
private void initDb() throws MessagingException {
try {
- ServiceManager serviceManager = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
- // Get the DataSourceSelector block
- DataSourceSelector datasources = (DataSourceSelector) serviceManager.lookup(DataSourceSelector.ROLE);
-
// Get the data-source required.
int stindex = repositoryPath.indexOf("://") + 3;
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) datasources.select(datasourceName);
+ datasource = (DataSourceComponent) selector.select(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
@@ -276,7 +277,7 @@
if (ignoreLocalSender) {
// ignore the message if the sender is local
if (mail.getSender() != null
- && getMailetContext().isLocalServer(mail.getSender().getHost())) {
+ && getMailetContext().isLocalServer(mail.getSender().getDomain())) {
return;
}
}
@@ -362,12 +363,12 @@
}
- private String getAddressesString(Collection addresses) {
+ private String getAddressesString(Collection<MailAddress> addresses) {
if (addresses == null) {
return "null";
}
- Iterator iter = addresses.iterator();
+ Iterator<MailAddress> iter = addresses.iterator();
StringBuffer sb = new StringBuffer();
sb.append('[');
for (int i = 0; iter.hasNext(); i++) {
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java Mon Nov 23 14:55:58 2009
@@ -22,25 +22,22 @@
package org.apache.james.transport.mailets;
import java.io.BufferedReader;
-import java.io.StringReader;
import java.io.ByteArrayOutputStream;
-
+import java.io.StringReader;
import java.sql.Connection;
import java.util.Enumeration;
-import javax.mail.internet.MimeMessage;
+import javax.annotation.Resource;
import javax.mail.Header;
import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
-import org.apache.mailet.base.GenericMailet;
-import org.apache.mailet.Mail;
-
import org.apache.james.util.bayesian.JDBCBayesianAnalyzer;
import org.apache.james.util.sql.JDBCUtil;
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.GenericMailet;
/**
* <P>Feeds ham OR spam messages to train the {@link BayesianAnalysis} mailet.</P>
@@ -145,6 +142,8 @@
* Holds value of property maxSize.
*/
private int maxSize = 100000;
+
+ private DataSourceSelector selector;
/**
* Getter for property maxSize.
@@ -155,6 +154,12 @@
return this.maxSize;
}
+
+ @Resource(name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")
+ public void setDataSourceSelector(DataSourceSelector selector) {
+ this.selector = selector;
+ }
+
/**
* Setter for property maxSize.
* @param maxSize New value of property maxSize.
@@ -193,17 +198,12 @@
private void initDb() throws MessagingException {
try {
- ServiceManager serviceManager = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
- // Get the DataSourceSelector block
- DataSourceSelector datasources = (DataSourceSelector) serviceManager.lookup(DataSourceSelector.ROLE);
-
// Get the data-source required.
int stindex = repositoryPath.indexOf("://") + 3;
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) datasources.select(datasourceName);
+ datasource = (DataSourceComponent) selector.select(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java Mon Nov 23 14:55:58 2009
@@ -23,14 +23,13 @@
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetException;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.ParseException;
@@ -59,7 +58,14 @@
protected DataSourceComponent datasource;
protected String query = null;
+ private DataSourceSelector selector;
+
+ @Resource(name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")
+ public void setDataSourceSelector(DataSourceSelector selector) {
+ this.selector = selector;
+ }
+
// The JDBCUtil helper class
private final JDBCUtil theJDBCUtil =
new JDBCUtil() {
@@ -87,11 +93,9 @@
throw new MailetException("target_column not specified for JDBCAlias");
}
try {
- ServiceManager componentManager = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
- // Get the DataSourceSelector service
- DataSourceSelector datasources = (DataSourceSelector)componentManager.lookup(DataSourceSelector.ROLE);
+
// Get the data-source required.
- datasource = (DataSourceComponent)datasources.select(datasourceName);
+ datasource = (DataSourceComponent)selector.select(datasourceName);
conn = datasource.getConnection();
@@ -137,17 +141,17 @@
PreparedStatement mappingStmt = null;
ResultSet mappingRS = null;
- Collection recipients = mail.getRecipients();
- Collection recipientsToRemove = new Vector();
- Collection recipientsToAdd = new Vector();
+ Collection<MailAddress> recipients = mail.getRecipients();
+ Collection<MailAddress> recipientsToRemove = new Vector<MailAddress>();
+ Collection<MailAddress> recipientsToAdd = new Vector<MailAddress>();
try {
conn = datasource.getConnection();
mappingStmt = conn.prepareStatement(query);
- for (Iterator i = recipients.iterator(); i.hasNext(); ) {
+ for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext(); ) {
try {
- MailAddress source = (MailAddress)i.next();
+ MailAddress source = i.next();
mappingStmt.setString(1, source.toString());
mappingRS = mappingStmt.executeQuery();
if (!mappingRS.next()) {
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCListserv.java Mon Nov 23 14:55:58 2009
@@ -23,12 +23,11 @@
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetException;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.ParseException;
@@ -67,7 +66,7 @@
protected boolean cacheSettings = true;
//Settings for this listserv
- protected Collection members = null;
+ protected Collection<MailAddress> members = null;
protected boolean membersOnly = true;
protected boolean attachmentsAllowed = true;
protected boolean replyToList = true;
@@ -77,7 +76,14 @@
//Queries to DB
protected String listservQuery = null;
protected String membersQuery = null;
+ private DataSourceSelector selector;
+
+ @Resource(name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")
+ public void setDataSourceSelector(DataSourceSelector selector) {
+ this.selector = selector;
+ }
+
/**
* The JDBCUtil helper class
*/
@@ -121,11 +127,8 @@
Connection conn = null;
try {
- ServiceManager componentManager = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
- // Get the DataSourceSelector service
- DataSourceSelector datasources = (DataSourceSelector)componentManager.lookup(DataSourceSelector.ROLE);
// Get the data-source required.
- datasource = (DataSourceComponent)datasources.select(datasourceName);
+ datasource = (DataSourceComponent)selector.select(datasourceName);
conn = datasource.getConnection();
@@ -185,7 +188,7 @@
/**
* Returns a Collection of MailAddress objects of members to receive this email
*/
- public Collection getMembers() throws MessagingException {
+ public Collection<MailAddress> getMembers() throws MessagingException {
if (!cacheSettings) {
loadSettings();
}
@@ -250,7 +253,7 @@
stmt = conn.prepareStatement(membersQuery);
stmt.setString(1, listservID);
rs = stmt.executeQuery();
- Collection tmpMembers = new Vector();
+ Collection<MailAddress> tmpMembers = new Vector<MailAddress>();
while (rs.next()) {
String address = rs.getString(1);
try {
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/JDBCVirtualUserTable.java Mon Nov 23 14:55:58 2009
@@ -23,13 +23,12 @@
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.impl.vut.VirtualUserTableUtil;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetException;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.sql.Connection;
@@ -109,6 +108,14 @@
}
};
+ private DataSourceSelector selector;
+
+ @Resource(name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")
+ public void setDataSourceSelector(DataSourceSelector selector) {
+ this.selector = selector;
+ }
+
+
/**
* Initialize the mailet
*/
@@ -126,11 +133,8 @@
Connection conn = null;
try {
- ServiceManager componentManager = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
- // Get the DataSourceSelector service
- DataSourceSelector datasources = (DataSourceSelector)componentManager.lookup(DataSourceSelector.ROLE);
// Get the data-source required.
- datasource = (DataSourceComponent)datasources.select(datasourceName);
+ datasource = (DataSourceComponent)selector.select(datasourceName);
conn = datasource.getConnection();
@@ -166,23 +170,23 @@
*
* @param recipientsMap the mapping of virtual to real recipients
*/
- protected void mapRecipients(Map recipientsMap) throws MessagingException {
+ protected void mapRecipients(Map<MailAddress,String> recipientsMap) throws MessagingException {
Connection conn = null;
PreparedStatement mappingStmt = null;
- Collection recipients = recipientsMap.keySet();
+ Collection<MailAddress> recipients = recipientsMap.keySet();
try {
conn = datasource.getConnection();
mappingStmt = conn.prepareStatement(query);
- for (Iterator i = recipients.iterator(); i.hasNext(); ) {
+ for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext(); ) {
ResultSet mappingRS = null;
try {
- MailAddress source = (MailAddress)i.next();
- mappingStmt.setString(1, source.getUser());
- mappingStmt.setString(2, source.getHost());
- mappingStmt.setString(3, source.getHost());
+ MailAddress source = i.next();
+ mappingStmt.setString(1, source.getLocalPart());
+ mappingStmt.setString(2, source.getDomain());
+ mappingStmt.setString(3, source.getDomain());
mappingRS = mappingStmt.executeQuery();
if (mappingRS.next()) {
String targetString = mappingRS.getString(1);
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java Mon Nov 23 14:55:58 2009
@@ -121,8 +121,8 @@
/**
* @return the postmaster address
*/
- protected Collection getRecipients() {
- Collection newRecipients = new HashSet();
+ protected Collection<MailAddress> getRecipients() {
+ Collection<MailAddress> newRecipients = new HashSet<MailAddress>();
newRecipients.add(getMailetContext().getPostmaster());
return newRecipients;
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifySender.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifySender.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifySender.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/NotifySender.java Mon Nov 23 14:55:58 2009
@@ -120,8 +120,8 @@
/**
* @return <CODE>SpecialAddress.SENDER</CODE>, indicating the sender of the current mail
*/
- protected Collection getRecipients() {
- Collection newRecipients = new HashSet();
+ protected Collection<MailAddress> getRecipients() {
+ Collection<MailAddress> newRecipients = new HashSet<MailAddress>();
newRecipients.add(SpecialAddress.SENDER);
return newRecipients;
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Redirect.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Redirect.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Redirect.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Redirect.java Mon Nov 23 14:55:58 2009
@@ -330,8 +330,8 @@
* or the <CODE>to</CODE> init parameter if missing
* or <CODE>null</CODE> if also the latter is missing
*/
- protected Collection getRecipients() throws MessagingException {
- Collection newRecipients = new HashSet();
+ protected Collection<MailAddress> getRecipients() throws MessagingException {
+ Collection<MailAddress> newRecipients = new HashSet<MailAddress>();
String addressList = getInitParameter("recipients",getInitParameter("to"));
// if nothing was specified, return <CODE>null</CODE> meaning no change
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java Mon Nov 23 14:55:58 2009
@@ -23,8 +23,6 @@
import org.apache.avalon.cornerstone.services.store.Store;
import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.james.Constants;
import org.apache.james.api.dnsservice.DNSService;
@@ -42,6 +40,7 @@
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
+import javax.annotation.Resource;
import javax.mail.Address;
import javax.mail.MessagingException;
import javax.mail.SendFailedException;
@@ -261,6 +260,20 @@
/** The retry count dnsProblemErrors */
private int dnsProblemRetry = 0;
+
+ private Store mailStore;
+
+
+ @Resource(name="org.apache.avalon.cornerstone.services.store.Store")
+ public void setStore(Store mailStore) {
+ this.mailStore = mailStore;
+ }
+
+ @Resource(name="org.apache.james.api.dnsservice.DNSService")
+ public void setDNSService(DNSService dnsService) {
+ this.dnsServer = dnsService;
+ }
+
/**
* Initializes all arguments based on configuration values specified in the
@@ -343,10 +356,6 @@
} catch (Exception e) {
log("Invalid maxRetries setting: " + getInitParameter("maxRetries"));
}
-
- ServiceManager compMgr = (ServiceManager) getMailetContext()
- .getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
// Get the path for the 'Outgoing' repository. This is the place on the
// file system where Mail objects will be saved during the 'delivery'
// processing. This can be changed to a repository on a database (e.g.
@@ -357,14 +366,11 @@
}
try {
- // Instantiate a MailRepository for mails to be processed.
- Store mailstore = (Store) compMgr.lookup(Store.ROLE);
-
DefaultConfigurationBuilder spoolConf = new DefaultConfigurationBuilder();
spoolConf.addProperty("[@destinationURL]", workRepositoryPath);
spoolConf.addProperty("[@type]", "SPOOL");
- workRepository = (SpoolRepository) mailstore.select(spoolConf);
- } catch (ServiceException cnfe) {
+ workRepository = (SpoolRepository) mailStore.select(spoolConf);
+ } catch (Exception cnfe) {
log("Failed to retrieve Store component:" + cnfe.getMessage());
throw new MessagingException("Failed to retrieve Store component",
cnfe);
@@ -423,13 +429,6 @@
authPass = getInitParameter("gatewayPassword");
}
- // Instantiate the DNSService for DNS queries lookup
- try {
- dnsServer = (DNSService) compMgr.lookup(DNSService.ROLE);
- } catch (ServiceException e1) {
- log("Failed to retrieve DNSService" + e1.getMessage());
- }
-
bindAddress = getInitParameter("bind");
isBindUsed = bindAddress != null;
try {
@@ -439,9 +438,9 @@
}
// deal with <mail.*> attributes, passing them to javamail
- Iterator i = getInitParameterNames();
+ Iterator<String> i = getInitParameterNames();
while (i.hasNext()) {
- String name = (String) i.next();
+ String name = i.next();
if (name.startsWith("mail.")) {
defprops.put(name,getInitParameter(name));
}
@@ -624,14 +623,14 @@
if (isDebug) {
log("Remotely delivering mail " + mail.getName());
}
- Collection recipients = mail.getRecipients();
+ Collection<MailAddress> recipients = mail.getRecipients();
if (gatewayServer == null) {
// Must first organize the recipients into distinct servers (name made case insensitive)
Hashtable<String, Collection<MailAddress>> targets = new Hashtable<String, Collection<MailAddress>>();
- for (Iterator i = recipients.iterator(); i.hasNext();) {
- MailAddress target = (MailAddress)i.next();
- String targetServer = target.getHost().toLowerCase(Locale.US);
+ for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext();) {
+ MailAddress target = i.next();
+ String targetServer = target.getDomain().toLowerCase(Locale.US);
Collection<MailAddress> temp = targets.get(targetServer);
if (temp == null) {
temp = new ArrayList<MailAddress>();
@@ -645,8 +644,8 @@
// Store the new message containers, organized by server, in the outgoing mail repository
String name = mail.getName();
- for (Iterator i = targets.keySet().iterator(); i.hasNext(); ) {
- String host = (String) i.next();
+ for (Iterator<String> i = targets.keySet().iterator(); i.hasNext(); ) {
+ String host = i.next();
Collection<MailAddress> rec = targets.get(host);
if (isDebug) {
StringBuilder logMessageBuffer =
@@ -857,11 +856,11 @@
MimeMessage message = mail.getMessage();
//Create an array of the recipients as InternetAddress objects
- Collection recipients = mail.getRecipients();
+ Collection<MailAddress> recipients = mail.getRecipients();
InternetAddress addr[] = new InternetAddress[recipients.size()];
int j = 0;
- for (Iterator i = recipients.iterator(); i.hasNext(); j++) {
- MailAddress rcpt = (MailAddress)i.next();
+ for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext(); j++) {
+ MailAddress rcpt = i.next();
addr[j] = rcpt.toInternetAddress();
}
@@ -875,7 +874,7 @@
Iterator<HostAddress> targetServers = null;
if (gatewayServer == null) {
MailAddress rcpt = (MailAddress) recipients.iterator().next();
- String host = rcpt.getHost();
+ String host = rcpt.getDomain();
//Lookup the possible targets
try {
@@ -1115,7 +1114,7 @@
} catch (SendFailedException sfe) {
logSendFailedException(sfe);
- Collection recipients = mail.getRecipients();
+ Collection<MailAddress> recipients = mail.getRecipients();
boolean deleteMessage = false;
@@ -1517,7 +1516,7 @@
out.println("I include the list of recipients and the reason why I was unable to deliver");
out.println("your message.");
out.println();
- for (Iterator i = mail.getRecipients().iterator(); i.hasNext(); ) {
+ for (Iterator<MailAddress> i = mail.getRecipients().iterator(); i.hasNext(); ) {
out.println(i.next());
}
if (ex instanceof MessagingException) {
@@ -1645,12 +1644,5 @@
}
};
}
-
- /**
- * Setter for the dnsserver service
- * @param dnsServer dns service
- */
- protected synchronized void setDNSServer(DNSService dnsServer) {
- this.dnsServer = dnsServer;
- }
+
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Retry.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Retry.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Retry.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/Retry.java Mon Nov 23 14:55:58 2009
@@ -20,10 +20,8 @@
package org.apache.james.transport.mailets;
import org.apache.avalon.cornerstone.services.store.Store;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.james.Constants;
import org.apache.james.services.SpoolRepository;
import org.apache.mailet.base.GenericMailet;
@@ -35,6 +33,7 @@
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.util.ArrayList;
@@ -99,7 +98,7 @@
// Holds allowed units for delayTime together with factor to turn it into
// the
// equivalent time in milliseconds.
- private static final HashMap MULTIPLIERS = new HashMap(10);
+ private static final HashMap<String,Integer> MULTIPLIERS = new HashMap<String,Integer>(10);
/*
* Compiles pattern for processing delayTime entries. <p>Initializes
@@ -210,7 +209,7 @@
private int workersThreadCount = 1;
// Collection that stores all worker threads.
- private Collection workersThreads = new Vector();
+ private Collection<Thread> workersThreads = new Vector<Thread>();
// Processor that will be called for retrying. Defaults to "root" processor.
private String retryProcessor = Mail.DEFAULT;
@@ -233,6 +232,14 @@
// Path of the retry repository
private String workRepositoryPath = null;
+ private Store mailStore;
+
+
+ @Resource(name="org.apache.avalon.cornerstone.services.store.Store")
+ public void setStore(Store mailStore) {
+ this.mailStore = mailStore;
+ }
+
/**
* Initializes all arguments based on configuration values specified in the
* James configuration file.
@@ -245,7 +252,7 @@
isDebug = (getInitParameter("debug") == null) ? false : new Boolean(getInitParameter("debug")).booleanValue();
// Create list of Delay Times.
- ArrayList delayTimesList = new ArrayList();
+ ArrayList<Delay> delayTimesList = new ArrayList<Delay>();
try {
if (getInitParameter("delayTime") != null) {
delayTimeMatcher = new Perl5Matcher();
@@ -311,10 +318,7 @@
} catch (Exception e) {
log("Invalid maxRetries setting: " + getInitParameter("maxRetries"));
}
-
- ServiceManager compMgr = (ServiceManager) getMailetContext()
- .getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
+
// Get the path for the 'Retry' repository. This is the place on the
// file system where Mail objects will be saved during the 'retry'
// processing. This can be changed to a repository on a database (e.g.
@@ -325,15 +329,11 @@
}
try {
- // Instantiate a MailRepository for mails that should be retried.
- Store mailstore = (Store) compMgr.lookup(Store.ROLE);
-
- DefaultConfiguration spoolConf = new DefaultConfiguration(
- "repository", "generated:Retry");
- spoolConf.setAttribute("destinationURL", workRepositoryPath);
- spoolConf.setAttribute("type", "SPOOL");
- workRepository = (SpoolRepository) mailstore.select(spoolConf);
- } catch (ServiceException cnfe) {
+ DefaultConfigurationBuilder spoolConf = new DefaultConfigurationBuilder();
+ spoolConf.addProperty("[@destinationURL]", workRepositoryPath);
+ spoolConf.addProperty("[@type]", "SPOOL");
+ workRepository = (SpoolRepository) mailStore.select(spoolConf);
+ } catch (Exception cnfe) {
log("Failed to retrieve Store component:" + cnfe.getMessage());
throw new MessagingException("Failed to retrieve Store component",
cnfe);
@@ -364,11 +364,11 @@
* list of 'Delay' objects
* @return total no. of retry attempts
*/
- private int calcTotalAttempts (ArrayList delayList) {
+ private int calcTotalAttempts (ArrayList<Delay> delayList) {
int sum = 0;
- Iterator i = delayList.iterator();
+ Iterator<Delay> i = delayList.iterator();
while (i.hasNext()) {
- Delay delay = (Delay)i.next();
+ Delay delay = i.next();
sum += delay.getAttempts();
}
return sum;
@@ -396,7 +396,7 @@
* the list to expand
* @return the expanded list
**/
- private long[] expandDelays(ArrayList delayList) {
+ private long[] expandDelays(ArrayList<Delay> delayList) {
long[] delays = new long[calcTotalAttempts(delayList)];
int idx = 0;
for (int i = 0; i < delayList.size(); i++) {
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java Mon Nov 23 14:55:58 2009
@@ -88,11 +88,11 @@
spamdPort);
sa.scanMail(message);
- Iterator headers = sa.getHeadersAsAttribute().keySet().iterator();
+ Iterator<String> headers = sa.getHeadersAsAttribute().keySet().iterator();
// Add headers as attribute to mail object
while (headers.hasNext()) {
- String key = headers.next().toString();
+ String key = headers.next();
mail.setAttribute(key, (String) sa.getHeadersAsAttribute().get(key));
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/ToRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/ToRepository.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/ToRepository.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/ToRepository.java Mon Nov 23 14:55:58 2009
@@ -21,11 +21,10 @@
package org.apache.james.transport.mailets;
+import javax.annotation.Resource;
+
import org.apache.avalon.cornerstone.services.store.Store;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.james.services.MailRepository;
import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
@@ -56,6 +55,14 @@
*/
private String repositoryPath;
+ private Store mailStore;
+
+
+ @Resource(name="org.apache.avalon.cornerstone.services.store.Store")
+ public void setStore(Store mailStore) {
+ this.mailStore = mailStore;
+ }
+
/**
* Initialize the mailet, loading configuration information.
*/
@@ -67,17 +74,13 @@
// Ignore exception, default to false
}
- ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
try {
- Store mailstore = (Store) compMgr.lookup(Store.ROLE);
- DefaultConfiguration mailConf
- = new DefaultConfiguration("repository", "generated:ToRepository");
- mailConf.setAttribute("destinationURL", repositoryPath);
- mailConf.setAttribute("type", "MAIL");
- mailConf.setAttribute("CACHEKEYS", getInitParameter("CACHEKEYS","TRUE"));
- repository = (MailRepository) mailstore.select(mailConf);
- } catch (ServiceException cnfe) {
- log("Failed to retrieve Store component:" + cnfe.getMessage());
+ DefaultConfigurationBuilder mailConf
+ = new DefaultConfigurationBuilder();
+ mailConf.addProperty("[@destinationURL]", repositoryPath);
+ mailConf.addProperty("[@type]", "MAIL");
+ mailConf.addProperty("[@CACHEKEYS]", getInitParameter("CACHEKEYS","TRUE"));
+ repository = (MailRepository) mailStore.select(mailConf);
} catch (Exception e) {
log("Failed to retrieve Store component:" + e.getMessage());
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java Mon Nov 23 14:55:58 2009
@@ -23,8 +23,6 @@
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.api.user.JamesUser;
import org.apache.james.api.user.UsersRepository;
import org.apache.james.util.sql.JDBCUtil;
@@ -35,6 +33,7 @@
import org.apache.mailet.base.RFC2822Headers;
import org.apache.mailet.base.RFC822DateFormat;
+import javax.annotation.Resource;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
@@ -156,13 +155,27 @@
/**
* Holds value of property sqlParameters.
*/
- private Map sqlParameters = new HashMap();
+ private Map<String,String> sqlParameters = new HashMap<String,String>();
+
+ private DataSourceSelector selector;
+
+ @Resource(name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")
+ public void setDataSourceSelector(DataSourceSelector selector) {
+ this.selector = selector;
+ }
+
+ @Resource(name="org.apache.james.api.user.UsersRepository")
+ public void setUsersRepository(UsersRepository localusers) {
+ this.localusers = localusers;
+ }
+
+
/**
* Getter for property sqlParameters.
* @return Value of property sqlParameters.
*/
- private Map getSqlParameters() {
+ private Map<String,String> getSqlParameters() {
return this.sqlParameters;
}
@@ -222,26 +235,15 @@
throw new MessagingException("repositoryPath is null");
}
- ServiceManager serviceManager = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
try {
- // Get the DataSourceSelector block
- DataSourceSelector datasources = (DataSourceSelector) serviceManager.lookup(DataSourceSelector.ROLE);
// Get the data-source required.
int stindex = repositoryPath.indexOf("://") + 3;
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) datasources.select(datasourceName);
+ datasource = (DataSourceComponent) selector.select(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
- try {
- // Get the UsersRepository
- localusers = (UsersRepository)serviceManager.lookup(UsersRepository.ROLE);
- } catch (Exception e) {
- throw new MessagingException("Can't get the local users repository", e);
- }
-
try {
initSqlQueries(datasource.getConnection(), getMailetContext());
} catch (Exception e) {
@@ -268,7 +270,7 @@
return;
}
- Collection recipients = mail.getRecipients();
+ Collection<MailAddress> recipients = mail.getRecipients();
if (recipients.size() == 1
&& whitelistManagerAddress != null
@@ -313,9 +315,9 @@
/** Loops through each address in the recipient list, checks if in the senders
* list and inserts in it otherwise.
*/
- private void checkAndInsert(MailAddress senderMailAddress, Collection recipients) throws MessagingException {
- String senderUser = senderMailAddress.getUser().toLowerCase(Locale.US);
- String senderHost = senderMailAddress.getHost().toLowerCase(Locale.US);
+ private void checkAndInsert(MailAddress senderMailAddress, Collection<MailAddress> recipients) throws MessagingException {
+ String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String senderHost = senderMailAddress.getDomain().toLowerCase(Locale.US);
senderUser = getPrimaryName(senderUser);
@@ -326,12 +328,12 @@
try {
- for (Iterator i = recipients.iterator(); i.hasNext(); ) {
+ for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext(); ) {
ResultSet selectRS = null;
try {
MailAddress recipientMailAddress = (MailAddress)i.next();
- String recipientUser = recipientMailAddress.getUser().toLowerCase(Locale.US);
- String recipientHost = recipientMailAddress.getHost().toLowerCase(Locale.US);
+ String recipientUser = recipientMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String recipientHost = recipientMailAddress.getDomain().toLowerCase(Locale.US);
if (getMailetContext().isLocalServer(recipientHost)) {
// not a remote recipient, so skip
@@ -398,8 +400,8 @@
private void manageDisplayRequest(Mail mail)
throws MessagingException {
MailAddress senderMailAddress = mail.getSender();
- String senderUser = senderMailAddress.getUser().toLowerCase(Locale.US);
- String senderHost = senderMailAddress.getHost().toLowerCase(Locale.US);
+ String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String senderHost = senderMailAddress.getDomain().toLowerCase(Locale.US);
senderUser = getPrimaryName(senderUser);
@@ -447,8 +449,8 @@
private void manageInsertRequest(Mail mail)
throws MessagingException {
MailAddress senderMailAddress = mail.getSender();
- String senderUser = senderMailAddress.getUser().toLowerCase(Locale.US);
- String senderHost = senderMailAddress.getHost().toLowerCase(Locale.US);
+ String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String senderHost = senderMailAddress.getDomain().toLowerCase(Locale.US);
senderUser = getPrimaryName(senderUser);
@@ -482,8 +484,8 @@
catch (javax.mail.internet.ParseException pe) {
continue;
}
- String recipientUser = recipientMailAddress.getUser().toLowerCase(Locale.US);
- String recipientHost = recipientMailAddress.getHost().toLowerCase(Locale.US);
+ String recipientUser = recipientMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String recipientHost = recipientMailAddress.getDomain().toLowerCase(Locale.US);
if (getMailetContext().isLocalServer(recipientHost)) {
// not a remote recipient, so skip
@@ -570,8 +572,8 @@
private void manageRemoveRequest(Mail mail)
throws MessagingException {
MailAddress senderMailAddress = mail.getSender();
- String senderUser = senderMailAddress.getUser().toLowerCase(Locale.US);
- String senderHost = senderMailAddress.getHost().toLowerCase(Locale.US);
+ String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String senderHost = senderMailAddress.getDomain().toLowerCase(Locale.US);
senderUser = getPrimaryName(senderUser);
@@ -605,8 +607,8 @@
catch (javax.mail.internet.ParseException pe) {
continue;
}
- String recipientUser = recipientMailAddress.getUser().toLowerCase(Locale.US);
- String recipientHost = recipientMailAddress.getHost().toLowerCase(Locale.US);
+ String recipientUser = recipientMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String recipientHost = recipientMailAddress.getDomain().toLowerCase(Locale.US);
if (getMailetContext().isLocalServer(recipientHost)) {
// not a remote recipient, so skip
@@ -718,7 +720,7 @@
reply.setHeader(RFC2822Headers.CONTENT_TYPE, multipart.getContentType());
//Create the list of recipients in our MailAddress format
- Set recipients = new HashSet();
+ Set<MailAddress> recipients = new HashSet<MailAddress>();
recipients.add(senderMailAddress);
//Set additional headers
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java Mon Nov 23 14:55:58 2009
@@ -80,13 +80,13 @@
*
* @param recipientsMap the mapping of virtual to real recipients
*/
- protected void mapRecipients(Map recipientsMap) throws MessagingException {
- Collection recipients = recipientsMap.keySet();
+ protected void mapRecipients(Map<MailAddress,String> recipientsMap) throws MessagingException {
+ Collection<MailAddress> recipients = recipientsMap.keySet();
- for (Iterator i = recipients.iterator(); i.hasNext(); ) {
- MailAddress source = (MailAddress)i.next();
- String user = source.getUser().toLowerCase();
- String domain = source.getHost().toLowerCase();
+ for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext(); ) {
+ MailAddress source = i.next();
+ String user = source.getLocalPart().toLowerCase();
+ String domain = source.getDomain().toLowerCase();
String targetString = VirtualUserTableUtil.getTargetString(user, domain, mappings);
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java Mon Nov 23 14:55:58 2009
@@ -21,11 +21,10 @@
package org.apache.james.transport.matchers;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.api.dnsservice.util.NetMatcher;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.util.StringTokenizer;
import java.util.Collection;
@@ -63,23 +62,10 @@
*/
private DNSService dnsServer;
- /**
- * The ServiceManger
- */
- private ServiceManager compMgr;
-
+
public void init() throws MessagingException {
- setServiceManager((ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER));
-
- try {
- // Instantiate DNSService
- setDNSServer((DNSService) compMgr.lookup(DNSService.ROLE));
- } catch (Exception e) {
- throw new MessagingException("Failed to retrieve DNSService:" + e.getMessage());
- }
-
- Collection nets = allowedNetworks();
+ Collection<String> nets = allowedNetworks();
if (nets != null) {
authorizedNetworks = new NetMatcher(allowedNetworks(),dnsServer) {
@@ -92,11 +78,11 @@
}
}
- protected Collection allowedNetworks() {
- Collection networks = null;
+ protected Collection<String> allowedNetworks() {
+ Collection<String> networks = null;
if (getCondition() != null) {
StringTokenizer st = new StringTokenizer(getCondition(), ", ", false);
- networks = new java.util.ArrayList();
+ networks = new java.util.ArrayList<String>();
while (st.hasMoreTokens()) networks.add(st.nextToken());
}
return networks;
@@ -111,11 +97,9 @@
}
- private void setDNSServer(DNSService dnsServer) {
- this.dnsServer = dnsServer;
+ @Resource(name="org.apache.james.api.dnsservice.DNSService")
+ public void setDNSService(DNSService dnsService) {
+ this.dnsServer = dnsService;
}
- private void setServiceManager(ServiceManager compMgr) {
- this.compMgr = compMgr;
- }
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java Mon Nov 23 14:55:58 2009
@@ -22,9 +22,6 @@
package org.apache.james.transport.matchers;
import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.api.user.JamesUser;
import org.apache.james.api.user.UsersRepository;
import org.apache.james.services.MailRepository;
@@ -33,6 +30,7 @@
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.util.Iterator;
@@ -53,30 +51,20 @@
private MailServer mailServer;
+ @Resource(name="org.apache.james.services.MailServer")
+ public void setMailServer(MailServer mailServer) {
+ this.mailServer = mailServer;
+ }
+
+ @Resource(name="org.apache.james.api.user.UsersRepository")
+ public void setUsersRepository(UsersRepository localusers) {
+ this.localusers = localusers;
+ }
/** The user repository for this mail server. Contains all the users with inboxes
* on this server.
*/
private UsersRepository localusers;
- /**
- * Standard matcher initialization.
- * Overriding classes must do a <CODE>super.init()</CODE>.
- */
- public void init() throws MessagingException {
- super.init();
- ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
- try {
- mailServer = (MailServer) compMgr.lookup(MailServer.ROLE);
- } catch (ServiceException e) {
- log("Exception in getting the MailServer: " + e.getMessage() + e.getKey());
- }
- try {
- localusers = (UsersRepository) compMgr.lookup(UsersRepository.ROLE);
- } catch (ServiceException e) {
- log("Exception in getting the UsersStore: " + e.getMessage() + e.getKey());
- }
- }
-
/**
* Checks the recipient.
* Does a <CODE>super.isRecipientChecked</CODE> and checks that the recipient
@@ -98,9 +86,9 @@
*/
protected long getUsed(MailAddress recipient, Mail _) throws MessagingException {
long size = 0;
- MailRepository userInbox = mailServer.getUserInbox(getPrimaryName(recipient.getUser()));
- for (Iterator it = userInbox.list(); it.hasNext(); ) {
- String key = (String) it.next();
+ MailRepository userInbox = mailServer.getUserInbox(getPrimaryName(recipient.getLocalPart()));
+ for (Iterator<String> it = userInbox.list(); it.hasNext(); ) {
+ String key = it.next();
Mail mc = userInbox.retrieve(key);
// Retrieve can return null if the mail is no longer in the store.
if (mc != null) try {
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java Mon Nov 23 14:55:58 2009
@@ -23,6 +23,7 @@
import org.apache.mailet.base.GenericMatcher;
import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
@@ -64,7 +65,7 @@
/**
* @see org.apache.mailet.GenericMatcher#match(Mail)
*/
- public Collection match(Mail mail) throws MessagingException {
+ public Collection<MailAddress> match(Mail mail) throws MessagingException {
MimeMessage message = mail.getMessage();
Perl5Matcher matcher = new Perl5Matcher();
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java Mon Nov 23 14:55:58 2009
@@ -24,6 +24,7 @@
import org.apache.mailet.base.GenericMatcher;
import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
import org.apache.mailet.MatcherConfig;
import java.util.Collection;
import javax.mail.MessagingException;
@@ -89,7 +90,7 @@
* interpreted as a regular expression matches the toString value of the
* corresponding attributes value.
**/
- public Collection match (Mail mail) throws MessagingException
+ public Collection<MailAddress> match (Mail mail) throws MessagingException
{
Serializable obj = mail.getAttribute (attributeName);
//to be a little more generic the toString of the value is what is matched against
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java Mon Nov 23 14:55:58 2009
@@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.StringTokenizer;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import org.apache.avalon.framework.service.ServiceException;
@@ -33,6 +34,7 @@
import org.apache.james.api.dnsservice.DNSService;
import org.apache.mailet.base.GenericMatcher;
import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
/**
* Checks the network IP address of the sending server against a
@@ -54,26 +56,22 @@
private DNSService dnsServer;
+
+
+ @Resource(name="org.apache.james.api.dnsservice.DNSService")
+ public void setDNSService(DNSService dnsService) {
+ this.dnsServer = dnsService;
+ }
+
public void init() throws MessagingException {
network = getCondition();
// check if the needed condition was given
if (network == null) throw new MessagingException("Please configure a blacklist");
-
- ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
- try {
- // Instantiate DNSService
- dnsServer = (DNSService) compMgr.lookup(DNSService.ROLE);
- } catch (ServiceException cnfe) {
- log("Failed to retrieve DNSService" + cnfe.getMessage());
- } catch (Exception e) {
- log("Failed to retrieve DNSService:" + e.getMessage());
- }
}
- public Collection match(Mail mail) {
+ public Collection<MailAddress> match(Mail mail) {
String host = mail.getRemoteAddr();
try {
//Have to reverse the octets first
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java Mon Nov 23 14:55:58 2009
@@ -23,8 +23,6 @@
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.james.Constants;
import org.apache.james.api.user.JamesUser;
import org.apache.james.api.user.UsersRepository;
import org.apache.james.transport.mailets.WhiteListManager;
@@ -34,6 +32,7 @@
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.io.File;
@@ -95,13 +94,25 @@
/**
* Holds value of property sqlParameters.
*/
- private Map sqlParameters = new HashMap();
+ private Map<String,String> sqlParameters = new HashMap<String,String>();
+ private DataSourceSelector selector;
+
+ @Resource(name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")
+ public void setDataSourceSelector(DataSourceSelector selector) {
+ this.selector = selector;
+ }
+
+ @Resource(name="org.apache.james.api.user.UsersRepository")
+ public void setUsersRepository(UsersRepository localusers) {
+ this.localusers = localusers;
+ }
+
/**
* Getter for property sqlParameters.
* @return Value of property sqlParameters.
*/
- private Map getSqlParameters() {
+ private Map<String,String> getSqlParameters() {
return this.sqlParameters;
}
@@ -122,26 +133,16 @@
throw new MessagingException("repositoryPath is null");
}
- ServiceManager serviceManager = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
-
+
try {
- // Get the DataSourceSelector block
- DataSourceSelector datasources = (DataSourceSelector) serviceManager.lookup(DataSourceSelector.ROLE);
// Get the data-source required.
int stindex = repositoryPath.indexOf("://") + 3;
String datasourceName = repositoryPath.substring(stindex);
- datasource = (DataSourceComponent) datasources.select(datasourceName);
+ datasource = (DataSourceComponent) selector.select(datasourceName);
} catch (Exception e) {
throw new MessagingException("Can't get datasource", e);
}
- try {
- // Get the UsersRepository
- localusers = (UsersRepository)serviceManager.lookup(UsersRepository.ROLE);
- } catch (Exception e) {
- throw new MessagingException("Can't get the local users repository", e);
- }
-
try {
initSqlQueries(datasource.getConnection(), getMailetContext());
} catch (Exception e) {
@@ -154,7 +155,7 @@
/**
* @see org.apache.mailet.GenericMatcher#match(Mail)
*/
- public Collection match(Mail mail) throws MessagingException {
+ public Collection<MailAddress> match(Mail mail) throws MessagingException {
// check if it's a local sender
MailAddress senderMailAddress = mail.getSender();
if (senderMailAddress == null) {
@@ -165,26 +166,26 @@
return null;
}
- String senderUser = senderMailAddress.getUser();
- String senderHost = senderMailAddress.getHost();
+ String senderUser = senderMailAddress.getLocalPart();
+ String senderHost = senderMailAddress.getDomain();
senderUser = senderUser.toLowerCase(Locale.US);
senderHost = senderHost.toLowerCase(Locale.US);
- Collection recipients = mail.getRecipients();
+ Collection<MailAddress> recipients = mail.getRecipients();
- Collection inWhiteList = new java.util.HashSet();
+ Collection<MailAddress> inWhiteList = new java.util.HashSet<MailAddress>();
Connection conn = null;
PreparedStatement selectStmt = null;
ResultSet selectRS = null;
try {
- for (Iterator i = recipients.iterator(); i.hasNext(); ) {
+ for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext(); ) {
try {
- MailAddress recipientMailAddress = (MailAddress)i.next();
- String recipientUser = recipientMailAddress.getUser().toLowerCase(Locale.US);
- String recipientHost = recipientMailAddress.getHost().toLowerCase(Locale.US);
+ MailAddress recipientMailAddress = i.next();
+ String recipientUser = recipientMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String recipientHost = recipientMailAddress.getDomain().toLowerCase(Locale.US);
if (!getMailetContext().isLocalServer(recipientHost)) {
// not a local recipient, so skip
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java Mon Nov 23 14:55:58 2009
@@ -22,6 +22,7 @@
package org.apache.james.transport.matchers;
import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
import java.util.Collection;
@@ -34,7 +35,7 @@
*
*/
public class RemoteAddrInNetwork extends AbstractNetworkMatcher {
- public Collection match(Mail mail) {
+ public Collection<MailAddress> match(Mail mail) {
return matchNetwork(mail.getRemoteAddr()) ? mail.getRecipients() : null;
}
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java Mon Nov 23 14:55:58 2009
@@ -22,6 +22,7 @@
package org.apache.james.transport.matchers;
import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
import java.util.Collection;
@@ -34,7 +35,7 @@
*
*/
public class RemoteAddrNotInNetwork extends AbstractNetworkMatcher {
- public Collection match(Mail mail) {
+ public Collection<MailAddress> match(Mail mail) {
return matchNetwork(mail.getRemoteAddr()) ? null : mail.getRecipients();
}
}
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java Mon Nov 23 14:55:58 2009
@@ -22,6 +22,7 @@
package org.apache.james.transport.matchers;
import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
import java.util.Collection;
@@ -33,13 +34,13 @@
*/
public class SenderInFakeDomain extends AbstractNetworkMatcher {
- public Collection match(Mail mail) {
+ public Collection<MailAddress> match(Mail mail) {
if (mail.getSender() == null) {
return null;
}
- String domain = mail.getSender().getHost();
+ String domain = mail.getSender().getDomain();
//DNS Lookup for this domain
- Collection servers = getMailetContext().getMailServers(domain);
+ Collection<String> servers = getMailetContext().getMailServers(domain);
if (servers.size() == 0) {
//No records...could not deliver to this domain, so matches criteria.
log("No MX, A, or CNAME record found for domain: " + domain);
@@ -62,7 +63,7 @@
*
*/
log("Banned IP found for domain: " + domain);
- log(" --> :" + servers.iterator().next().toString());
+ log(" --> :" + servers.iterator().next());
return mail.getRecipients();
} else {
// Some servers were found... the domain is not fake.
Modified: james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java (original)
+++ james/server/trunk/mailets-function/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java Mon Nov 23 14:55:58 2009
@@ -73,7 +73,7 @@
}
}
- public Collection match(Mail mail) {
+ public Collection<MailAddress> match(Mail mail) {
MailAddress mailAddress = mail.getSender();
if (mailAddress == null) {
return null;
Modified: james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/mailets/StandardRemoteDeliveryTestable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/mailets/StandardRemoteDeliveryTestable.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/mailets/StandardRemoteDeliveryTestable.java (original)
+++ james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/mailets/StandardRemoteDeliveryTestable.java Mon Nov 23 14:55:58 2009
@@ -19,6 +19,7 @@
package org.apache.james.transport.mailets;
+import org.apache.avalon.cornerstone.services.store.Store;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.transport.remotedeliverytester.RemoteDeliveryTestable;
import org.apache.james.transport.remotedeliverytester.Tester;
@@ -53,7 +54,10 @@
}
public void setDNSServer(DNSService dnsServer) {
- super.setDNSServer(dnsServer);
+ super.setDNSService(dnsServer);
}
+ public void setStore(Store mailStore) {
+ super.setStore(mailStore);
+ }
}
Modified: james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java?rev=883358&r1=883357&r2=883358&view=diff
==============================================================================
--- james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java (original)
+++ james/server/trunk/mailets-function/src/test/java/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java Mon Nov 23 14:55:58 2009
@@ -36,10 +36,8 @@
import junit.framework.TestCase;
-import org.apache.james.Constants;
import org.apache.james.api.dnsservice.AbstractDNSServer;
import org.apache.james.api.dnsservice.DNSService;
-import org.apache.james.test.mock.avalon.MockServiceManager;
import org.apache.mailet.base.test.FakeMailContext;
import org.apache.mailet.base.test.FakeMatcherConfig;
import org.apache.mailet.Mail;
@@ -55,8 +53,6 @@
private DNSService dnsServer;
- private MockServiceManager m_serviceManager;
-
public AbstractRemoteAddrInNetworkTest(String arg0)
throws UnsupportedEncodingException {
super(arg0);
@@ -205,12 +201,10 @@
}
protected void setupMatcher() throws MessagingException {
- m_serviceManager = new MockServiceManager();
- m_serviceManager.put(DNSService.ROLE, dnsServer);
-
+
FakeMailContext mmc = new FakeMailContext();
- mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER, m_serviceManager);
matcher = createMatcher();
+ matcher.setDNSService(dnsServer);
FakeMatcherConfig mci = new FakeMatcherConfig(getConfigOption()
+ getAllowedNetworks(), mmc);
matcher.init(mci);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org