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 2011/12/23 21:56:11 UTC

svn commit: r1222839 - in /james/protocols/trunk: api/src/main/java/org/apache/james/protocols/api/ProtocolServer.java netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java

Author: norman
Date: Fri Dec 23 20:56:11 2011
New Revision: 1222839

URL: http://svn.apache.org/viewvc?rev=1222839&view=rev
Log:
Add ProtocolServer interface

Added:
    james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolServer.java   (with props)
Modified:
    james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java

Added: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolServer.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolServer.java?rev=1222839&view=auto
==============================================================================
--- james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolServer.java (added)
+++ james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolServer.java Fri Dec 23 20:56:11 2011
@@ -0,0 +1,65 @@
+/****************************************************************
+ * 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.protocols.api;
+
+import java.net.InetSocketAddress;
+import java.util.List;
+
+public interface ProtocolServer {
+
+    /**
+     * Start the server
+     * 
+     * @throws Exception 
+     * 
+     */
+    void bind() throws Exception;
+    
+    /**
+     * Stop the server
+     */
+    void unbind();
+    
+    /**
+     * return true if the server is bound 
+     * 
+     * @return bound
+     */
+    boolean isBound();
+
+    /**
+     * Return the read/write timeout in seconds for the socket.
+     * @return the timeout
+     */
+    int  getTimeout();
+    
+    /**
+     * Return the backlog for the socket
+     * 
+     * @return backlog
+     */
+    int getBacklog();
+    
+    /**
+     * Return the ips on which the server listen for connections
+     * 
+     * @return ips
+     */
+    List<InetSocketAddress> getListenAddresses();
+}

Propchange: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java?rev=1222839&r1=1222838&r2=1222839&view=diff
==============================================================================
--- james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java (original)
+++ james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java Fri Dec 23 20:56:11 2011
@@ -26,6 +26,8 @@ import java.util.List;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
 
+import org.apache.james.protocols.api.ProtocolServer;
+import org.apache.james.protocols.api.ProtocolSession;
 import org.jboss.netty.bootstrap.ServerBootstrap;
 import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.group.ChannelGroup;
@@ -38,7 +40,7 @@ import org.jboss.netty.util.ExternalReso
  * Abstract base class for Servers which want to use async io
  *
  */
-public abstract class AbstractAsyncServer {
+public abstract class AbstractAsyncServer implements ProtocolServer{
 
     public static final int DEFAULT_IO_WORKER_COUNT = Runtime.getRuntime().availableProcessors() * 2;
     private volatile int backlog = 250;
@@ -79,11 +81,10 @@ public abstract class AbstractAsyncServe
         return ioWorker;
     }
     
-    /**
-     * Start the server
-     * 
-     * @throws Exception 
-     * 
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolServer#bind()
      */
     public synchronized void bind() throws Exception {
         if (started) throw new IllegalStateException("Server running already");
@@ -120,8 +121,10 @@ public abstract class AbstractAsyncServe
         return new NioServerSocketChannelFactory(createBossExecutor(), createWorkerExecutor(), ioWorker);
     }
     
-    /**
-     * Stop the server
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolServer#unbind()
      */
     public synchronized void unbind() {
         if (started == false) return;
@@ -136,10 +139,11 @@ public abstract class AbstractAsyncServe
     
     
     
-    /**
-     * Return the ip on which the server listen for connections
-     * 
-     * @return ip
+
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolServer#getListenAddresses()
      */
     public synchronized List<InetSocketAddress> getListenAddresses() {
         return addresses;
@@ -175,18 +179,19 @@ public abstract class AbstractAsyncServe
         this.backlog = backlog;
     }
     
-    /**
-     * Return the backlog for the socket
-     * 
-     * @return backlog
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolServer#getBacklog()
      */
     public int getBacklog() {
         return backlog;
     }
     
-    /**
-     * Return the read/write timeout for the socket.
-     * @return the set timeout
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolServer#getTimeout()
      */
     public int getTimeout() {
         return timeout;
@@ -211,10 +216,10 @@ public abstract class AbstractAsyncServe
         return Executors.newCachedThreadPool();
     }
     
-    /**
-     * return true if the server is bound 
-     * 
-     * @return bound
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolServer#isBound()
      */
     public boolean isBound() {
         return started;



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