pgoldstein 2002/08/16 10:08:53 Modified: src/java/org/apache/james/transport JamesSpoolManager.java Log: Fix for NPE, additional comments. Thanks to Stephen McConnell, Noel Bergman Revision Changes Path 1.12 +57 -8 jakarta-james/src/java/org/apache/james/transport/JamesSpoolManager.java Index: JamesSpoolManager.java =================================================================== RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/JamesSpoolManager.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- JamesSpoolManager.java 10 Aug 2002 23:13:11 -0000 1.11 +++ JamesSpoolManager.java 16 Aug 2002 17:08:53 -0000 1.12 @@ -33,6 +33,11 @@ import java.util.Iterator; /** + * Manages the mail spool. This class is responsible for retrieving + * messages from the spool, directing messages to the appropriate + * processor, and removing them from the spool when processing is + * complete. + * * @author Serge Knystautas <[EMAIL PROTECTED]> * @author Federico Barbieri <[EMAIL PROTECTED]> * @@ -56,21 +61,51 @@ private ThreadPool workerPool; private ThreadManager threadManager; - public void configure(Configuration conf) throws ConfigurationException { - this.conf = conf; - threads = conf.getChild("threads").getValueAsInteger(1); - } - + /** + * Pass the Context to the component. + * This method is called after the setLogger() + * method and before any other method. + * + * @param context the context + * @throws ContextException if context is invalid + */ public void contextualize(Context context) { this.context = new DefaultContext( context ); } + /** + * Pass the <code>ComponentManager</code> to the <code>composer</code>. + * The instance uses the specified <code>ComponentManager</code> to + * acquire the components it needs for execution. + * + * @param componentManager The <code>ComponentManager</code> which this + * <code>Composable</code> uses. + * @throws ComponentException if an error occurs + */ public void compose(ComponentManager comp) throws ComponentException { threadManager = (ThreadManager)comp.lookup( ThreadManager.ROLE ); compMgr = new DefaultComponentManager(comp); } + /** + * Pass the <code>Configuration</code> to the instance. + * + * @param configuration the class configurations. + * @throws ConfigurationException if an error occurs + */ + public void configure(Configuration conf) throws ConfigurationException { + this.conf = conf; + threads = conf.getChild("threads").getValueAsInteger(1); + } + + /** + * Initialize the component. Initialization includes + * allocating any resources required throughout the + * components lifecycle. + * + * @throws Exception if an error occurs + */ public void initialize() throws Exception { getLogger().info("JamesSpoolManager init..."); @@ -266,6 +301,9 @@ try { String key = spool.accept(); MailImpl mail = spool.retrieve(key); + if (mail == null) { + continue; + } if (infoEnabled) { StringBuffer infoBuffer = new StringBuffer(64) @@ -310,6 +348,8 @@ /** * Process this mail message by the appropriate processor as designated * in the state of the Mail object. + * + * @param mail the mail message to be processed */ protected void process(MailImpl mail) { while (true) { @@ -369,7 +409,16 @@ } } - // Shutdown processors + /** + * The dispose operation is called at the end of a components lifecycle. + * Instances of this class use this method to release and destroy any + * resources that they own. + * + * This implementation shuts down the LinearProcessors managed by this + * JamesSpoolManager + * + * @throws Exception if an error is encountered during shutdown + */ public void dispose() { getLogger().info("JamesSpoolManager dispose..."); Iterator it = processors.keySet().iterator();
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>