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/10/12 20:03:20 UTC

svn commit: r1021866 [1/2] - in /james/server/trunk: dnsservice-api/src/main/java/org/apache/james/dnsservice/api/ dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/ domain-api/src/main/java/org/apache/james/api/domainlist/ domain-ap...

Author: norman
Date: Tue Oct 12 18:03:19 2010
New Revision: 1021866

URL: http://svn.apache.org/viewvc?rev=1021866&view=rev
Log:
Add JMX support for a few components (JAMES-645 and JAMES-1057)

Added:
    james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainListMBean.java
    james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainListMBean.java
    james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/ServerMBean.java
    james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/ConnectionCountHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerMBean.java
Removed:
    james/server/trunk/management/src/main/java/org/apache/james/management/DomainListManagementException.java
    james/server/trunk/management/src/main/java/org/apache/james/management/DomainListManagementMBean.java
    james/server/trunk/management/src/main/java/org/apache/james/management/DomainListManagementService.java
    james/server/trunk/management/src/main/java/org/apache/james/management/impl/DomainListManagement.java
    james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/POP3ServerMBean.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/RemoteManagerMBean.java
Modified:
    james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java
    james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSServiceMBean.java
    james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
    james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainList.java
    james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainList.java
    james/server/trunk/domain-api/src/test/java/org/apache/james/api/domainlist/SimpleDomainList.java
    james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java
    james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JPADomainListTest.java
    james/server/trunk/domain-function/src/test/java/org/apache/james/domain/XMLDomainListTest.java
    james/server/trunk/domain-library/src/main/java/org/apache/james/domain/AbstractDomainList.java
    james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NioImapServer.java
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java
    james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
    james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/JamesMailetContext.java
    james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java
    james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/NioPOP3Server.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddDomainCmdHandler.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListDomainsCmdHandler.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/RemoveDomainCmdHandler.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java
    james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/NioSMTPServer.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailServer.java
    james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml

Modified: james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java (original)
+++ james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSService.java Tue Oct 12 18:03:19 2010
@@ -33,11 +33,6 @@ import org.apache.mailet.HostAddress;
 public interface DNSService {
 
     /**
-     * The component role used by components implementing this service
-     */
-    String ROLE = DNSService.class.getName();
-
-    /**
      * <p>Return a prioritized unmodifiable list of host handling mail
      * for the domain.</p>
      * 

Modified: james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSServiceMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSServiceMBean.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSServiceMBean.java (original)
+++ james/server/trunk/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/DNSServiceMBean.java Tue Oct 12 18:03:19 2010
@@ -22,14 +22,34 @@
 package org.apache.james.dnsservice.api;
 
 /**
- * An interface to expose James management functionality through JMX.
+ * JMX MBean to manage the DNSService
  * 
- * @phoenix:mx-topic name="DNSService"
  */
 public interface DNSServiceMBean {
-    /**
-    * @phoenix:mx-operation
-    * @phoenix:mx-description Returns the list of DNS servers
-    */    
+
+	/**
+	 * Return the configured DNSServers
+	 * 
+	 * @return servers
+	 */
     public String[] getDNSServers();
+    
+    /**
+     * Return the maximum cache size
+     * 
+     * @return maxCacheSize
+     */
+    public int getMaximumCacheSize();
+    
+    /**
+     * Return the current size of the cache
+     * 
+     * @return currentCacheSize
+     */
+    public int getCurrentCacheSize();
+
+    /**
+     * Clear the cache of the service
+     */
+    public void clearCache();
 }

Modified: james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java (original)
+++ james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java Tue Oct 12 18:03:19 2010
@@ -119,16 +119,24 @@ public class DNSJavaService implements D
     
     private String localAddress;
     
-    private HierarchicalConfiguration configuration;
     
     private Log logger;
     
     
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.lifecycle.LogEnabled#setLog(org.apache.commons.logging.Log)
+     */
     public void setLog(Log logger) {
         this.logger = logger;
     }
     
-    public void configure(HierarchicalConfiguration configuration) throws ConfigurationException{
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
+     */
+    @SuppressWarnings("unchecked")
+	public void configure(HierarchicalConfiguration configuration) throws ConfigurationException{
 
         final boolean autodiscover =
             configuration.getBoolean( "autodiscover", true );
@@ -191,7 +199,7 @@ public class DNSJavaService implements D
         //      docs I don't think so
         dnsCredibility = authoritative ? Credibility.AUTH_ANSWER : Credibility.NONAUTH_ANSWER;
 
-        maxCacheSize = (int)configuration.getLong( "maxcachesize",maxCacheSize );
+        maxCacheSize = configuration.getInt( "maxcachesize",maxCacheSize );
     }
     
     
@@ -596,4 +604,28 @@ public class DNSJavaService implements D
         return InetAddress.getLocalHost();
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.dnsservice.api.DNSServiceMBean#getMaximumCacheSize()
+     */
+	public int getMaximumCacheSize() {
+		return maxCacheSize;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.dnsservice.api.DNSServiceMBean#getCurrentCacheSize()
+	 */
+	public int getCurrentCacheSize() {
+		return cache.getSize();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.dnsservice.api.DNSServiceMBean#clearCache()
+	 */
+	public void clearCache() {
+		cache.clearCache();
+	}
+
 }

Modified: james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainList.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainList.java (original)
+++ james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainList.java Tue Oct 12 18:03:19 2010
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.james.api.domainlist;
 
-import java.util.List;
 
 /**
  * This interface should be implemented by services which
@@ -26,19 +25,14 @@ import java.util.List;
  *
  */
 public interface DomainList {
-
-    /**
-     * The component role used by components implementing this service
-     */
-    public final static String ROLE = DomainList.class.getName();
     
     /**
-     * Return List of domains which should be used as localdomains.
+     * Return array of domains which should be used as localdomains.
      * Return null if no domain is found.
      * 
      * @return domains
      */
-    public List<String> getDomains();
+    public String[] getDomains();
     
     /**
      * Return true if the domain exists in the service 

Added: james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainListMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainListMBean.java?rev=1021866&view=auto
==============================================================================
--- james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainListMBean.java (added)
+++ james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/DomainListMBean.java Tue Oct 12 18:03:19 2010
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.api.domainlist;
+
+public interface DomainListMBean {
+
+	  /**
+     * Return an Array of domains which should be used as localdomains. Return null if no
+     * domains were found
+     * 
+     * @return domains
+     */
+    public String[] getDomains();
+    
+    /**
+     * Return true if the domain exists in the domainlist 
+     * 
+     * 
+     * @param domain the domain
+     * @return true if the given domain exists in the service
+     */
+    public boolean containsDomain(String domain);
+    
+    
+}

Modified: james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainList.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainList.java (original)
+++ james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainList.java Tue Oct 12 18:03:19 2010
@@ -22,8 +22,6 @@ package org.apache.james.api.domainlist;
  * Services which allow to manage the DomainList should implement this interface.
  */
 public interface ManageableDomainList extends DomainList {
-
-    public final static String ROLE = ManageableDomainList.class.getName();
     
     /**
      * Add domain to the service
@@ -40,5 +38,5 @@ public interface ManageableDomainList ex
      * @return true if successfull
      */
     public boolean removeDomain(String domain);
-
+    
 }

Added: james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainListMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainListMBean.java?rev=1021866&view=auto
==============================================================================
--- james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainListMBean.java (added)
+++ james/server/trunk/domain-api/src/main/java/org/apache/james/api/domainlist/ManageableDomainListMBean.java Tue Oct 12 18:03:19 2010
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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.api.domainlist;
+
+public interface ManageableDomainListMBean extends DomainListMBean{
+
+    /**
+     * Add domain to the service
+     * 
+     * @param domain domain to add
+     * @return true if successfull
+     */
+    public boolean addDomain(String domain);
+    
+    /**
+     * Remove domain from the service
+     *  
+     * @param domain domain to remove
+     * @return true if successfull
+     */
+    public boolean removeDomain(String domain);
+}

Modified: james/server/trunk/domain-api/src/test/java/org/apache/james/api/domainlist/SimpleDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-api/src/test/java/org/apache/james/api/domainlist/SimpleDomainList.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/domain-api/src/test/java/org/apache/james/api/domainlist/SimpleDomainList.java (original)
+++ james/server/trunk/domain-api/src/test/java/org/apache/james/api/domainlist/SimpleDomainList.java Tue Oct 12 18:03:19 2010
@@ -34,8 +34,8 @@ public class SimpleDomainList implements
         return domains.contains(domain);
     }
 
-    public List<String> getDomains() {
-        return domains;
+    public String[] getDomains() {
+        return domains.toArray(new String[domains.size()]);
     }
 
     public void setAutoDetect(boolean autodetect) {

Modified: james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java (original)
+++ james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JDBCDomainListTest.java Tue Oct 12 18:03:19 2010
@@ -130,7 +130,7 @@ public class JDBCDomainListTest  extends
         dom.init();
         dom.addDomain("domain1.");
 
-        assertEquals("two domain found",dom.getDomains().size(),2);
+        assertEquals("two domain found",dom.getDomains().length,2);
         
         dom.removeDomain("domain1.");
         assertNull("two domain found",dom.getDomains());

Modified: james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JPADomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JPADomainListTest.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JPADomainListTest.java (original)
+++ james/server/trunk/domain-function/src/test/java/org/apache/james/domain/JPADomainListTest.java Tue Oct 12 18:03:19 2010
@@ -98,7 +98,7 @@ public class JPADomainListTest extends T
         assertEquals(true, jpaDomainList.addDomain(DOMAIN_3));
         assertEquals(true, jpaDomainList.addDomain(DOMAIN_4));
         assertEquals(true, jpaDomainList.addDomain(DOMAIN_5));
-        assertEquals(3, jpaDomainList.getDomains().size());
+        assertEquals(3, jpaDomainList.getDomains().length);
     }
 
     /**
@@ -124,7 +124,7 @@ public class JPADomainListTest extends T
     public void testAddRemoveContainsDifferentDomain() {
         assertEquals(true, jpaDomainList.addDomain(DOMAIN_1));
         assertEquals(true, jpaDomainList.removeDomain(DOMAIN_2));
-        assertEquals(1, jpaDomainList.getDomains().size());
+        assertEquals(1, jpaDomainList.getDomains().length);
         assertEquals(true, jpaDomainList.containsDomain(DOMAIN_1));
     }
     

Modified: james/server/trunk/domain-function/src/test/java/org/apache/james/domain/XMLDomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-function/src/test/java/org/apache/james/domain/XMLDomainListTest.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/domain-function/src/test/java/org/apache/james/domain/XMLDomainListTest.java (original)
+++ james/server/trunk/domain-function/src/test/java/org/apache/james/domain/XMLDomainListTest.java Tue Oct 12 18:03:19 2010
@@ -75,7 +75,7 @@ public class XMLDomainListTest extends T
         dom.configure(setUpConfiguration(false, false, domains));
         dom.setDNSService(setUpDNSServer("localhost"));
 
-        assertTrue("No domain found", dom.getDomains().isEmpty());
+        assertNull("No domain found", dom.getDomains());
     }
 
     public void testGetDomains() throws Exception {
@@ -88,7 +88,7 @@ public class XMLDomainListTest extends T
         dom.configure(setUpConfiguration(false,false,domains));
         dom.setDNSService(setUpDNSServer("localhost"));
         
-        assertTrue("Two domain found",dom.getDomains().size() ==2);
+        assertTrue("Two domain found",dom.getDomains().length ==2);
     }
     
     public void testGetDomainsAutoDetectNotLocalHost() throws Exception {
@@ -100,7 +100,7 @@ public class XMLDomainListTest extends T
         dom.configure(setUpConfiguration(true,false,domains));
 
         dom.setDNSService(setUpDNSServer("local"));
-        assertEquals("Two domains found",dom.getDomains().size(), 2);
+        assertEquals("Two domains found",dom.getDomains().length, 2);
     }
     
     public void testGetDomainsAutoDetectLocalHost() throws Exception {
@@ -113,6 +113,6 @@ public class XMLDomainListTest extends T
 
         dom.setDNSService(setUpDNSServer("localhost"));
         
-        assertEquals("One domain found",dom.getDomains().size(), 1);
+        assertEquals("One domain found",dom.getDomains().length, 1);
     }
 }

Modified: james/server/trunk/domain-library/src/main/java/org/apache/james/domain/AbstractDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-library/src/main/java/org/apache/james/domain/AbstractDomainList.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/domain-library/src/main/java/org/apache/james/domain/AbstractDomainList.java (original)
+++ james/server/trunk/domain-library/src/main/java/org/apache/james/domain/AbstractDomainList.java Tue Oct 12 18:03:19 2010
@@ -32,13 +32,14 @@ import javax.annotation.Resource;
 
 import org.apache.commons.logging.Log;
 import org.apache.james.api.domainlist.ManageableDomainList;
+import org.apache.james.api.domainlist.ManageableDomainListMBean;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.lifecycle.LogEnabled;
 
 /**
  * All implementations of the DomainList interface should extends this abstract class
  */
-public abstract class AbstractDomainList implements  ManageableDomainList, LogEnabled {
+public abstract class AbstractDomainList implements  ManageableDomainList, LogEnabled, ManageableDomainListMBean {
     private DNSService dns;
     private boolean autoDetect = true;
     private boolean autoDetectIP = true;
@@ -57,11 +58,12 @@ public abstract class AbstractDomainList
     protected Log getLogger() {
         return logger;
     }
-    
-    /**
+
+    /*
+     * (non-Javadoc)
      * @see org.apache.james.api.domainlist.DomainList#getDomains()
      */
-    public List<String> getDomains() {  
+    public String[] getDomains() {  
         List<String> domains = getDomainListInternal();
         if (domains != null) {
             
@@ -88,7 +90,11 @@ public abstract class AbstractDomainList
                     getLogger().debug("Handling mail for: " + i.next());
                 }
             }  
-            return domains;
+            if (domains.isEmpty()) {
+            	return null;
+            } else {
+                return domains.toArray(new String[domains.size()]);
+            }
         } else {
             return null;
         }

Modified: james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NioImapServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NioImapServer.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NioImapServer.java (original)
+++ james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NioImapServer.java Tue Oct 12 18:03:19 2010
@@ -1,138 +1,168 @@
-/****************************************************************
- * 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.imapserver.netty;
-
-import static org.jboss.netty.channel.Channels.pipeline;
-
-import javax.annotation.Resource;
-import javax.net.ssl.SSLEngine;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.imap.api.ImapConstants;
-import org.apache.james.imap.api.process.ImapProcessor;
-import org.apache.james.imap.decode.ImapDecoder;
-import org.apache.james.imap.encode.ImapEncoder;
-import org.apache.james.imap.main.ImapRequestStreamHandler;
-import org.apache.james.protocols.impl.ChannelGroupHandler;
-import org.apache.james.protocols.impl.TimeoutHandler;
-import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.handler.connection.ConnectionLimitUpstreamHandler;
-import org.jboss.netty.handler.connection.ConnectionPerIpLimitUpstreamHandler;
-import org.jboss.netty.handler.ssl.SslHandler;
-import org.jboss.netty.util.HashedWheelTimer;
-
-/**
- * NIO IMAP Server which use Netty
- *
- */
-public class NioImapServer extends AbstractConfigurableAsyncServer implements ImapConstants{
-
-    private static final String softwaretype = "JAMES "+VERSION+" Server "; //+ Constants.SOFTWARE_VERSION;
-
-    private String hello;
-    private ImapProcessor processor;
-    private ImapEncoder encoder;
-
-    private ImapDecoder decoder;
-
-    @Resource(name="imapDecoder")
-    public void setImapDecoder(ImapDecoder decoder) {
-        this.decoder = decoder;
-    }
-    
-    @Resource(name="imapEncoder")
-    public void setImapEncoder(ImapEncoder encoder) {
-        this.encoder = encoder;
-    }
-    
-    @Resource(name="imapProcessor")
-    public void setImapProcessor(ImapProcessor processor) {
-        this.processor = processor;
-    }
-    
-    @Override
-    public void doConfigure( final HierarchicalConfiguration configuration ) throws ConfigurationException {
-        super.doConfigure(configuration);
-        hello  = softwaretype + " Server " + getHelloName() + " is ready.";
-    }
-    
-    
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.socket.mina.AbstractAsyncServer#getDefaultPort()
-     */
-    public int getDefaultPort() {
-        return 143;
-    }
-
- 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.socket.mina.AbstractAsyncServer#getServiceType()
-     */
-    public String getServiceType() {
-        return "IMAP Service";
-    }
-
-    @Override
-    protected ChannelPipelineFactory createPipelineFactory(final ChannelGroup group) {
-        return new ChannelPipelineFactory() {
-            private final ChannelGroupHandler groupHandler = new ChannelGroupHandler(group);
-            private final HashedWheelTimer timer = new HashedWheelTimer();
-            
-            // Timeout of 30 minutes See rfc2060 5.4 for details
-            private final static int TIMEOUT = 30 * 60;
-            
-            public ChannelPipeline getPipeline() throws Exception {
-                ChannelPipeline pipeline = pipeline();
-                pipeline.addLast("groupHandler", groupHandler);
-                pipeline.addLast("timeoutHandler", new TimeoutHandler(timer, TIMEOUT));
-                pipeline.addLast("connectionLimit", new ConnectionLimitUpstreamHandler(NioImapServer.this.connectionLimit));
-
-                pipeline.addLast("connectionPerIpLimit", new ConnectionPerIpLimitUpstreamHandler(NioImapServer.this.connPerIP));
-
-                if (isSSLSocket()) {
-                    // We need to set clientMode to false.
-                    // See https://issues.apache.org/jira/browse/JAMES-1025
-                    SSLEngine engine = getSSLContext().createSSLEngine();
-                    engine.setUseClientMode(false);
-                    pipeline.addFirst("sslHandler", new SslHandler(engine));
-                    
-                }
-                final ImapRequestStreamHandler handler = new ImapRequestStreamHandler(decoder, processor, encoder);
-                
-                if (isStartTLSSupported())  {
-                    pipeline.addLast("coreHandler",  new ImapStreamChannelUpstreamHandler(hello, handler, getLogger(), NioImapServer.this.getTimeout(), getSSLContext().createSSLEngine()));
-                } else {
-                    pipeline.addLast("coreHandler",  new ImapStreamChannelUpstreamHandler(hello, handler, getLogger(), NioImapServer.this.getTimeout()));
-                }
-                
-                return pipeline;
-            }
-           
-        };
-    }
-
-
-
-}
+/****************************************************************
+ * 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.imapserver.netty;
+
+import static org.jboss.netty.channel.Channels.pipeline;
+
+import javax.annotation.Resource;
+import javax.net.ssl.SSLEngine;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.decode.ImapDecoder;
+import org.apache.james.imap.encode.ImapEncoder;
+import org.apache.james.imap.main.ImapRequestStreamHandler;
+import org.apache.james.protocols.impl.ChannelGroupHandler;
+import org.apache.james.protocols.impl.TimeoutHandler;
+import org.apache.james.socket.ServerMBean;
+import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
+import org.apache.james.socket.netty.ConnectionCountHandler;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.group.ChannelGroup;
+import org.jboss.netty.handler.connection.ConnectionLimitUpstreamHandler;
+import org.jboss.netty.handler.connection.ConnectionPerIpLimitUpstreamHandler;
+import org.jboss.netty.handler.ssl.SslHandler;
+import org.jboss.netty.util.HashedWheelTimer;
+
+/**
+ * NIO IMAP Server which use Netty
+ *
+ */
+public class NioImapServer extends AbstractConfigurableAsyncServer implements ImapConstants, ServerMBean {
+
+    private static final String softwaretype = "JAMES "+VERSION+" Server ";
+    private final ConnectionCountHandler countHandler = new ConnectionCountHandler();
+    
+    private String hello;
+    private ImapProcessor processor;
+    private ImapEncoder encoder;
+
+    private ImapDecoder decoder;
+
+    @Resource(name="imapDecoder")
+    public void setImapDecoder(ImapDecoder decoder) {
+        this.decoder = decoder;
+    }
+    
+    @Resource(name="imapEncoder")
+    public void setImapEncoder(ImapEncoder encoder) {
+        this.encoder = encoder;
+    }
+    
+    @Resource(name="imapProcessor")
+    public void setImapProcessor(ImapProcessor processor) {
+        this.processor = processor;
+    }
+    
+    @Override
+    public void doConfigure( final HierarchicalConfiguration configuration ) throws ConfigurationException {
+        super.doConfigure(configuration);
+        hello  = softwaretype + " Server " + getHelloName() + " is ready.";
+    }
+    
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.mina.AbstractAsyncServer#getDefaultPort()
+     */
+    public int getDefaultPort() {
+        return 143;
+    }
+
+ 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.mina.AbstractAsyncServer#getServiceType()
+     */
+    public String getServiceType() {
+        return "IMAP Service";
+    }
+
+    @Override
+    protected ChannelPipelineFactory createPipelineFactory(final ChannelGroup group) {
+        return new ChannelPipelineFactory() {
+            private final ChannelGroupHandler groupHandler = new ChannelGroupHandler(group);
+            private final HashedWheelTimer timer = new HashedWheelTimer();
+            
+            // Timeout of 30 minutes See rfc2060 5.4 for details
+            private final static int TIMEOUT = 30 * 60;
+            
+            public ChannelPipeline getPipeline() throws Exception {
+                ChannelPipeline pipeline = pipeline();
+                pipeline.addLast("groupHandler", groupHandler);
+                pipeline.addLast("timeoutHandler", new TimeoutHandler(timer, TIMEOUT));
+                pipeline.addLast("connectionLimit", new ConnectionLimitUpstreamHandler(NioImapServer.this.connectionLimit));
+
+                pipeline.addLast("connectionPerIpLimit", new ConnectionPerIpLimitUpstreamHandler(NioImapServer.this.connPerIP));
+
+                if (isSSLSocket()) {
+                    // We need to set clientMode to false.
+                    // See https://issues.apache.org/jira/browse/JAMES-1025
+                    SSLEngine engine = getSSLContext().createSSLEngine();
+                    engine.setUseClientMode(false);
+                    pipeline.addFirst("sslHandler", new SslHandler(engine));
+                    
+                }
+                pipeline.addLast("connectionCountHandler", countHandler);
+                
+                final ImapRequestStreamHandler handler = new ImapRequestStreamHandler(decoder, processor, encoder);
+                
+                if (isStartTLSSupported())  {
+                    pipeline.addLast("coreHandler",  new ImapStreamChannelUpstreamHandler(hello, handler, getLogger(), NioImapServer.this.getTimeout(), getSSLContext().createSSLEngine()));
+                } else {
+                    pipeline.addLast("coreHandler",  new ImapStreamChannelUpstreamHandler(hello, handler, getLogger(), NioImapServer.this.getTimeout()));
+                }
+                
+                return pipeline;
+            }
+           
+        };
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.ServerMBean#getCurrentConnections()
+     */
+	public int getCurrentConnections() {
+		return countHandler.getCurrentConnectionCount();
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.imapserver.IMAPServerMBean#getStartTLSSupported()
+	 */
+	public boolean getStartTLSSupported() {
+		return isStartTLSSupported();
+	}
+	
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.socket.ServerMBean#getMaximumConcurrentConnections()
+	 */
+	public int getMaximumConcurrentConnections() {
+		return connectionLimit;
+	}
+
+
+}

Modified: james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java (original)
+++ james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java Tue Oct 12 18:03:19 2010
@@ -1,201 +1,259 @@
-/****************************************************************
- * 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.lmtpserver.netty;
-
-import javax.annotation.Resource;
-import javax.net.ssl.SSLContext;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.protocols.api.ProtocolHandlerChain;
-import org.apache.james.protocols.impl.AbstractSSLAwareChannelPipelineFactory;
-import org.apache.james.protocols.smtp.SMTPConfiguration;
-import org.apache.james.services.MailServer;
-import org.apache.james.smtpserver.netty.SMTPChannelUpstreamHandler;
-import org.apache.james.smtpserver.netty.SMTPResponseEncoder;
-import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
-
-public class NioLMTPServer extends AbstractConfigurableAsyncServer{
-
-    /**
-     * The maximum message size allowed by this SMTP server.  The default
-     * value, 0, means no limit.
-     */
-    private long maxMessageSize = 0;
-    private MailServer mailServer;
-    private ProtocolHandlerChain handlerChain;
-    private LMTPConfiguration lmtpConfig = new LMTPConfiguration();
-    private String lmtpGreeting;
-    
-
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
-    
-
-    public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
-        this.handlerChain = handlerChain;
-    }
-
-    
-    @Override
-    public int getDefaultPort() {
-        return 24;
-    }
-
-    @Override
-    public String getServiceType() {
-        return "LMTP Service";
-    }
-    
-    public void doConfigure(final HierarchicalConfiguration configuration) throws ConfigurationException {
-        if (isEnabled()) {
-            HierarchicalConfiguration handlerConfiguration = configuration.configurationAt("handler");
-           
-
-            // get the message size limit from the conf file and multiply
-            // by 1024, to put it in bytes
-            maxMessageSize = handlerConfiguration.getLong( "maxmessagesize",maxMessageSize ) * 1024;
-            if (maxMessageSize > 0) {
-                getLogger().info("The maximum allowed message size is " + maxMessageSize + " bytes.");
-            } else {
-                getLogger().info("No maximum message size is enforced for this server.");
-            }
-            
-            // get the lmtpGreeting
-            lmtpGreeting = handlerConfiguration.getString("lmtpGreeting",null);
-
-
-        }
-    }
-    
-    @Override
-    protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) {
-        return new LMTPChannelPipelineFactory(getTimeout(), connectionLimit, connPerIP, group);
-    }
-
-    /**
-     * A class to provide SMTP handler configuration to the handlers
-     */
-    public class LMTPConfiguration implements SMTPConfiguration {
-
-        /**
-         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName()
-         */
-        public String getHelloName() {
-            if (NioLMTPServer.this.getHelloName() == null) {
-                return NioLMTPServer.this.mailServer.getHelloName();
-            } else {
-                return NioLMTPServer.this.getHelloName();
-            }
-        }
-
-        /**
-         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getResetLength()
-         */
-        public int getResetLength() {
-            return -1;
-        }
-
-        /**
-         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getMaxMessageSize()
-         */
-        public long getMaxMessageSize() {
-            return NioLMTPServer.this.maxMessageSize;
-        }
-
-        /**
-         * Relaying not allowed with LMTP
-         */
-        public boolean isRelayingAllowed(String remoteIP) {
-            return false;
-        }
-
-        /**
-         * No enforcement
-         */
-        public boolean useHeloEhloEnforcement() {
-            return false;
-        }
-
-
-        /**
-         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getSMTPGreeting()
-         */
-        public String getSMTPGreeting() {
-            return NioLMTPServer.this.lmtpGreeting;
-        }
-
-        /**
-         * @see org.apache.james.protocols.smtp.SMTPConfiguration#useAddressBracketsEnforcement()
-         */
-        public boolean useAddressBracketsEnforcement() {
-            return true;
-        }
-
-        /**
-         * @see org.apache.james.protocols.smtp.SMTPConfiguration#isAuthRequired(java.lang.String)
-         */
-        public boolean isAuthRequired(String remoteIP) {
-            return true;
-        }
-
-        /**
-         * @see org.apache.james.protocols.smtp.SMTPConfiguration#isStartTLSSupported()
-         */
-        public boolean isStartTLSSupported() {
-            return false;
-        }
-    }
-    
-    private final class LMTPChannelPipelineFactory extends AbstractSSLAwareChannelPipelineFactory {
-
-        public LMTPChannelPipelineFactory(int timeout, int maxConnections,
-                int maxConnectsPerIp, ChannelGroup group) {
-            super(timeout, maxConnections, maxConnectsPerIp, group);
-        }
-
-        @Override
-        protected SSLContext getSSLContext() {
-            return null;
-        }
-
-        @Override
-        protected boolean isSSLSocket() {
-            return  false;
-        }
-
-        @Override
-        protected OneToOneEncoder createEncoder() {
-            return new SMTPResponseEncoder();
-        }
-
-        @Override
-        protected ChannelUpstreamHandler createHandler() {
-            return new SMTPChannelUpstreamHandler(handlerChain, lmtpConfig, getLogger(), getSSLContext());
-        }
-        
-    }
-
-}
+/****************************************************************
+ * 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.lmtpserver.netty;
+
+import javax.annotation.Resource;
+import javax.net.ssl.SSLContext;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.protocols.api.ProtocolHandlerChain;
+import org.apache.james.protocols.impl.AbstractSSLAwareChannelPipelineFactory;
+import org.apache.james.protocols.smtp.SMTPConfiguration;
+import org.apache.james.services.MailServer;
+import org.apache.james.smtpserver.SMTPServerMBean;
+import org.apache.james.smtpserver.netty.SMTPChannelUpstreamHandler;
+import org.apache.james.smtpserver.netty.SMTPResponseEncoder;
+import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
+import org.apache.james.socket.netty.ConnectionCountHandler;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.ChannelUpstreamHandler;
+import org.jboss.netty.channel.group.ChannelGroup;
+import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
+
+public class NioLMTPServer extends AbstractConfigurableAsyncServer implements SMTPServerMBean{
+
+    /**
+     * The maximum message size allowed by this SMTP server.  The default
+     * value, 0, means no limit.
+     */
+    private long maxMessageSize = 0;
+    private MailServer mailServer;
+    private ProtocolHandlerChain handlerChain;
+    private LMTPConfiguration lmtpConfig = new LMTPConfiguration();
+    private String lmtpGreeting;
+    private final ConnectionCountHandler countHandler = new ConnectionCountHandler();
+    
+
+    @Resource(name="mailserver")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
+    
+
+    public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
+        this.handlerChain = handlerChain;
+    }
+
+    
+    @Override
+    public int getDefaultPort() {
+        return 24;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.ServerMBean#getServiceType()
+     */
+    public String getServiceType() {
+        return "LMTP Service";
+    }
+    
+    public void doConfigure(final HierarchicalConfiguration configuration) throws ConfigurationException {
+        if (isEnabled()) {
+            HierarchicalConfiguration handlerConfiguration = configuration.configurationAt("handler");
+           
+
+            // get the message size limit from the conf file and multiply
+            // by 1024, to put it in bytes
+            maxMessageSize = handlerConfiguration.getLong( "maxmessagesize",maxMessageSize ) * 1024;
+            if (maxMessageSize > 0) {
+                getLogger().info("The maximum allowed message size is " + maxMessageSize + " bytes.");
+            } else {
+                getLogger().info("No maximum message size is enforced for this server.");
+            }
+            
+            // get the lmtpGreeting
+            lmtpGreeting = handlerConfiguration.getString("lmtpGreeting",null);
+
+
+        }
+    }
+    
+    @Override
+    protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) {
+        return new LMTPChannelPipelineFactory(getTimeout(), connectionLimit, connPerIP, group);
+    }
+
+    /**
+     * A class to provide SMTP handler configuration to the handlers
+     */
+    public class LMTPConfiguration implements SMTPConfiguration {
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName()
+         */
+        public String getHelloName() {
+            if (NioLMTPServer.this.getHelloName() == null) {
+                return NioLMTPServer.this.mailServer.getHelloName();
+            } else {
+                return NioLMTPServer.this.getHelloName();
+            }
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getResetLength()
+         */
+        public int getResetLength() {
+            return -1;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getMaxMessageSize()
+         */
+        public long getMaxMessageSize() {
+            return NioLMTPServer.this.maxMessageSize;
+        }
+
+        /**
+         * Relaying not allowed with LMTP
+         */
+        public boolean isRelayingAllowed(String remoteIP) {
+            return false;
+        }
+
+        /**
+         * No enforcement
+         */
+        public boolean useHeloEhloEnforcement() {
+            return false;
+        }
+
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getSMTPGreeting()
+         */
+        public String getSMTPGreeting() {
+            return NioLMTPServer.this.lmtpGreeting;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#useAddressBracketsEnforcement()
+         */
+        public boolean useAddressBracketsEnforcement() {
+            return true;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#isAuthRequired(java.lang.String)
+         */
+        public boolean isAuthRequired(String remoteIP) {
+            return true;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#isStartTLSSupported()
+         */
+        public boolean isStartTLSSupported() {
+            return false;
+        }
+    }
+    
+    private final class LMTPChannelPipelineFactory extends AbstractSSLAwareChannelPipelineFactory {
+
+        public LMTPChannelPipelineFactory(int timeout, int maxConnections,
+                int maxConnectsPerIp, ChannelGroup group) {
+            super(timeout, maxConnections, maxConnectsPerIp, group);
+        }
+
+        @Override
+		public ChannelPipeline getPipeline() throws Exception {
+			ChannelPipeline pipeLine = super.getPipeline();
+			pipeLine.addBefore("coreHandler", "countHandler", countHandler);
+			return pipeLine;
+		}
+
+		@Override
+        protected SSLContext getSSLContext() {
+            return null;
+        }
+
+        @Override
+        protected boolean isSSLSocket() {
+            return  false;
+        }
+
+        @Override
+        protected OneToOneEncoder createEncoder() {
+            return new SMTPResponseEncoder();
+        }
+
+        @Override
+        protected ChannelUpstreamHandler createHandler() {
+            return new SMTPChannelUpstreamHandler(handlerChain, lmtpConfig, getLogger(), getSSLContext());
+        }
+        
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.smtpserver.SMTPServerMBean#getAddressBracketsEnforcement()
+     */
+	public boolean getAddressBracketsEnforcement() {
+		return lmtpConfig.useAddressBracketsEnforcement();
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.smtpserver.SMTPServerMBean#getHeloEhloEnforcement()
+	 */
+	public boolean getHeloEhloEnforcement() {
+		return lmtpConfig.useHeloEhloEnforcement();
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.smtpserver.SMTPServerMBean#getMaximalMessageSize()
+	 */
+	public long getMaximalMessageSize() {
+		return lmtpConfig.getMaxMessageSize();
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.socket.ServerMBean#getCurrentConnections()
+	 */
+	public int getCurrentConnections() {
+		return countHandler.getCurrentConnectionCount();
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.protocols.smtp.SMTPServerMBean#getNetworkInterface()
+	 */
+	public String getNetworkInterface() {
+		return "unknown";
+	}
+
+}

Modified: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java (original)
+++ james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java Tue Oct 12 18:03:19 2010
@@ -93,9 +93,9 @@ public class CamelMailProcessorList impl
 	@PostConstruct
 	public void init() throws Exception  {
 		getCamelContext().addRoutes(new SpoolRouteBuilder());
-
 		producerTemplate = getCamelContext().createProducerTemplate();
 	}
+	
     /**
      * Destroy all mailets and matchers
      */

Modified: james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/JamesMailetContext.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/JamesMailetContext.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/JamesMailetContext.java (original)
+++ james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/JamesMailetContext.java Tue Oct 12 18:03:19 2010
@@ -457,13 +457,16 @@ public class JamesMailetContext implemen
             String domainName = null; // the domain to use
             // loop through candidate domains until we find one or exhaust the
             // list
-            Iterator<String> i = domains.getDomains().iterator();
-            while (i.hasNext()) {
-                String serverName = i.next().toLowerCase(Locale.US);
-                if (!("localhost".equals(serverName))) {
-                    domainName = serverName; // ok, not localhost, so use it
-                    continue;
-                }
+            String[] doms = domains.getDomains();
+            if (doms != null) {
+            	for (int i = 0; i < doms.length; i++) {
+                    String serverName = doms[i].toLowerCase(Locale.US);
+                    if (!("localhost".equals(serverName))) {
+                        domainName = serverName; // ok, not localhost, so use it
+                        continue;
+                    }
+            	}
+            
             }
             // if we found a suitable domain, use it. Otherwise fallback to the
             // host name.

Added: james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/ServerMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/ServerMBean.java?rev=1021866&view=auto
==============================================================================
--- james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/ServerMBean.java (added)
+++ james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/ServerMBean.java Tue Oct 12 18:03:19 2010
@@ -0,0 +1,72 @@
+/****************************************************************
+ * 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.socket;
+
+/**
+ * JMX MBean interface for servers
+ */
+public interface ServerMBean {
+	
+	/**
+	 * Return the maximum allowed concurrent connections for the server
+	 *  
+	 * @return maxConcurrentConnections
+	 */
+	public int getMaximumConcurrentConnections();
+	
+	/**
+	 * Return the current connection count
+	 * 
+	 * @return currentConnection
+	 */
+	public int getCurrentConnections();
+	
+	/**
+	 * Return true if the server is enabled
+	 * 
+	 * @return isEnabled
+	 */
+    public boolean isEnabled();
+
+    /**
+     * Return true if startTLS is supported by the server
+     * 
+     * @return startTLS
+     */
+	public boolean getStartTLSSupported();
+
+	
+    /**
+     * Return the port number to which ther server is bound
+     * @return
+     */
+    public int  getPort();
+    
+    /**
+     * Return the socket type of the server. Which can either be plain or secure
+     * 
+     */  
+    public String getSocketType();
+    
+    /**
+     * Return the service type of the server
+     * 
+     */  
+    public String getServiceType();
+}

Modified: james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java (original)
+++ james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java Tue Oct 12 18:03:19 2010
@@ -38,13 +38,14 @@ import org.apache.james.lifecycle.Config
 import org.apache.james.lifecycle.LogEnabled;
 import org.apache.james.protocols.impl.AbstractAsyncServer;
 import org.apache.james.services.FileSystem;
+import org.apache.james.socket.ServerMBean;
 
 
 /**
  * Abstract base class for Servers for all James Servers
  *
  */
-public abstract class AbstractConfigurableAsyncServer extends AbstractAsyncServer implements LogEnabled, Configurable{
+public abstract class AbstractConfigurableAsyncServer extends AbstractAsyncServer implements LogEnabled, Configurable, ServerMBean{
     /**
      * The default value for the connection backlog.
      */
@@ -398,13 +399,6 @@ public abstract class AbstractConfigurab
      */
     protected abstract int getDefaultPort();
     
-    /**
-     * Return textual representation of the service this server provide
-     * 
-     * @return serviceType
-     */
-    protected abstract String getServiceType();
-    
     
     /**
      * Return the SSLContext to use 
@@ -426,14 +420,22 @@ public abstract class AbstractConfigurab
         return "plain";
     }
     
-    /**
-     * Return the network interface on which server is bound. Default is to return
-     * unknown
-     * 
-     * @return interface
-     */
-    public String getNetworkInterface() {
-        return "unkown";
-    }
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.socket.ServerMBean#getStartTLSSupported()
+	 */
+	public boolean getStartTLSSupported() {
+		return isStartTLSSupported();
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.socket.ServerMBean#getMaximumConcurrentConnections()
+	 */
+	public int getMaximumConcurrentConnections() {
+		return connectionLimit;
+	}
     
 }

Added: james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/ConnectionCountHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/ConnectionCountHandler.java?rev=1021866&view=auto
==============================================================================
--- james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/ConnectionCountHandler.java (added)
+++ james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/ConnectionCountHandler.java Tue Oct 12 18:03:19 2010
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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.socket.netty;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+
+/**
+ * Count active connections
+ *
+ */
+public class ConnectionCountHandler extends SimpleChannelUpstreamHandler {
+
+	public AtomicInteger currentConnectionCount = new AtomicInteger();
+	
+	@Override
+	public void channelClosed(ChannelHandlerContext ctx,
+			ChannelStateEvent e) throws Exception {
+		currentConnectionCount.decrementAndGet();
+		super.channelClosed(ctx, e);
+	}
+
+	@Override
+	public void channelOpen(ChannelHandlerContext ctx,
+			ChannelStateEvent e) throws Exception {
+		currentConnectionCount.incrementAndGet();
+		super.channelOpen(ctx, e);
+	}
+
+	
+	/**
+	 * Return the count of the current open connections
+	 * 
+	 * @return count
+	 */
+	public int getCurrentConnectionCount() {
+		return currentConnectionCount.get();
+	}
+}

Modified: james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/NioPOP3Server.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/NioPOP3Server.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/NioPOP3Server.java (original)
+++ james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/NioPOP3Server.java Tue Oct 12 18:03:19 2010
@@ -24,11 +24,13 @@ import javax.net.ssl.SSLContext;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.james.pop3server.POP3HandlerConfigurationData;
-import org.apache.james.pop3server.POP3ServerMBean;
 import org.apache.james.protocols.api.ProtocolHandlerChain;
 import org.apache.james.protocols.impl.AbstractSSLAwareChannelPipelineFactory;
 import org.apache.james.services.MailServer;
+import org.apache.james.socket.ServerMBean;
 import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
+import org.apache.james.socket.netty.ConnectionCountHandler;
+import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.ChannelUpstreamHandler;
 import org.jboss.netty.channel.group.ChannelGroup;
@@ -39,7 +41,7 @@ import org.jboss.netty.handler.codec.one
  * 
  *
  */
-public class NioPOP3Server extends AbstractConfigurableAsyncServer implements POP3ServerMBean{
+public class NioPOP3Server extends AbstractConfigurableAsyncServer implements ServerMBean{
     /**
      * The number of bytes to read before resetting the connection timeout
      * timer. Defaults to 20 KB.
@@ -51,10 +53,13 @@ public class NioPOP3Server extends Abstr
      */
     private POP3HandlerConfigurationData theConfigData = new POP3HandlerConfigurationDataImpl();
 
+    private final ConnectionCountHandler countHandler = new ConnectionCountHandler();
+    
     private ProtocolHandlerChain handlerChain;
 
     private MailServer mailServer;
 
+    
     public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
         this.handlerChain = handlerChain;
     }
@@ -68,8 +73,11 @@ public class NioPOP3Server extends Abstr
         return 110;
     }
 
-    @Override
-    protected String getServiceType() {
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.ServerMBean#getServiceType()
+     */
+    public String getServiceType() {
         return "POP3 Service";
     }
 
@@ -129,6 +137,13 @@ public class NioPOP3Server extends Abstr
         }
 
         @Override
+		public ChannelPipeline getPipeline() throws Exception {
+			ChannelPipeline pipeLine =  super.getPipeline();
+			pipeLine.addBefore("coreHandler", "countHandler", countHandler);
+			return pipeLine;
+		}
+
+		@Override
         protected SSLContext getSSLContext() {
             return NioPOP3Server.this.getSSLContext();
 
@@ -152,4 +167,13 @@ public class NioPOP3Server extends Abstr
         }
         
     }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.ServerMBean#getCurrentConnections()
+     */
+	public int getCurrentConnections() {
+		return countHandler.getCurrentConnectionCount();
+	}
+
 }

Modified: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddDomainCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddDomainCmdHandler.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddDomainCmdHandler.java (original)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddDomainCmdHandler.java Tue Oct 12 18:03:19 2010
@@ -25,8 +25,7 @@ import java.util.List;
 
 import javax.annotation.Resource;
 
-import org.apache.james.management.DomainListManagementException;
-import org.apache.james.management.DomainListManagementService;
+import org.apache.james.api.domainlist.ManageableDomainList;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.remotemanager.CommandHandler;
@@ -43,11 +42,11 @@ public class AddDomainCmdHandler impleme
     private final static String COMMAND_NAME = "ADDDOMAIN";
     private CommandHelp help = new CommandHelp("adddomain [domainname]","add domain to local domains");
 
-    private DomainListManagementService domService;
+    private ManageableDomainList domList;
 
     @Resource(name="domainlistmanagement")
-    public final void setDomainListManagement(DomainListManagementService domService) {
-        this.domService = domService;
+    public final void setManageableDomainList(ManageableDomainList domList) {
+        this.domList = domList;
     }
     
     /**
@@ -70,17 +69,13 @@ public class AddDomainCmdHandler impleme
             response = new RemoteManagerResponse("Usage: " + help.getSyntax());
             return response;
         }
-        
-        try {
-            if(domService.addDomain(parameters)) {
-                response = new RemoteManagerResponse("Adding domain " + parameters + " successful");
-            } else {
-                response = new RemoteManagerResponse("Adding domain " + parameters + " fail");
-            }
-        } catch (DomainListManagementException e) {
-            session.getLogger().error("Error on adding domain: " + e);
-            response = new RemoteManagerResponse("Error on adding domain: " + e);
-        }
+
+		if (domList.addDomain(parameters)) {
+			response = new RemoteManagerResponse("Adding domain " + parameters + " successful");
+		} else {
+			response = new RemoteManagerResponse("Adding domain " + parameters + " fail");
+		}
+
         return response;
     }
 

Modified: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java (original)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java Tue Oct 12 18:03:19 2010
@@ -26,9 +26,9 @@ import java.util.List;
 
 import javax.annotation.Resource;
 
+import org.apache.james.api.domainlist.ManageableDomainList;
 import org.apache.james.api.user.UsersRepository;
 import org.apache.james.api.user.UsersStore;
-import org.apache.james.management.DomainListManagementService;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.remotemanager.CommandHandler;
@@ -47,11 +47,12 @@ public class AddUserCmdHandler implement
 
     private UsersStore uStore;
     private MailServer mailServer;
-    private DomainListManagementService domService;
+
+    private ManageableDomainList domList;
 
     @Resource(name="domainlistmanagement")
-    public final void setDomainListManagement(DomainListManagementService domService) {
-        this.domService = domService;
+    public final void setManageableDomainList(ManageableDomainList domList) {
+        this.domList = domList;
     }
     
     /**
@@ -117,7 +118,7 @@ public class AddUserCmdHandler implement
                     return response;
                 }
                 String domain = username.split("@")[1];
-                if (domService.containsDomain(domain) == false) {
+                if (domList.containsDomain(domain) == false) {
                     response = new RemoteManagerResponse("Domain not exists: " + domain);
                     return response;
                 }

Modified: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListDomainsCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListDomainsCmdHandler.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListDomainsCmdHandler.java (original)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListDomainsCmdHandler.java Tue Oct 12 18:03:19 2010
@@ -21,12 +21,11 @@ package org.apache.james.remotemanager.c
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.annotation.Resource;
 
-import org.apache.james.management.DomainListManagementService;
+import org.apache.james.api.domainlist.ManageableDomainList;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.remotemanager.CommandHandler;
@@ -42,13 +41,12 @@ public class ListDomainsCmdHandler imple
     private final static String COMMAND_NAME = "LISTDOMAINS";
     private CommandHelp help = new CommandHelp("listdomains","list local domains");
 
-    private DomainListManagementService domService;
+    private ManageableDomainList domList;
 
     @Resource(name="domainlistmanagement")
-    public final void setDomainListManagement(DomainListManagementService domService) {
-        this.domService = domService;
+    public final void setManageableDomainList(ManageableDomainList domList) {
+        this.domList = domList;
     }
-    
     /**
      * @see org.apache.james.remotemanager.CommandHandler#getHelp()
      */
@@ -63,15 +61,15 @@ public class ListDomainsCmdHandler imple
     public Response onCommand(RemoteManagerSession session, Request request) {
         RemoteManagerResponse response = null;
         
-        Collection<String> domains = domService.getDomains();
+        String[] domains = domList.getDomains();
         if (domains == null) {
             response = new RemoteManagerResponse("No domains found");
         } else {
             response = new RemoteManagerResponse("Domains:");
                 
-            Iterator<String> d = domains.iterator();
-            while(d.hasNext()) {
-                response.appendLine(d.next());
+            
+            for(int i = 0; i < domains.length; i++) {
+                response.appendLine(domains[i]);
             }
         }   
         return response;

Modified: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/RemoveDomainCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/RemoveDomainCmdHandler.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/RemoveDomainCmdHandler.java (original)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/RemoveDomainCmdHandler.java Tue Oct 12 18:03:19 2010
@@ -26,8 +26,7 @@ import java.util.List;
 
 import javax.annotation.Resource;
 
-import org.apache.james.management.DomainListManagementException;
-import org.apache.james.management.DomainListManagementService;
+import org.apache.james.api.domainlist.ManageableDomainList;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.remotemanager.CommandHandler;
@@ -44,11 +43,11 @@ public class RemoveDomainCmdHandler impl
     private final static String COMMAND_NAME = "REMOVEDOMAIN";
     private CommandHelp help = new CommandHelp("removedomain [domainname]","remove domain from local domains");
 
-    private DomainListManagementService domService;
+    private ManageableDomainList domList;
 
     @Resource(name="domainlistmanagement")
-    public final void setDomainListManagement(DomainListManagementService domService) {
-        this.domService = domService;
+    public final void setManageableDomainList(ManageableDomainList domList) {
+        this.domList = domList;
     }
     
     /**
@@ -72,17 +71,14 @@ public class RemoveDomainCmdHandler impl
             return response;
         }
         
-        try {
-            if(domService.removeDomain(parameters)) {
-                response = new RemoteManagerResponse("Removing domain " + parameters + " successful");
+
+        if(domList.removeDomain(parameters)) {
+            response = new RemoteManagerResponse("Removing domain " + parameters + " successful");
                
-            } else {
-                response = new RemoteManagerResponse("Removing domain " + parameters + " fail");
-            }
-        } catch (DomainListManagementException e) {
-            session.getLogger().error("Error on removing domain: " + e);
-            response = new RemoteManagerResponse("Error on removing domain: " + e);
+        } else {
+            response = new RemoteManagerResponse("Removing domain " + parameters + " fail");
         }
+      
         return response;
     }
 

Modified: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java (original)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java Tue Oct 12 18:03:19 2010
@@ -30,9 +30,11 @@ import org.apache.commons.configuration.
 import org.apache.james.protocols.api.ProtocolHandlerChain;
 import org.apache.james.protocols.impl.AbstractChannelPipelineFactory;
 import org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData;
-import org.apache.james.remotemanager.RemoteManagerMBean;
 import org.apache.james.services.MailServer;
+import org.apache.james.socket.ServerMBean;
 import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
+import org.apache.james.socket.netty.ConnectionCountHandler;
+import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.ChannelUpstreamHandler;
 import org.jboss.netty.channel.group.ChannelGroup;
@@ -43,12 +45,12 @@ import org.jboss.netty.handler.codec.one
  * NIO RemoteManager which use Netty
  *
  */
-public class NioRemoteManager extends AbstractConfigurableAsyncServer implements RemoteManagerMBean{
+public class NioRemoteManager extends AbstractConfigurableAsyncServer implements ServerMBean{
 
 
     private Map<String,String> adminAccounts = new HashMap<String, String>();
     private RemoteManagerHandlerConfigurationData configData = new RemoteManagerHandlerConfigurationDataImpl();
-   
+    private final ConnectionCountHandler countHandler = new ConnectionCountHandler();
     private ProtocolHandlerChain handlerChain;
     private MailServer mailServer;
 
@@ -67,8 +69,12 @@ public class NioRemoteManager extends Ab
         return 4555;
     }
 
-    @Override
-    protected String getServiceType() {
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.ServerMBean#getServiceType()
+     */
+    public String getServiceType() {
         return "RemoteManager Service";
     }
 
@@ -128,7 +134,17 @@ public class NioRemoteManager extends Ab
                 int maxConnections, int maxConnectsPerIp, ChannelGroup group) {
             super(timeout, maxConnections, maxConnectsPerIp, group);
         }
+        
+        
         @Override
+		public ChannelPipeline getPipeline() throws Exception {
+			ChannelPipeline pipeLine =  super.getPipeline();
+			pipeLine.addBefore("coreHandler", "countHandler", countHandler);
+			return pipeLine;
+		}
+
+
+		@Override
         protected OneToOneEncoder createEncoder() {
             return new RemoteManagerResponseEncoder();
         }
@@ -139,4 +155,15 @@ public class NioRemoteManager extends Ab
         }
         
     }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.socket.ServerMBean#getCurrentConnections()
+     */
+	public int getCurrentConnections() {
+		return countHandler.getCurrentConnectionCount();
+	}
+
+
+
 }

Modified: james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java?rev=1021866&r1=1021865&r2=1021866&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java (original)
+++ james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java Tue Oct 12 18:03:19 2010
@@ -47,8 +47,6 @@ import org.apache.james.lifecycle.Lifecy
 import org.apache.james.mailstore.MockMailStore;
 import org.apache.james.management.BayesianAnalyzerManagementException;
 import org.apache.james.management.BayesianAnalyzerManagementService;
-import org.apache.james.management.DomainListManagementException;
-import org.apache.james.management.DomainListManagementService;
 import org.apache.james.management.ProcessorManagementService;
 import org.apache.james.management.SpoolFilter;
 import org.apache.james.management.SpoolManagementException;
@@ -198,37 +196,8 @@ public abstract class AbstractRemoteMana
 	
 		ManageableDomainList xml = new SimpleDomainList();
 
-		DomainListManagementService domManagement = new DomainListManagementService() {
-
-			private ManageableDomainList domainList;
-
-			public boolean addDomain(String domain)
-					throws DomainListManagementException {
-				return domainList.addDomain(domain);
-			}
-
-			public DomainListManagementService setDomainList(
-					ManageableDomainList xml) {
-				this.domainList = xml;
-				return this;
-			}
-
-			public boolean containsDomain(String domain) {
-				return domainList.containsDomain(domain);
-			}
-
-			public List getDomains() {
-				return domainList.getDomains();
-			}
-
-			public boolean removeDomain(String domain)
-					throws DomainListManagementException {
-				return domainList.removeDomain(domain);
-			}
-
-		}.setDomainList(xml);
-
-		serviceManager.put("domainlistmanagement", domManagement);
+	
+		serviceManager.put("domainlistmanagement", xml);
 		serviceManager.put("bayesiananalyzermanagement",
 				new BayesianAnalyzerManagementService() {
 

Added: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerMBean.java?rev=1021866&view=auto
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerMBean.java (added)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPServerMBean.java Tue Oct 12 18:03:19 2010
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.smtpserver;
+
+import org.apache.james.socket.ServerMBean;
+
+/**
+ * JMX MBean interface for the SMTPServer
+ * 
+ *
+ */
+public interface SMTPServerMBean extends org.apache.james.protocols.smtp.SMTPServerMBean, ServerMBean {
+
+	/**
+	 * Return the maximum allowed size of the message
+	 * 
+	 * @return maxMessageSize
+	 */
+	public long getMaximalMessageSize();
+	
+	/**
+	 * Return true if brackets around addresses in the MAIL and RCPT are required
+	 * 
+	 * @return bracketsEnforcement
+	 */
+	public boolean getAddressBracketsEnforcement();
+	
+	/**
+	 * Return true if a HELO/EHLO is required when connecting to this server
+	 * 
+	 * @return heloEhloEnforcement
+	 */
+	public boolean getHeloEhloEnforcement();
+}



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