james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1049554 - in /james/server/trunk: container-spring/src/main/config/james/context/ core-api/src/main/java/org/apache/james/services/ core-function/src/main/java/org/apache/james/transport/ mailetcontainer-api/src/main/java/org/apache/james/...
Date Wed, 15 Dec 2010 13:54:00 GMT
Author: norman
Date: Wed Dec 15 13:53:59 2010
New Revision: 1049554

URL: http://svn.apache.org/viewvc?rev=1049554&view=rev
Log:
Rename SpoolManager to MailSpooler and move the interface from core-api to mailetcontainer-api.
The implementation was moved from core-function to mailetcontainer-library. See JAMES-1148

Added:
    james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpooler.java
      - copied, changed from r1033370, james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
    james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpoolerMBean.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailSpooler.java
      - copied, changed from r1033370, james/server/trunk/core-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java
Removed:
    james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
    james/server/trunk/core-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java
Modified:
    james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
    james/server/trunk/mailetcontainer-library/pom.xml

Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1049554&r1=1049553&r2=1049554&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
(original)
+++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
Wed Dec 15 13:53:59 2010
@@ -57,7 +57,7 @@
                 <entry key="pop3ProtocolHandlerChain" value="pop3server"/>
                 <entry key="remoteProtocolHandlerChain" value="remotemanager"/>
                 <entry key="mailProcessor" value="mailetcontainer"/>
-                <entry key="spoolmanager" value="mailetcontainer"/>
+                <entry key="mailspooler" value="mailetcontainer"/>
                 <entry key="mailetloader" value="mailetcontainer"/>
                 <entry key="matcherloader" value="mailetcontainer"/>
                 <entry key="mailetcontext" value="mailetcontainer"/>
@@ -81,7 +81,7 @@
                 <entry key="pop3ProtocolHandlerChain" value="pop3server"/>
                 <entry key="remoteProtocolHandlerChain" value="remoteManager"/>
                 <entry key="mailProcessor" value="mailetcontainer"/>
-                <entry key="spoolmanager" value="mailetcontainer"/>
+                <entry key="mailspooler" value="mailetcontainer"/>
                 <entry key="mailetloader" value="mailetcontainer"/>
                 <entry key="matcherloader" value="mailetcontainer"/>
                 <entry key="usersstore" value="usersrepository"/>
@@ -152,7 +152,7 @@
      -->
     <bean id="mailQueueFactory" class="org.apache.james.queue.activemq.ActiveMQMailQueueFactory"
depends-on="broker"/>
     <bean id="mailProcessor" name="processorRoute" class="org.apache.james.mailetcontainer.camel.CamelMailProcessorList"/>
-    <bean id="spoolmanager" class="org.apache.james.transport.JamesSpoolManager"/>
+    <bean id="mailspooler" class="org.apache.james.mailetcontainer.lib.JamesMailSpooler"/>
     <bean id="mailetcontext" class="org.apache.james.mailetcontainer.lib.JamesMailetContext"/>
     <bean id="mailetloader" class="org.apache.james.mailetcontainer.lib.JamesMailetLoader"
/>
     <bean id="matcherloader" class="org.apache.james.mailetcontainer.lib.JamesMatcherLoader"
/>
@@ -332,12 +332,13 @@
           <entry key="org.apache.james:type=component,name=usermanagement" value-ref="usermanagement"/>
           <entry key="org.apache.james:type=component,name=fetchmail" value-ref="fetchmail"/>
           <entry key="org.apache.james:type=component,name=mailboxmanagement" value-ref="mailboxmanagermanagement"/>
+          <entry key="org.apache.james:type=component,name=mailspooler" value-ref="mailspooler"/>
           <entry key="org.apache.james:type=mailbox,name=mailboxcopier" value-ref="mailboxcopiermanagement"/>
         </map>
       </property>
       <property name="assembler">
           <bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
-            <property name="managedInterfaces" value="org.apache.james.smtpserver.netty.SMTPServerMBean,org.apache.james.remotemanager.netty.RemoteManagerMBean,org.apache.james.pop3server.netty.POP3ServerMBean,org.apache.james.imapserver.netty.IMAPServerMBean,org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.mailetcontainer.api.ProcessorManagementMBean,org.apache.james.vut.api.VirtualUserTableManagementMBean,org.apache.james.user.api.UserManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.mailbox.copier.MailboxCopierManagementMBean"/>
+            <property name="managedInterfaces" value="org.apache.james.smtpserver.netty.SMTPServerMBean,org.apache.james.remotemanager.netty.RemoteManagerMBean,org.apache.james.pop3server.netty.POP3ServerMBean,org.apache.james.imapserver.netty.IMAPServerMBean,org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.mailetcontainer.api.ProcessorManagementMBean,org.apache.james.vut.api.VirtualUserTableManagementMBean,org.apache.james.user.api.UserManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.mailbox.copier.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.MailSpoolerMBean"/>
           </bean>
       </property>
     </bean>

Copied: james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpooler.java
(from r1033370, james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpooler.java?p2=james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpooler.java&p1=james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java&r1=1033370&r2=1049554&rev=1049554&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
(original)
+++ james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpooler.java
Wed Dec 15 13:53:59 2010
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.services;
+package org.apache.james.mailetcontainer.api;
 
 import java.util.List;
 
@@ -26,7 +26,7 @@ import org.apache.mailet.Matcher;
 /**
  * provide all the data needed to manage spool processors, mailets and matchers
  */
-public interface SpoolManager {
+public interface MailSpooler {
 
     /**
      * @return names of all configured processors

Added: james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpoolerMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpoolerMBean.java?rev=1049554&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpoolerMBean.java
(added)
+++ james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailSpoolerMBean.java
Wed Dec 15 13:53:59 2010
@@ -0,0 +1,49 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailetcontainer.api;
+
+/**
+ * JMX MBean for MailSpooler 
+ * 
+ *
+ */
+public interface MailSpoolerMBean {
+
+    /**
+     * Return the number of threads used for spooling
+     * 
+     * @return threadCount
+     */
+    public int getThreadCount();
+    
+    /**
+     * 
+     * @return
+     */
+    public int getCurrentSpoolCount();
+    
+
+    /**
+     * Return all processor names
+     * 
+     * @return pNames
+     */
+    public String[] getProcessorNames();
+
+}

Modified: james/server/trunk/mailetcontainer-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/pom.xml?rev=1049554&r1=1049553&r2=1049554&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/pom.xml (original)
+++ james/server/trunk/mailetcontainer-library/pom.xml Wed Dec 15 13:53:59 2010
@@ -38,6 +38,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-queue-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-mailetcontainer-api</artifactId>
     </dependency>
      <dependency>

Copied: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailSpooler.java
(from r1033370, james/server/trunk/core-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailSpooler.java?p2=james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailSpooler.java&p1=james/server/trunk/core-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java&r1=1033370&r2=1049554&rev=1049554&view=diff
==============================================================================
--- james/server/trunk/core-function/src/main/java/org/apache/james/transport/JamesSpoolManager.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailSpooler.java
Wed Dec 15 13:53:59 2010
@@ -19,7 +19,7 @@
 
 
 
-package org.apache.james.transport;
+package org.apache.james.mailetcontainer.lib;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -39,11 +39,12 @@ import org.apache.james.lifecycle.Lifecy
 import org.apache.james.lifecycle.LogEnabled;
 import org.apache.james.mailetcontainer.api.MailProcessor;
 import org.apache.james.mailetcontainer.api.MailProcessorList;
+import org.apache.james.mailetcontainer.api.MailSpooler;
+import org.apache.james.mailetcontainer.api.MailSpoolerMBean;
 import org.apache.james.mailetcontainer.api.MailetContainer;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.james.queue.api.MailQueue.MailQueueItem;
-import org.apache.james.services.SpoolManager;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.Matcher;
@@ -58,7 +59,7 @@ import org.apache.mailet.Matcher;
  * 
  * TODO: We should better use a ExecutorService here and only spawn a new Thread if needed
  */
-public class JamesSpoolManager implements Runnable, SpoolManager, Configurable, LogEnabled
{
+public class JamesMailSpooler implements Runnable, MailSpooler, Configurable, LogEnabled,
MailSpoolerMBean {
 
     
     private MailQueue queue;
@@ -74,6 +75,9 @@ public class JamesSpoolManager implement
      */
     private AtomicInteger numActive = new AtomicInteger(0);;
 
+    private AtomicInteger processingActive = new AtomicInteger(0);;
+
+    
     /**
      * Spool threads are active
      */
@@ -117,14 +121,15 @@ public class JamesSpoolManager implement
      */
     @PostConstruct
     public void init() throws Exception {
-        logger.info("JamesSpoolManager init...");
+        logger.info(getClass().getName() + " init...");
         
         queue = queueFactory.getQueue(MailQueueFactory.SPOOL);
 
         if (logger.isInfoEnabled()) {
             StringBuffer infoBuffer =
                 new StringBuffer(64)
-                    .append("Spooler Manager uses ")
+                    .append(getClass().getName())
+                    .append(" uses ")
                     .append(numThreads)
                     .append(" Thread(s)");
             logger.info(infoBuffer.toString());
@@ -146,9 +151,9 @@ public class JamesSpoolManager implement
     public void run() {
 
         if (logger.isInfoEnabled()) {
-            logger.info("Run JamesSpoolManager: "
+            logger.info("Run " + getClass().getName() +": "
                              + Thread.currentThread().getName());
-            logger.info("Spool=" + queue.getClass().getName());
+            logger.info("Queue=" + queue.toString());
         }
 
         while(active.get()) {
@@ -156,6 +161,10 @@ public class JamesSpoolManager implement
 
             try {
                 MailQueueItem queueItem = queue.deQueue();
+                
+                // increase count
+                processingActive.incrementAndGet();
+                
                 Mail mail = queueItem.getMail();
                 if (logger.isDebugEnabled()) {
                     StringBuffer debugBuffer =
@@ -171,7 +180,7 @@ public class JamesSpoolManager implement
                     queueItem.done(true);
                 } catch (Exception e) {
                     if (active.get() && logger.isErrorEnabled()) {
-                        logger.error("Exception processing mail in JamesSpoolManager.run
" + e.getMessage(), e);
+                        logger.error("Exception processing mail while spooling " + e.getMessage(),
e);
                     }
                     queueItem.done(false);
 
@@ -182,16 +191,17 @@ public class JamesSpoolManager implement
                
             } catch (Throwable e) {
                 if (active.get() && logger.isErrorEnabled()) {
-                    logger.error("Exception processing mail in JamesSpoolManager.run "
-                                      + e.getMessage(), e);
+                    logger.error("Exception processing mail while spooling " + e.getMessage(),
e);
+
                 }
             } finally {
+                processingActive.decrementAndGet();
                 numActive.decrementAndGet();
             }
 
         }
         if (logger.isInfoEnabled()){
-            logger.info("Stop JamesSpoolManager: " + Thread.currentThread().getName());
+            logger.info("Stop " +  getClass().getName() +": " + Thread.currentThread().getName());
         }
     }
 
@@ -207,7 +217,7 @@ public class JamesSpoolManager implement
      */
     @PreDestroy
     public void dispose() {
-        logger.info("JamesSpoolManager dispose...");
+        logger.info(getClass().getName() +" dispose...");
         active.set(false); // shutdown the threads
         for (Thread thread: spoolThreads) {
             thread.interrupt(); // interrupt any waiting accept() calls.
@@ -221,11 +231,12 @@ public class JamesSpoolManager implement
             } catch (Exception ignored) {}
         }
         
-        logger.info("JamesSpoolManager thread shutdown completed.");
+        logger.info(getClass().getName() +" thread shutdown completed.");
     }
 
-    /**
-     * @see org.apache.james.services.SpoolManager#getProcessorNames()
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.mailetcontainer.api.MailSpooler#getProcessorNames()
      */
     public String[] getProcessorNames() {
         return mailProcessor.getProcessorNames();
@@ -233,7 +244,7 @@ public class JamesSpoolManager implement
 
     /*
      * (non-Javadoc)
-     * @see org.apache.james.services.SpoolManager#getMailets(java.lang.String)
+     * @see org.apache.james.mailetcontainer.api.MailSpooler#getMailets(java.lang.String)
      */
     public List<Mailet> getMailets(String processorName) {
         MailetContainer mailetContainer = getMailetContainerByName(processorName);
@@ -243,7 +254,7 @@ public class JamesSpoolManager implement
 
     /*
      * (non-Javadoc)
-     * @see org.apache.james.services.SpoolManager#getMatchers(java.lang.String)
+     * @see org.apache.james.mailetcontainer.api.MailSpooler#getMatchers(java.lang.String)
      */
     public List<Matcher> getMatchers(String processorName) {
         MailetContainer mailetContainer = getMailetContainerByName(processorName);
@@ -251,6 +262,7 @@ public class JamesSpoolManager implement
         return mailetContainer.getMatchers();
     }
 
+    
     private MailetContainer getMailetContainerByName(String processorName) {        
         MailProcessor processor = mailProcessor.getProcessor(processorName);
         if (!(processor instanceof MailetContainer)) return null;
@@ -268,4 +280,20 @@ public class JamesSpoolManager implement
     public void setLog(Log log) {
         this.logger = log;
     }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.mailetcontainer.api.MailSpoolerMBean#getThreadCount()
+     */
+    public int getThreadCount() {
+        return numThreads;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.mailetcontainer.api.MailSpoolerMBean#getCurrentSpoolCount()
+     */
+    public int getCurrentSpoolCount() {
+        return processingActive.get();
+    }
 }



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


Mime
View raw message