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 2010/09/20 21:00:30 UTC

svn commit: r999056 - in /james/server/trunk: core-api/src/main/java/org/apache/james/services/ management/src/main/java/org/apache/james/management/impl/ spoolmanager/src/main/java/org/apache/james/transport/ spoolmanager/src/main/java/org/apache/jame...

Author: norman
Date: Mon Sep 20 19:00:30 2010
New Revision: 999056

URL: http://svn.apache.org/viewvc?rev=999056&view=rev
Log:
Change MailetContainer to be able to return Mailet/Matcher instances 

Modified:
    james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
    james/server/trunk/management/src/main/java/org/apache/james/management/impl/ProcessorManagement.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MailetContainer.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/CamelMailProcessorList.java

Modified: james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java?rev=999056&r1=999055&r2=999056&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java Mon Sep 20 19:00:30 2010
@@ -20,8 +20,8 @@ package org.apache.james.services;
 
 import java.util.List;
 
-import org.apache.mailet.MailetConfig;
-import org.apache.mailet.MatcherConfig;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.Matcher;
 
 /**
  * provide all the data needed to manage spool processors, mailets and matchers
@@ -39,12 +39,12 @@ public interface SpoolManager {
      * @param processorName - name of the processor who's mailets should be retrieved
      * @return List<MailetConfig>
      */
-    List<MailetConfig> getMailetConfigs(String processorName);
+    List<Mailet> getMailets(String processorName);
     
     /**
      * retrieve all matchers for given processor
      * @param processorName - name of the processor who's matchers should be retrieved
      * @return List<MatcherConfig>
      */
-    List<MatcherConfig> getMatcherConfigs(String processorName);
+    List<Matcher> getMatchers(String processorName);
 }

Modified: james/server/trunk/management/src/main/java/org/apache/james/management/impl/ProcessorManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management/src/main/java/org/apache/james/management/impl/ProcessorManagement.java?rev=999056&r1=999055&r2=999056&view=diff
==============================================================================
--- james/server/trunk/management/src/main/java/org/apache/james/management/impl/ProcessorManagement.java (original)
+++ james/server/trunk/management/src/main/java/org/apache/james/management/impl/ProcessorManagement.java Mon Sep 20 19:00:30 2010
@@ -24,7 +24,9 @@ import org.apache.james.management.Proce
 import org.apache.james.management.mbean.MatcherManagement;
 import org.apache.james.management.mbean.ProcessorDetail;
 import org.apache.james.management.mbean.MailetManagement;
+import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
+import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;
 
 import javax.annotation.PostConstruct;
@@ -73,9 +75,9 @@ public class ProcessorManagement impleme
         registerMBean(mBeanServer, processorMBeanName, processorMBean);
 
         // add all mailets but the last, because that is a terminator (see LinearProcessor.closeProcessorLists())
-        List<MailetConfig> mailetConfigs = processorManager.getMailetConfigs(processorName);
-        for (int i = 0; i < mailetConfigs.size()-1; i++) {
-            MailetConfig mailetConfig = mailetConfigs.get(i);
+        List<Mailet> mailets = processorManager.getMailets(processorName);
+        for (int i = 0; i < mailets.size()-1; i++) {
+            MailetConfig mailetConfig = mailets.get(i).getMailetConfig();
 
             String mailetMBeanName = processorMBeanName + ",subtype=mailet,index=" + (i+1) + ",mailetname=" + mailetConfig.getMailetName();
             MailetManagement mailetMBean = new MailetManagement(mailetConfig);
@@ -83,9 +85,9 @@ public class ProcessorManagement impleme
         }
 
         // add all matchers but the last, because that is a terminator (see LinearProcessor.closeProcessorLists())
-        List<MatcherConfig> matcherConfigs = processorManager.getMatcherConfigs(processorName);
-        for (int i = 0; i < matcherConfigs.size()-1; i++) {
-            MatcherConfig matcherConfig = matcherConfigs.get(i);
+        List<Matcher> matchers = processorManager.getMatchers(processorName);
+        for (int i = 0; i < matchers.size()-1; i++) {
+            MatcherConfig matcherConfig = matchers.get(i).getMatcherConfig();
 
             String matcherMBeanName = processorMBeanName + ",subtype=matcher,index=" + (i+1) + ",matchername=" + matcherConfig.getMatcherName();
             MatcherManagement matcherMBean = new MatcherManagement(matcherConfig);
@@ -124,13 +126,13 @@ public class ProcessorManagement impleme
      * @see org.apache.james.management.ProcessorManagementService#getMailetNames(java.lang.String)
      */
     public String[] getMailetNames(String processorName) {
-        List<MailetConfig> mailetConfigs = processorManager.getMailetConfigs(processorName);
+        List<Mailet> mailets = processorManager.getMailets(processorName);
         // always ommit the terminating mailet
-        String[] mailetNames = new String[mailetConfigs.size()-1];
+        String[] mailetNames = new String[mailets.size()-1];
         int i = 0;
-        Iterator<MailetConfig> iterator = mailetConfigs.iterator();
+        Iterator<Mailet> iterator = mailets.iterator();
         while (iterator.hasNext()) {
-            MailetConfig mailetConfig = iterator.next();
+            MailetConfig mailetConfig = iterator.next().getMailetConfig();
             if (!iterator.hasNext()) continue; // ommit the terminating mailet
             String mailetName = mailetConfig.getMailetName();
             mailetNames[i] = mailetName;
@@ -143,13 +145,13 @@ public class ProcessorManagement impleme
      * @see org.apache.james.management.ProcessorManagementService#getMatcherNames(java.lang.String)
      */
     public String[] getMatcherNames(String processorName) {
-        List<MatcherConfig> matcherConfigs = processorManager.getMatcherConfigs(processorName);
+        List<Matcher> matchers = processorManager.getMatchers(processorName);
         // always ommit the terminating mailet
-        String[] matcherNames = new String[matcherConfigs.size()-1];
+        String[] matcherNames = new String[matchers.size()-1];
         int i = 0;
-        Iterator<MatcherConfig> iterator = matcherConfigs.iterator();
+        Iterator<Matcher> iterator = matchers.iterator();
         while (iterator.hasNext()) {
-            MatcherConfig matcherConfig = iterator.next();
+            MatcherConfig matcherConfig = iterator.next().getMatcherConfig();
             if (!iterator.hasNext()) continue; // ommit the terminating mailet
             String matcherName = matcherConfig.getMatcherName();
             matcherNames[i] = matcherName;
@@ -162,9 +164,9 @@ public class ProcessorManagement impleme
      * @see org.apache.james.management.ProcessorManagementService#getMatcherParameters(java.lang.String, int)
      */
     public String[] getMatcherParameters(String processorName, int matcherIndex) {
-        List<MatcherConfig> matcherConfigs = processorManager.getMatcherConfigs(processorName);
-        if (matcherConfigs == null || matcherConfigs.size() < matcherIndex) return null;
-        MatcherConfig matcherConfig = matcherConfigs.get(matcherIndex);
+        List<Matcher> matchers = processorManager.getMatchers(processorName);
+        if (matchers == null || matchers.size() < matcherIndex) return null;
+        MatcherConfig matcherConfig = matchers.get(matcherIndex).getMatcherConfig();
         return new String[] {matcherConfig.getCondition()};
     }
 
@@ -172,9 +174,9 @@ public class ProcessorManagement impleme
      * @see org.apache.james.management.ProcessorManagementService#getMailetParameters(java.lang.String, int)
      */
     public String[] getMailetParameters(String processorName, int mailetIndex) {
-        List<MailetConfig> mailetConfigs = processorManager.getMailetConfigs(processorName);
-        if (mailetConfigs == null || mailetConfigs.size() < mailetIndex) return null;
-        MailetConfig mailetConfig = mailetConfigs.get(mailetIndex);
+        List<Mailet> mailets = processorManager.getMailets(processorName);
+        if (mailets == null || mailets.size() < mailetIndex) return null;
+        MailetConfig mailetConfig = mailets.get(mailetIndex).getMailetConfig();
         return MailetManagement.getMailetParameters(mailetConfig);
     }
 

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java?rev=999056&r1=999055&r2=999056&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java Mon Sep 20 19:00:30 2010
@@ -1,266 +1,268 @@
-/****************************************************************
- * 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.transport;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-import javax.mail.MessagingException;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.james.lifecycle.Configurable;
-import org.apache.james.lifecycle.LifecycleUtil;
-import org.apache.james.lifecycle.LogEnabled;
-import org.apache.james.queue.MailQueue;
-import org.apache.james.queue.MailQueueFactory;
-import org.apache.james.queue.MailQueue.DequeueOperation;
-import org.apache.james.queue.MailQueue.MailQueueException;
-import org.apache.james.services.SpoolManager;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailetConfig;
-import org.apache.mailet.MatcherConfig;
-
-/**
- * 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.
- *
- * @version CVS $Revision$ $Date$
- * 
- * TODO: We should better use a ExecutorService here and only spawn a new Thread if needed
- */
-public class JamesSpoolManager implements Runnable, SpoolManager, Configurable, LogEnabled {
-
-    
-    private MailQueue queue;
-
-    /**
-     * The number of threads used to move mail through the spool.
-     */
-    private int numThreads;
-
-  
-    /**
-     * Number of active threads
-     */
-    private int numActive;
-
-    /**
-     * Spool threads are active
-     */
-    private boolean active;
-
-    /**
-     * Spool threads
-     */
-    private Collection<Thread> spoolThreads;
-
-    /**
-     * The mail processor 
-     */
-    private MailProcessorList mailProcessor;
-
-    private Log logger;
-
-    private MailQueueFactory queueFactory;
-
-
-    @Resource(name="mailQueueFactory")
-    public void setMailQueueFactory(MailQueueFactory queueFactory) {
-        this.queueFactory = queueFactory;
-    }
-
-    @Resource(name="mailProcessor")
-    public void setMailProcessorList(MailProcessorList mailProcessor) {
-        this.mailProcessor = mailProcessor;
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
-     */
-    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
-        numThreads = config.getInt("threads",100);
-    }
-
-    /**
-     * Initialises the spool manager.
-     */
-    @PostConstruct
-    public void init() throws Exception {
-        logger.info("JamesSpoolManager init...");
-        
-        queue = queueFactory.getQueue(MailQueueFactory.SPOOL);
-
-        if (logger.isInfoEnabled()) {
-            StringBuffer infoBuffer =
-                new StringBuffer(64)
-                    .append("Spooler Manager uses ")
-                    .append(numThreads)
-                    .append(" Thread(s)");
-            logger.info(infoBuffer.toString());
-        }
-
-        active = true;
-        numActive = 0;
-        spoolThreads = new java.util.ArrayList<Thread>(numThreads);
-        for ( int i = 0 ; i < numThreads ; i++ ) {
-            Thread reader = new Thread(this, "Spool Thread #" + i);
-            spoolThreads.add(reader);
-            reader.start();
-        }
-    }
-
-    /**
-     * This routinely checks the message spool for messages, and processes
-     * them as necessary
-     */
-    public void run() {
-
-        if (logger.isInfoEnabled()) {
-            logger.info("Run JamesSpoolManager: "
-                             + Thread.currentThread().getName());
-            logger.info("Spool=" + queue.getClass().getName());
-        }
-
-        numActive++;
-        while(active) {
-            try {
-                queue.deQueue(new DequeueOperation() {
-                    
-                    /*
-                     * (non-Javadoc)
-                     * @see org.apache.james.queue.activemq.MailQueue.DequeueOperation#process(org.apache.mailet.Mail)
-                     */
-                    public void process(Mail mail) throws MailQueueException, MessagingException {
-                        if (logger.isDebugEnabled()) {
-                            StringBuffer debugBuffer =
-                                new StringBuffer(64)
-                                        .append("==== Begin processing mail ")
-                                        .append(mail.getName())
-                                        .append("====");
-                            logger.debug(debugBuffer.toString());
-                        }
-
-                        mailProcessor.service(mail);
-
-                        if ((Mail.GHOST.equals(mail.getState())) ||
-                            (mail.getRecipients() == null) ||
-                            (mail.getRecipients().size() == 0)) {
-                            LifecycleUtil.dispose(mail);
-                            mail = null;
-                        }                        
-                    }
-                });
-                
-               
-            } catch (Throwable e) {
-                if (logger.isErrorEnabled()) {
-                    logger.error("Exception processing mail in JamesSpoolManager.run "
-                                      + e.getMessage(), e);
-                }
-            }
-        }
-        if (logger.isInfoEnabled()){
-            logger.info("Stop JamesSpoolManager: " + Thread.currentThread().getName());
-        }
-        numActive--;
-    }
-
-    /**
-     * 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
-     * 
-     * @see org.apache.avalon.framework.activity.Disposable#dispose()
-     */
-    @PreDestroy
-    public void dispose() {
-        logger.info("JamesSpoolManager dispose...");
-        active = false; // shutdown the threads
-        for (Thread thread: spoolThreads) {
-            thread.interrupt(); // interrupt any waiting accept() calls.
-        }
-
-        long stop = System.currentTimeMillis() + 60000;
-        // give the spooler threads one minute to terminate gracefully
-        while (numActive != 0 && stop > System.currentTimeMillis()) {
-            try {
-                Thread.sleep(1000);
-            } catch (Exception ignored) {}
-        }
-        logger.info("JamesSpoolManager thread shutdown completed.");
-    }
-
-    /**
-     * @see org.apache.james.services.SpoolManager#getProcessorNames()
-     */
-    public String[] getProcessorNames() {
-        return mailProcessor.getProcessorNames();
-    }
-
-    /**
-     * @see org.apache.james.services.SpoolManager#getMailetConfigs(java.lang.String)
-     */
-    public List<MailetConfig> getMailetConfigs(String processorName) {
-        MailetContainer mailetContainer = getMailetContainerByName(processorName);
-        if (mailetContainer == null) return new ArrayList<MailetConfig>();
-        return mailetContainer.getMailetConfigs();
-    }
-
-    /**
-     * @see org.apache.james.services.SpoolManager#getMatcherConfigs(java.lang.String)
-     */
-    public List<MatcherConfig> getMatcherConfigs(String processorName) {
-        MailetContainer mailetContainer = getMailetContainerByName(processorName);
-        if (mailetContainer == null) return new ArrayList<MatcherConfig>();
-        return mailetContainer.getMatcherConfigs();
-    }
-
-    private MailetContainer getMailetContainerByName(String processorName) {        
-        MailProcessor processor = mailProcessor.getProcessor(processorName);
-        if (!(processor instanceof MailetContainer)) return null;
-        // TODO: decide, if we have to visit all sub-processors for being ProcessorLists 
-        // on their very own and collecting the processor names deeply.
-        return (MailetContainer)processor;
-    }
-
-
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.lifecycle.LogEnabled#setLog(org.apache.commons.logging.Log)
-     */
-    public void setLog(Log log) {
-        this.logger = log;
-    }
-}
+/****************************************************************
+ * 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.transport;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.mail.MessagingException;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.lifecycle.Configurable;
+import org.apache.james.lifecycle.LifecycleUtil;
+import org.apache.james.lifecycle.LogEnabled;
+import org.apache.james.queue.MailQueue;
+import org.apache.james.queue.MailQueueFactory;
+import org.apache.james.queue.MailQueue.DequeueOperation;
+import org.apache.james.queue.MailQueue.MailQueueException;
+import org.apache.james.services.SpoolManager;
+import org.apache.mailet.Mail;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.Matcher;
+
+/**
+ * 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.
+ *
+ * @version CVS $Revision$ $Date$
+ * 
+ * TODO: We should better use a ExecutorService here and only spawn a new Thread if needed
+ */
+public class JamesSpoolManager implements Runnable, SpoolManager, Configurable, LogEnabled {
+
+    
+    private MailQueue queue;
+
+    /**
+     * The number of threads used to move mail through the spool.
+     */
+    private int numThreads;
+
+  
+    /**
+     * Number of active threads
+     */
+    private int numActive;
+
+    /**
+     * Spool threads are active
+     */
+    private boolean active;
+
+    /**
+     * Spool threads
+     */
+    private Collection<Thread> spoolThreads;
+
+    /**
+     * The mail processor 
+     */
+    private MailProcessorList mailProcessor;
+
+    private Log logger;
+
+    private MailQueueFactory queueFactory;
+
+
+    @Resource(name="mailQueueFactory")
+    public void setMailQueueFactory(MailQueueFactory queueFactory) {
+        this.queueFactory = queueFactory;
+    }
+
+    @Resource(name="mailProcessor")
+    public void setMailProcessorList(MailProcessorList mailProcessor) {
+        this.mailProcessor = mailProcessor;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
+     */
+    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+        numThreads = config.getInt("threads",100);
+    }
+
+    /**
+     * Initialises the spool manager.
+     */
+    @PostConstruct
+    public void init() throws Exception {
+        logger.info("JamesSpoolManager init...");
+        
+        queue = queueFactory.getQueue(MailQueueFactory.SPOOL);
+
+        if (logger.isInfoEnabled()) {
+            StringBuffer infoBuffer =
+                new StringBuffer(64)
+                    .append("Spooler Manager uses ")
+                    .append(numThreads)
+                    .append(" Thread(s)");
+            logger.info(infoBuffer.toString());
+        }
+
+        active = true;
+        numActive = 0;
+        spoolThreads = new java.util.ArrayList<Thread>(numThreads);
+        for ( int i = 0 ; i < numThreads ; i++ ) {
+            Thread reader = new Thread(this, "Spool Thread #" + i);
+            spoolThreads.add(reader);
+            reader.start();
+        }
+    }
+
+    /**
+     * This routinely checks the message spool for messages, and processes
+     * them as necessary
+     */
+    public void run() {
+
+        if (logger.isInfoEnabled()) {
+            logger.info("Run JamesSpoolManager: "
+                             + Thread.currentThread().getName());
+            logger.info("Spool=" + queue.getClass().getName());
+        }
+
+        numActive++;
+        while(active) {
+            try {
+                queue.deQueue(new DequeueOperation() {
+                    
+                    /*
+                     * (non-Javadoc)
+                     * @see org.apache.james.queue.activemq.MailQueue.DequeueOperation#process(org.apache.mailet.Mail)
+                     */
+                    public void process(Mail mail) throws MailQueueException, MessagingException {
+                        if (logger.isDebugEnabled()) {
+                            StringBuffer debugBuffer =
+                                new StringBuffer(64)
+                                        .append("==== Begin processing mail ")
+                                        .append(mail.getName())
+                                        .append("====");
+                            logger.debug(debugBuffer.toString());
+                        }
+
+                        mailProcessor.service(mail);
+
+                        if ((Mail.GHOST.equals(mail.getState())) ||
+                            (mail.getRecipients() == null) ||
+                            (mail.getRecipients().size() == 0)) {
+                            LifecycleUtil.dispose(mail);
+                            mail = null;
+                        }                        
+                    }
+                });
+                
+               
+            } catch (Throwable e) {
+                if (logger.isErrorEnabled()) {
+                    logger.error("Exception processing mail in JamesSpoolManager.run "
+                                      + e.getMessage(), e);
+                }
+            }
+        }
+        if (logger.isInfoEnabled()){
+            logger.info("Stop JamesSpoolManager: " + Thread.currentThread().getName());
+        }
+        numActive--;
+    }
+
+    /**
+     * 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
+     * 
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    @PreDestroy
+    public void dispose() {
+        logger.info("JamesSpoolManager dispose...");
+        active = false; // shutdown the threads
+        for (Thread thread: spoolThreads) {
+            thread.interrupt(); // interrupt any waiting accept() calls.
+        }
+
+        long stop = System.currentTimeMillis() + 60000;
+        // give the spooler threads one minute to terminate gracefully
+        while (numActive != 0 && stop > System.currentTimeMillis()) {
+            try {
+                Thread.sleep(1000);
+            } catch (Exception ignored) {}
+        }
+        logger.info("JamesSpoolManager thread shutdown completed.");
+    }
+
+    /**
+     * @see org.apache.james.services.SpoolManager#getProcessorNames()
+     */
+    public String[] getProcessorNames() {
+        return mailProcessor.getProcessorNames();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.services.SpoolManager#getMailets(java.lang.String)
+     */
+    public List<Mailet> getMailets(String processorName) {
+        MailetContainer mailetContainer = getMailetContainerByName(processorName);
+        if (mailetContainer == null) return new ArrayList<Mailet>();
+        return mailetContainer.getMailets();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.services.SpoolManager#getMatchers(java.lang.String)
+     */
+    public List<Matcher> getMatchers(String processorName) {
+        MailetContainer mailetContainer = getMailetContainerByName(processorName);
+        if (mailetContainer == null) return new ArrayList<Matcher>();
+        return mailetContainer.getMatchers();
+    }
+
+    private MailetContainer getMailetContainerByName(String processorName) {        
+        MailProcessor processor = mailProcessor.getProcessor(processorName);
+        if (!(processor instanceof MailetContainer)) return null;
+        // TODO: decide, if we have to visit all sub-processors for being ProcessorLists 
+        // on their very own and collecting the processor names deeply.
+        return (MailetContainer)processor;
+    }
+
+
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.lifecycle.LogEnabled#setLog(org.apache.commons.logging.Log)
+     */
+    public void setLog(Log log) {
+        this.logger = log;
+    }
+}

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MailetContainer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MailetContainer.java?rev=999056&r1=999055&r2=999056&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MailetContainer.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MailetContainer.java Mon Sep 20 19:00:30 2010
@@ -1,44 +1,45 @@
-/****************************************************************
- * 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.transport;
-
-import java.util.List;
-
-import org.apache.mailet.MailetConfig;
-import org.apache.mailet.MatcherConfig;
-
-
-/**
- * interface for mailet/matcher-containing processors.
- */
-public interface MailetContainer {
-    /**
-     * retrieve mailet configuration data for introspection
-     * @return List<MailetConfig>
-     */
-    List<MailetConfig> getMailetConfigs();
-
-    /**
-     * retrieve matcher configuration data for introspection
-     * @return List<MatcherConfig>
-     */
-    List<MatcherConfig> getMatcherConfigs();
-
-}
-
+/****************************************************************
+ * 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.transport;
+
+import java.util.List;
+
+import org.apache.mailet.Mailet;
+import org.apache.mailet.Matcher;
+
+
+/**
+ * interface for mailet/matcher-containing processors.
+ */
+public interface MailetContainer {
+
+    /**
+     * retrieve mailet configuration data for introspection
+     * @return List<MailetConfig>
+     */
+    List<Mailet> getMailets();
+
+    /**
+     * retrieve matcher configuration data for introspection
+     * @return List<MatcherConfig>
+     */
+    List<Matcher> getMatchers();
+
+}
+

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/CamelMailProcessorList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/CamelMailProcessorList.java?rev=999056&r1=999055&r2=999056&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/CamelMailProcessorList.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/CamelMailProcessorList.java Mon Sep 20 19:00:30 2010
@@ -45,14 +45,12 @@ import org.apache.james.transport.MailPr
 import org.apache.james.transport.MailetConfigImpl;
 import org.apache.james.transport.MailetContainer;
 import org.apache.james.transport.MailetLoader;
-import org.apache.james.transport.MatcherConfigImpl;
 import org.apache.james.transport.MatcherLoader;
 import org.apache.james.transport.MailProcessorList;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
 import org.apache.mailet.Matcher;
-import org.apache.mailet.MatcherConfig;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.MatcherInverter;
 
@@ -407,37 +405,21 @@ public class CamelMailProcessorList exte
             // TODO: Allow to only run a part of the route
             
         }
-
+        
         /*
          * (non-Javadoc)
-         * @see org.apache.james.transport.MailetContainer#getMailetConfigs()
+         * @see org.apache.james.transport.MailetContainer#getMailets()
          */
-        public List<MailetConfig> getMailetConfigs() {
-            List<MailetConfig> mailetConfigs = new ArrayList<MailetConfig>();
-            Iterator<Mailet> iterator = mailets.get(processorName).iterator();
-            while (iterator.hasNext()) {
-                Mailet mailet = (Mailet) iterator.next();
-                MailetConfig mailetConfig = mailet.getMailetConfig();
-                if (mailetConfig == null) mailetConfigs.add(new MailetConfigImpl()); // placeholder
-                else mailetConfigs.add(mailetConfig);
-            }
-            return mailetConfigs; 
+        public List<Mailet> getMailets() {
+            return mailets.get(processorName);
         }
 
         /*
          * (non-Javadoc)
-         * @see org.apache.james.transport.MailetContainer#getMatcherConfigs()
+         * @see org.apache.james.transport.MailetContainer#getMatchers()
          */
-        public List<MatcherConfig> getMatcherConfigs() {
-            List<MatcherConfig> matcherConfigs = new ArrayList<MatcherConfig>();
-            Iterator<Matcher> iterator = matchers.get(processorName).iterator();
-            while (iterator.hasNext()) {
-                Matcher matcher = (Matcher) iterator.next();
-                MatcherConfig matcherConfig = matcher.getMatcherConfig();
-                if (matcherConfig == null) matcherConfigs.add(new MatcherConfigImpl()); // placeholder
-                else matcherConfigs.add(matcherConfig);
-            }      
-            return matcherConfigs;
+        public List<Matcher> getMatchers() {
+            return matchers.get(processorName);       
         }
         
     }



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