directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: rev 56608 - incubator/directory/seda/trunk/src/java/org/apache/seda/output
Date Thu, 04 Nov 2004 16:49:47 GMT
Author: trustin
Date: Thu Nov  4 08:49:47 2004
New Revision: 56608

Modified:
   incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
Log:
UDPOutputManager does not listen to Connect/Disconnect events anymore because they are not
needed.

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java	Thu
Nov  4 08:49:47 2004
@@ -19,16 +19,9 @@
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.nio.channels.DatagramChannel;
 import java.util.EventObject;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.seda.event.AbstractSubscriber;
-import org.apache.seda.event.ConnectEvent;
-import org.apache.seda.event.ConnectSubscriber;
-import org.apache.seda.event.DisconnectEvent;
-import org.apache.seda.event.DisconnectSubscriber;
 import org.apache.seda.event.EventFilter;
 import org.apache.seda.event.EventRouter;
 import org.apache.seda.event.OutputEvent;
@@ -37,7 +30,6 @@
 import org.apache.seda.event.filter.CompositeEventFilter;
 import org.apache.seda.event.filter.EventTypeFilter;
 import org.apache.seda.listener.ClientKey;
-import org.apache.seda.listener.KeyExpiryException;
 import org.apache.seda.listener.UDPClientKey;
 import org.apache.seda.stage.DefaultStage;
 import org.apache.seda.stage.DefaultStageConfig;
@@ -52,9 +44,7 @@
  * @version $Rev$
  */
 public class UDPOutputManager extends DefaultStage implements OutputManager,
-                                                              OutputSubscriber,
-                                                              ConnectSubscriber,
-                                                              DisconnectSubscriber
+                                                              OutputSubscriber
 {
     /** the router we subscribe for OutputEvents on */
     private final EventRouter router;
@@ -62,9 +52,6 @@
     /** the monitor used to track notable events in this OutputManager */
     private OutputMonitor monitor;
 
-    /** a map of channels by ClientKey */
-    private Map channels = new HashMap();
-
     // ------------------------------------------------------------------------
     // constructors
     // ------------------------------------------------------------------------
@@ -118,36 +105,6 @@
         enqueue(event);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.seda.event.ConnectSubscriber#inform(
-     * org.apache.seda.event.ConnectEvent)
-     */
-    public void inform(ConnectEvent event)
-    {
-        UDPClientKey key = (UDPClientKey) event.getClientKey();
-
-        try
-        {
-            channels.put(key, key.getSocket().getChannel());
-        }
-        catch (KeyExpiryException e)
-        {
-            monitor.keyExpired(this, key, e);
-        }
-
-        monitor.addedClient(this, event);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.seda.event.DisconnectSubscriber#inform(
-     * org.apache.seda.event.DisconnectEvent)
-     */
-    public void inform(DisconnectEvent event)
-    {
-        channels.remove(event.getClientKey());
-        monitor.removedClient(this, event);
-    }
-
     // ------------------------------------------------------------------------
     // OutputManager method
     // ------------------------------------------------------------------------
@@ -160,15 +117,8 @@
     public void write(ClientKey key, ByteBuffer buf)
                throws IOException
     {
-        DatagramChannel channel = (DatagramChannel) channels.get(key);
-
-        if (null == channel)
-        {
-            monitor.channelMissing(this, key);
-            return;
-        }
-
-        channel.send(buf, key.getRemoteAddress());
+    	UDPClientKey udpKey = (UDPClientKey) key;
+        udpKey.getSocket().getChannel().send(buf, key.getRemoteAddress());
         monitor.writeOccurred(this, key);
     }
 

Mime
View raw message