Index: C:/Lab/VOID/projects/james-merge/src/java/org/apache/james/transport/LinearProcessor.java =================================================================== --- C:/Lab/VOID/projects/james-merge/src/java/org/apache/james/transport/LinearProcessor.java (revision 168008) +++ C:/Lab/VOID/projects/james-merge/src/java/org/apache/james/transport/LinearProcessor.java (working copy) @@ -17,24 +17,29 @@ package org.apache.james.transport; -import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.avalon.framework.logger.Logger; import org.apache.james.core.MailImpl; import org.apache.james.core.MailetConfigImpl; -import org.apache.james.services.SpoolRepository; -import org.apache.mailet.*; +import org.apache.mailet.GenericMailet; +import org.apache.mailet.GenericMatcher; +import org.apache.mailet.Mail; +import org.apache.mailet.MailAddress; +import org.apache.mailet.Mailet; +import org.apache.mailet.MailetConfig; +import org.apache.mailet.MailetException; +import org.apache.mailet.Matcher; import javax.mail.MessagingException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; -import java.util.List; -import java.util.Random; import java.util.Iterator; +import java.util.List; import java.util.Locale; +import java.util.Random; /** * Implements a processor for mails, directing the mail down @@ -56,7 +61,7 @@ * it is implemented on the <mailet> tag. The specification is: * * <mailet match="..." class="..." - * [onMatchException="{noMatch|matchAll|error|<aProcessorName>}"] + * [onMatchException="{noMatch|matchAll|error|<aProcessorName>}"] * [onMailetException="{ignore|error|<aProcessorName>}"]> * * noMatch: no addresses are considered to match @@ -69,7 +74,7 @@ *

CVS $Id$

* @version 2.2.0 */ -public class LinearProcessor +public class LinearProcessor extends AbstractLogEnabled implements Initializable, Disposable { @@ -96,23 +101,8 @@ private List mailets; // The list of mailets for this processor private List matchers; // The list of matchers for this processor private volatile boolean listsClosed; // Whether the matcher/mailet lists have been closed. - private SpoolRepository spool; // The spool on which this processor is acting /** - * Set the spool to be used by this LinearProcessor. - * - * @param spool the spool to be used by this processor - * - * @throws IllegalArgumentException when the spool passed in is null - */ - public void setSpool(SpoolRepository spool) { - if (spool == null) { - throw new IllegalArgumentException("The spool cannot be null"); - } - this.spool = spool; - } - - /** * @see org.apache.avalon.framework.activity.Initializable#initialize() */ public void initialize() { @@ -150,7 +140,7 @@ * *

It is an essential part of the contract of the LinearProcessor * that a particular matcher/mailet combination be used to - * terminate the processor chain. This is done by calling the + * terminate the processor chain. This is done by calling the * closeProcessorList method.

* *

Once the closeProcessorList has been called any subsequent @@ -196,12 +186,12 @@ public Collection match(Mail mail) { return mail.getRecipients(); } - + public String getMatcherInfo() { return TERMINATING_MATCHER_NAME; } }; - Mailet terminatingMailet = + Mailet terminatingMailet = new GenericMailet() { public void service(Mail mail) { if (!(Mail.ERROR.equals(mail.getState()))) { @@ -217,11 +207,11 @@ } mail.setState(Mail.GHOST); } - + public String getMailetInfo() { return getMailetName(); } - + public String getMailetName() { return TERMINATING_MAILET_NAME; } @@ -238,21 +228,17 @@ * *

If the matcher/mailet lists have not been closed by a call to the closeProcessorLists * method then a call to this method will result in an IllegalStateException. - * The end of the matcher/mailet chain must be a matcher that matches all mails and - * a mailet that sets every mail to GHOST status. This is necessary to ensure that + * The end of the matcher/mailet chain must be a matcher that matches all mails and + * a mailet that sets every mail to GHOST status. This is necessary to ensure that * mails are removed from the spool in an orderly fashion. The closeProcessorLists method * ensures this.

- * + * * @param mail the new mail to be processed * * @throws IllegalStateException when this method is called before the processor lists have been closed * or the spool has been initialized */ public void service(MailImpl mail) throws MessagingException { - if (spool == null) { - throw new IllegalStateException("Attempt to service mail before the spool has been set to a non-null value"); - } - if (!listsClosed) { throw new IllegalStateException("Attempt to service mail before matcher/mailet lists have been closed"); } @@ -269,7 +255,7 @@ // It is a List of Mail objects at each array spot as multiple Mail // objects could be at the same stage. // - // Note that every Mail object in this array will either be the + // Note that every Mail object in this array will either be the // original Mail object passed in, or a result of this method's // (and hence this thread's) processing. @@ -299,8 +285,8 @@ // Please note that the presence of the terminating mailet at the end // of the chain is critical to the proper operation // of the LinearProcessor code. If this mailet is not placed - // at the end of the chain with a terminating matcher, there is a - // potential for configuration or implementation errors to + // at the end of the chain with a terminating matcher, there is a + // potential for configuration or implementation errors to // lead to mails trapped in the spool. This matcher/mailet // combination is added when the closeProcessorList method // is called. @@ -432,10 +418,8 @@ mail = null; continue; } - // This was just set to another state requiring further processing... - // Store this back in the spool and it will get picked up and - // run in that processor - spool.store(mail); + // This was just set to another state requiring further processing... + // We exit the processor mail = null; continue; } else { @@ -451,7 +435,7 @@ * Create a unique new primary key name. * * @param mail the mail to use as the basis for the new mail name - * + * * @return a new name */ private String newName(MailImpl mail) {