Author: norman
Date: Tue Mar 22 14:02:37 2011
New Revision: 1084186

URL: http://svn.apache.org/viewvc?rev=1084186&view=rev
Log:
Add support for blocking IO in server components. See JAMES-1209

Added:
    
james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServer.java
    
james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/OioPOP3Server.java
    
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java
    
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServer.java
    
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/OioSMTPServerTest.java
Modified:
    
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
    
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java

Added: 
james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServer.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServer.java?rev=1084186&view=auto
==============================================================================
--- 
james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServer.java
 (added)
+++ 
james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServer.java
 Tue Mar 22 14:02:37 2011
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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 org.jboss.netty.channel.socket.ServerSocketChannelFactory;
+import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
+
+/**
+ * LMTPServer which use old IO and not NIO. If you want to use NIO you should 
use {@link LMTPerver}
+ * 
+ *
+ */
+public class OioLMTPServer extends LMTPServer{
+
+
+    @Override
+    protected ServerSocketChannelFactory createSocketChannelFactory() {
+        return new OioServerSocketChannelFactory(createBossExecutor(), 
createWorkerExecutor());
+    }
+
+    /**
+     * Return -1 as it is not known
+     * 
+     * 
+     */
+    @Override
+    public int getIoWorkerCount() {
+        return -1;
+    }
+
+}

Added: 
james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/OioPOP3Server.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/OioPOP3Server.java?rev=1084186&view=auto
==============================================================================
--- 
james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/OioPOP3Server.java
 (added)
+++ 
james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/netty/OioPOP3Server.java
 Tue Mar 22 14:02:37 2011
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.pop3server.netty;
+
+import org.jboss.netty.channel.socket.ServerSocketChannelFactory;
+import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
+
+/**
+ * POP3Server which use old IO and not NIO. If you want to use NIO you should 
use {@link POP3Server}
+ * 
+ *
+ */
+public class OioPOP3Server extends POP3Server{
+
+
+    @Override
+    protected ServerSocketChannelFactory createSocketChannelFactory() {
+        return new OioServerSocketChannelFactory(createBossExecutor(), 
createWorkerExecutor());
+    }
+
+    /**
+     * Return -1 as it is not known
+     * 
+     * 
+     */
+    @Override
+    public int getIoWorkerCount() {
+        return -1;
+    }
+}

Added: 
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java?rev=1084186&view=auto
==============================================================================
--- 
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java
 (added)
+++ 
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/OioPOP3ServerTest.java
 Tue Mar 22 14:02:37 2011
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.pop3server;
+
+import org.apache.james.pop3server.netty.OioPOP3Server;
+import org.apache.james.pop3server.netty.POP3Server;
+
+public class OioPOP3ServerTest extends POP3ServerTest{
+
+    @Override
+    protected POP3Server createPOP3Server() {
+        return new OioPOP3Server();
+    }
+
+    
+}

Modified: 
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java?rev=1084186&r1=1084185&r2=1084186&view=diff
==============================================================================
--- 
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
 (original)
+++ 
james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
 Tue Mar 22 14:02:37 2011
@@ -79,6 +79,9 @@ public class POP3ServerTest extends Test
 
     private POP3Server m_pop3Server;
 
+    protected POP3Server createPOP3Server() {
+        return new POP3Server();
+    }
     
     protected void initPOP3Server(POP3TestConfiguration testConfiguration) 
throws Exception {
         m_pop3Server.configure(testConfiguration);
@@ -88,7 +91,7 @@ public class POP3ServerTest extends Test
     
     protected void setUpPOP3Server() throws Exception {
         
-        m_pop3Server = new POP3Server();
+        m_pop3Server = createPOP3Server();
         m_pop3Server.setDNSService(dnsservice);
         m_pop3Server.setFileSystem(fSystem);
         m_pop3Server.setProtocolHandlerChain(chain);

Added: 
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServer.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServer.java?rev=1084186&view=auto
==============================================================================
--- 
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServer.java
 (added)
+++ 
james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServer.java
 Tue Mar 22 14:02:37 2011
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.netty;
+
+import org.jboss.netty.channel.socket.ServerSocketChannelFactory;
+import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
+
+/**
+ * SMTPServer which use old IO and not NIO. If you want to use NIO you should 
use {@link SMTPServer}
+ * 
+ *
+ */
+public class OioSMTPServer extends SMTPServer{
+
+    @Override
+    protected ServerSocketChannelFactory createSocketChannelFactory() {
+        return new OioServerSocketChannelFactory(createBossExecutor(), 
createWorkerExecutor());
+    }
+
+    /**
+     * Return -1 as it is not known
+     * 
+     * 
+     */
+    @Override
+    public int getIoWorkerCount() {
+        return -1;
+    }
+
+}

Added: 
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/OioSMTPServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/OioSMTPServerTest.java?rev=1084186&view=auto
==============================================================================
--- 
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/OioSMTPServerTest.java
 (added)
+++ 
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/OioSMTPServerTest.java
 Tue Mar 22 14:02:37 2011
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.smtpserver.netty.OioSMTPServer;
+import org.apache.james.smtpserver.netty.SMTPServer;
+
+public class OioSMTPServerTest extends SMTPServerTest{
+
+    @Override
+    protected SMTPServer createSMTPServer() {
+        return new OioSMTPServer();
+    }
+    
+    /**
+     * TODO: This should not be needed
+     */
+    public void testConnectionLimit() throws Exception {
+        // TODO: Check why the connection limit is not working with IO 
implementation
+    }
+}

Modified: 
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java?rev=1084186&r1=1084185&r2=1084186&view=diff
==============================================================================
--- 
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 (original)
+++ 
james/server/trunk/smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 Tue Mar 22 14:02:37 2011
@@ -181,11 +181,14 @@ public abstract class SMTPServerTest ext
       
     }
 
+    protected SMTPServer createSMTPServer() {
+        return new SMTPServer();
+    }
     protected void setUpSMTPServer() throws Exception {
         Logger log = LoggerFactory.getLogger("SMTP");
         // slf4j can't set programmatically any log level. It's just a facade
         // log.setLevel(SimpleLog.LOG_LEVEL_ALL);
-        m_smtpServer = new SMTPServer();
+        m_smtpServer = createSMTPServer();
         m_smtpServer.setDNSService(m_dnsServer);
         m_smtpServer.setFileSystem(fileSystem);      
         



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to