You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by jv...@apache.org on 2012/05/21 20:58:58 UTC

svn commit: r1341145 - in /mina/trunk/core/src/main/java/org/apache/mina: api/IoService.java service/AbstractIoService.java service/IoHandler.java transport/tcp/nio/NioTcpServer.java transport/udp/nio/NioUdpServer.java

Author: jvermillard
Date: Mon May 21 18:58:57 2012
New Revision: 1341145

URL: http://svn.apache.org/viewvc?rev=1341145&view=rev
Log:
removed useless IoHandler

Removed:
    mina/trunk/core/src/main/java/org/apache/mina/service/IoHandler.java
Modified:
    mina/trunk/core/src/main/java/org/apache/mina/api/IoService.java
    mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java
    mina/trunk/core/src/main/java/org/apache/mina/transport/tcp/nio/NioTcpServer.java
    mina/trunk/core/src/main/java/org/apache/mina/transport/udp/nio/NioUdpServer.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/api/IoService.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/api/IoService.java?rev=1341145&r1=1341144&r2=1341145&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/api/IoService.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/api/IoService.java Mon May 21 18:58:57 2012
@@ -21,8 +21,6 @@ package org.apache.mina.api;
 
 import java.util.Map;
 
-import org.apache.mina.service.IoHandler;
-
 /**
  * Base interface for all {@link IoServer}s and {@link IoClient}s that provide I/O service 
  * and manage {@link IoSession}s.
@@ -53,21 +51,6 @@ public interface IoService {
     void removeListeners(IoServiceListener... listeners);
 
     /**
-     * Returns the handler which will handle all the connections managed by this service.
-     * 
-     * @return The {@link IoService} {@link IoHandler}
-     */
-    IoHandler getHandler();
-
-    /**
-     * Sets the handler which will handle all connections managed by this service. The handler can 
-     * only be set before the service is started. We can have only one {@link IoHandler} per service.
-     * 
-     * @param handler The {@link IoHandler} associated with this service
-     */
-    void setHandler(IoHandler handler);
-
-    /**
      * Get the list of filters installed on this service
      * 
      * @return The list of installed filters

Modified: mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java?rev=1341145&r1=1341144&r2=1341145&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java Mon May 21 18:58:57 2012
@@ -47,11 +47,6 @@ public abstract class AbstractIoService 
     private final Map<Long, IoSession> managedSessions = new ConcurrentHashMap<Long, IoSession>();
 
     /**
-     * The handler, the interface with the application part.
-     */
-    private IoHandler handler;
-
-    /**
      * Placeholder for storing all the listeners added
      */
     private final List<IoServiceListener> listeners = new CopyOnWriteArrayList<IoServiceListener>();
@@ -127,32 +122,6 @@ public abstract class AbstractIoService 
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    public final IoHandler getHandler() {
-        return this.handler;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public final void setHandler(final IoHandler handler) {
-        if (handler == null) {
-            throw new IllegalArgumentException("handler cannot be null");
-        }
-
-        // TODO: check the service state, we should not be able to set the handler
-        // if the service is already started
-        /*
-         * if (isActive()) { throw new IllegalStateException( "handler cannot be set while the service is active."); }
-         */
-
-        this.handler = handler;
-    }
-
-    /**
      * @return true if the IoService is active
      */
     public boolean isActive() {

Modified: mina/trunk/core/src/main/java/org/apache/mina/transport/tcp/nio/NioTcpServer.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/transport/tcp/nio/NioTcpServer.java?rev=1341145&r1=1341144&r2=1341145&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/transport/tcp/nio/NioTcpServer.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/transport/tcp/nio/NioTcpServer.java Mon May 21 18:58:57 2012
@@ -57,6 +57,9 @@ public class NioTcpServer extends Abstra
         this.config = new DefaultSocketSessionConfig();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public SocketSessionConfig getSessionConfig() {
         return this.config;
@@ -66,16 +69,25 @@ public class NioTcpServer extends Abstra
         this.config = config;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void setReuseAddress(final boolean reuseAddress) {
         this.reuseAddress = reuseAddress;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean isReuseAddress() {
         return this.reuseAddress;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void bind(final SocketAddress... localAddress) throws IOException {
         if (localAddress == null) {
@@ -103,11 +115,17 @@ public class NioTcpServer extends Abstra
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public Set<SocketAddress> getLocalAddresses() {
         return this.addresses;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void unbind(final SocketAddress... localAddresses) throws IOException {
         for (SocketAddress socketAddress : localAddresses) {
@@ -122,6 +140,9 @@ public class NioTcpServer extends Abstra
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void unbindAll() throws IOException {
         for (SocketAddress socketAddress : this.addresses) {

Modified: mina/trunk/core/src/main/java/org/apache/mina/transport/udp/nio/NioUdpServer.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/transport/udp/nio/NioUdpServer.java?rev=1341145&r1=1341144&r2=1341145&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/transport/udp/nio/NioUdpServer.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/transport/udp/nio/NioUdpServer.java Mon May 21 18:58:57 2012
@@ -19,22 +19,43 @@
  */
 package org.apache.mina.transport.udp.nio;
 
+import java.net.SocketAddress;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.mina.api.IoSessionConfig;
+import org.apache.mina.service.SelectorStrategy;
 import org.apache.mina.transport.udp.AbstractUdpServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * TODO
+ * This class implements a UDP NIO based server.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
 public class NioUdpServer extends AbstractUdpServer {
+	
+	static final Logger LOG = LoggerFactory.getLogger(NioUdpServer.class);
+
+    // list of bound addresses
+    private final Set<SocketAddress> addresses = Collections.synchronizedSet(new HashSet<SocketAddress>());
+
+    // the strategy for dispatching servers and client to selector threads.
+    private final SelectorStrategy strategy;
+
     /**
      * Create a new instance of NioUdpServer
      */
-    public NioUdpServer() {
+    public NioUdpServer(final SelectorStrategy strategy) {
         super();
+        this.strategy = strategy;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public IoSessionConfig getSessionConfig() {
         // TODO Auto-generated method stub