directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: rev 56601 - incubator/directory/seda/trunk/src/java/org/apache/seda/listener
Date Thu, 04 Nov 2004 15:57:46 GMT
Author: trustin
Date: Thu Nov  4 07:57:45 2004
New Revision: 56601

Modified:
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
Log:
Made all ClientKey's get(Local|Remote)Address cached not returning KeyExpiryException.

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java	Thu Nov
 4 07:57:45 2004
@@ -50,7 +50,9 @@
 
     /** Unique key or client id */
     private final String clientId;
-
+    private final InetSocketAddress localAddress;
+    private final InetSocketAddress remoteAddress;
+	
     // ----------------------------------------------
     // Constructors
     // ----------------------------------------------
@@ -68,9 +70,11 @@
      *
      * @param clientId the id of this client key
      */
-    ClientKey(String clientId)
+    ClientKey(String clientId, InetSocketAddress localAddress, InetSocketAddress remoteAddress)
     {
         this.clientId = clientId;
+        this.localAddress = localAddress;
+        this.remoteAddress = remoteAddress;
     }
 
     // ----------------------------------------------
@@ -96,19 +100,19 @@
      * Gets the local socket address.
      *
      * @return the local socket address
-     * @throws KeyExpiryException to force the handling of expired keys
      */
-    public abstract InetSocketAddress getLocalAddress()
-                                               throws KeyExpiryException;
+    public final InetSocketAddress getLocalAddress() {
+    	return localAddress;
+    }
 
     /**
      * Gets the client's socket address.
      *
      * @return the client's socket address.
-     * @throws KeyExpiryException to force the handling of expired keys
      */
-    public abstract InetSocketAddress getRemoteAddress()
-                                                throws KeyExpiryException;
+    public final InetSocketAddress getRemoteAddress() {
+    	return remoteAddress;
+    }
 
     // ----------------------------------------------
     // Key expiration methods.

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java	Thu
Nov  4 07:57:45 2004
@@ -74,7 +74,11 @@
      */
     TCPClientKey(final Socket a_socket)
     {
-        super(getClientId(a_socket));
+        super(getClientId(a_socket),
+              new InetSocketAddress(a_socket.getLocalAddress(),
+                                    a_socket.getLocalPort()),
+              new InetSocketAddress(a_socket.getInetAddress(),
+                                    a_socket.getPort()));
         socket = a_socket;
     }
 
@@ -105,21 +109,6 @@
     {
         checkExpiry();
         return socket;
-    }
-
-    public InetSocketAddress getLocalAddress() throws KeyExpiryException
-    {
-        checkExpiry();
-        return new InetSocketAddress(
-                                     socket.getLocalAddress(),
-                                     socket.getLocalPort());
-    }
-
-    public InetSocketAddress getRemoteAddress() throws KeyExpiryException
-    {
-        checkExpiry();
-        return new InetSocketAddress(
-                                     socket.getInetAddress(), socket.getPort());
     }
 
     // ----------------------------------------------

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
Thu Nov  4 07:57:45 2004
@@ -18,15 +18,12 @@
 package org.apache.seda.listener;
 
 import java.io.IOException;
-
 import java.net.InetSocketAddress;
 import java.net.Socket;
-
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
-
 import java.util.EventObject;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -39,8 +36,6 @@
 import org.apache.seda.event.DisconnectSubscriber;
 import org.apache.seda.event.EventFilter;
 import org.apache.seda.event.EventRouter;
-import org.apache.seda.event.ProtocolEvent;
-import org.apache.seda.event.ProtocolSubscriber;
 import org.apache.seda.event.filter.ClientKeyTypeFilter;
 import org.apache.seda.event.filter.CompositeEventFilter;
 import org.apache.seda.event.filter.EventTypeFilter;
@@ -54,8 +49,7 @@
  * @version $Rev$
  */
 public class TCPListenerManager implements DisconnectSubscriber,
-                                           ProtocolSubscriber, ListenerManager,
-                                           Runnable
+                                           ListenerManager, Runnable
 {
     /** event manager used to decouple source to sink relationships */
     private final EventRouter router;
@@ -296,15 +290,6 @@
     public void inform(EventObject event)
     {
         inform((DisconnectEvent) event);
-    }
-
-    /**
-     * Informs this subscriber of a protocol event.
-     *
-     * @param event the protocol event to inform of
-     */
-    public void inform(ProtocolEvent event)
-    {
     }
 
     // ------------------------------------------------------------------------

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java	Thu
Nov  4 07:57:45 2004
@@ -75,18 +75,18 @@
      * @param a_socket newly established client socket connection to the
      * server.
      */
-    UDPClientKey(
-                 final DatagramSocket a_socket,
+    UDPClientKey(final DatagramSocket a_socket,
                  final InetSocketAddress clientAddress)
     {
-        super(getClientId(a_socket, clientAddress));
+        super(getClientId(a_socket, clientAddress),
+              new InetSocketAddress(a_socket.getLocalAddress(),
+                                    a_socket.getLocalPort()), clientAddress);
 
         socket = a_socket;
         this.clientAddress = clientAddress;
     }
 
-    private static String getClientId(
-                                      DatagramSocket a_socket,
+    private static String getClientId(DatagramSocket a_socket,
                                       InetSocketAddress clientAddress)
     {
         // build the key ...
@@ -108,20 +108,6 @@
     {
         checkExpiry();
         return socket;
-    }
-
-    public InetSocketAddress getLocalAddress() throws KeyExpiryException
-    {
-        checkExpiry();
-        return new InetSocketAddress(
-                                     socket.getLocalAddress(),
-                                     socket.getLocalPort());
-    }
-
-    public InetSocketAddress getRemoteAddress() throws KeyExpiryException
-    {
-        checkExpiry();
-        return clientAddress;
     }
 
     // ----------------------------------------------

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
Thu Nov  4 07:57:45 2004
@@ -18,15 +18,12 @@
 package org.apache.seda.listener;
 
 import java.io.IOException;
-
 import java.net.DatagramSocket;
 import java.net.InetSocketAddress;
-
 import java.nio.ByteBuffer;
 import java.nio.channels.DatagramChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
-
 import java.util.EventObject;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -40,8 +37,6 @@
 import org.apache.seda.event.DisconnectSubscriber;
 import org.apache.seda.event.EventRouter;
 import org.apache.seda.event.InputEvent;
-import org.apache.seda.event.ProtocolEvent;
-import org.apache.seda.event.ProtocolSubscriber;
 
 
 /**
@@ -52,8 +47,7 @@
  * @version $Rev$
  */
 public class UDPListenerManager implements DisconnectSubscriber,
-                                           ProtocolSubscriber, ListenerManager,
-                                           Runnable
+                                           ListenerManager, Runnable
 {
     /** event manager used to decouple source to sink relationships */
     private final EventRouter router;
@@ -291,15 +285,6 @@
     public void inform(EventObject event)
     {
         inform((DisconnectEvent) event);
-    }
-
-    /**
-     * Informs this subscriber of a protocol event.
-     *
-     * @param event the protocol event to inform of
-     */
-    public void inform(ProtocolEvent event)
-    {
     }
 
     // ------------------------------------------------------------------------

Mime
View raw message