directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: rev 55338 - in incubator/directory/seda/trunk/src/java/org/apache/seda: . listener output
Date Sat, 23 Oct 2004 00:29:41 GMT
Author: trustin
Date: Fri Oct 22 17:29:41 2004
New Revision: 55338

Added:
   incubator/directory/seda/trunk/src/java/org/apache/seda/output/TCPOutputManager.java
      - copied, changed from rev 55337, incubator/directory/seda/trunk/src/java/org/apache/seda/output/DefaultOutputManager.java
Removed:
   incubator/directory/seda/trunk/src/java/org/apache/seda/output/DefaultOutputManager.java
Modified:
   incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.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/UDPListenerConfig.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
Log:
* Reformatted listener package with Jalopy
* Renamed DefaultOutputManager to TCPOutputManager


Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java	Fri Oct 22 17:29:41 2004
@@ -29,7 +29,7 @@
 import org.apache.seda.listener.ListenerManager;
 import org.apache.seda.listener.TCPListenerManager;
 import org.apache.seda.output.OutputManager;
-import org.apache.seda.output.DefaultOutputManager;
+import org.apache.seda.output.TCPOutputManager;
 import org.apache.seda.protocol.RequestProcessor;
 import org.apache.seda.protocol.InetServicesDatabase;
 import org.apache.seda.protocol.DefaultRequestProcessor;
@@ -86,7 +86,7 @@
     {
         ( ( TCPListenerManager ) srvMan ).stop();
         ( ( TCPInputManager ) inMan ).stop();
-        ( ( DefaultOutputManager ) outMan ).stop();
+        ( ( TCPOutputManager ) outMan ).stop();
         ( ( DefaultRequestProcessor ) reqProc ).stop();
         ( ( DefaultDecoderManager ) decMan ).stop();
         ( ( DefaultEncoderManager ) encMan ).stop();

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java	Fri Oct 22 17:29:41 2004
@@ -38,7 +38,7 @@
 import org.apache.seda.input.InputManager;
 import org.apache.seda.input.TCPInputManager;
 import org.apache.seda.output.OutputManager;
-import org.apache.seda.output.DefaultOutputManager;
+import org.apache.seda.output.TCPOutputManager;
 import org.apache.commons.threadpool.DefaultThreadPool;
 import org.apache.commons.threadpool.CommonsLoggingThreadPoolMonitor;
 
@@ -182,7 +182,7 @@
     {
         DefaultStageConfig config = new DefaultStageConfig( "outputManager",
             createThreadPool( 3 ) );
-        DefaultOutputManager outMan = new DefaultOutputManager( router, config );
+        TCPOutputManager outMan = new TCPOutputManager( router, config );
         outMan.start();
         return outMan;
     }

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java	Fri Oct 22 17:29:41 2004
@@ -16,12 +16,13 @@
  */
 package org.apache.seda.listener;
 
+import java.io.IOException;
+
+import java.net.ServerSocket;
 
+import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.NoSuchElementException;
-import java.net.ServerSocket;
-import java.io.IOException;
 
 
 /**
@@ -33,7 +34,6 @@
  * @see <a href="http://www.iana.org/assignments/port-numbers">IANA.org</a>
  */
 public class AvailablePortFinder {
-
     /**
      * The minimum number of server port number.
      */
@@ -44,15 +44,12 @@
      */
     public static final int MAX_PORT_NUMBER = 49151;
 
-
     /**
      * Creates a new instance.
      */
-    public AvailablePortFinder()
-    {
+    public AvailablePortFinder() {
     }
 
-
     /**
      * Returns the {@link Set} of currently available port numbers
      * ({@link Integer}).  This method is identical to
@@ -60,70 +57,53 @@
      *
      * WARNING: this can take a very long time.
      */
-    public Set getAvailablePorts()
-    {
-        return getAvailablePorts( MIN_PORT_NUMBER, MAX_PORT_NUMBER ) ;
+    public Set getAvailablePorts() {
+        return getAvailablePorts(MIN_PORT_NUMBER, MAX_PORT_NUMBER);
     }
 
-
     /**
      * Gets the next available port starting at the lowest port number.
      *
      * @throws NoSuchElementException if there are no ports available
      */
-    public static int getNextAvailable()
-    {
-        return getNextAvailable( MIN_PORT_NUMBER );
+    public static int getNextAvailable() {
+        return getNextAvailable(MIN_PORT_NUMBER);
     }
 
-
     /**
      * Gets the next available port starting at a port.
      *
      * @param fromPort the port to scan for availability
      * @throws NoSuchElementException if there are no ports available
      */
-    public static int getNextAvailable( int fromPort )
-    {
-        if ( fromPort < MIN_PORT_NUMBER || fromPort > MAX_PORT_NUMBER )
-        {
-            throw new IllegalArgumentException( "Invalid start port: " +
-                fromPort );
+    public static int getNextAvailable(int fromPort) {
+        if ((fromPort < MIN_PORT_NUMBER) || (fromPort > MAX_PORT_NUMBER)) {
+            throw new IllegalArgumentException("Invalid start port: "
+                                               + fromPort);
         }
 
-        for ( int i = fromPort; i <= MAX_PORT_NUMBER; i++ )
-        {
+        for (int i = fromPort; i <= MAX_PORT_NUMBER; i++) {
             ServerSocket s = null;
 
-            try
-            {
-                s = new ServerSocket( i );
+            try {
+                s = new ServerSocket(i);
                 return i;
-            }
-            catch ( IOException e )
-            {
-            }
-            finally
-            {
-                if ( s != null )
-                {
-                    try
-                    {
+            } catch (IOException e) {
+            } finally {
+                if (s != null) {
+                    try {
                         s.close();
-                    }
-                    catch ( IOException e )
-                    {
+                    } catch (IOException e) {
                         /* should not be thrown */
                     }
                 }
             }
         }
 
-        throw new NoSuchElementException( "Could not find an available port " +
-            "above " + fromPort );
+        throw new NoSuchElementException("Could not find an available port "
+                                         + "above " + fromPort);
     }
 
-
     /**
      * Returns the {@link Set} of currently avaliable port numbers ({@link Integer})
      * between the specified port range.
@@ -132,40 +112,27 @@
      * {@link #MIN_PORT_NUMBER} and {@link #MAX_PORT_NUMBER} or
      * <code>fromPort</code> if greater than <code>toPort</code>.
      */
-    public Set getAvailablePorts( int fromPort, int toPort )
-    {
-        if ( fromPort < MIN_PORT_NUMBER ||
-            toPort > MAX_PORT_NUMBER ||
-            fromPort > toPort )
-        {
-            throw new IllegalArgumentException( "Invalid port range: " +
-                fromPort + " ~ " + toPort );
+    public Set getAvailablePorts(int fromPort, int toPort) {
+        if ((fromPort < MIN_PORT_NUMBER) || (toPort > MAX_PORT_NUMBER)
+                || (fromPort > toPort)) {
+            throw new IllegalArgumentException("Invalid port range: "
+                                               + fromPort + " ~ " + toPort);
         }
 
         Set result = new TreeSet();
 
-        for ( int i = fromPort; i <= toPort; i++ )
-        {
+        for (int i = fromPort; i <= toPort; i++) {
             ServerSocket s = null;
 
-            try
-            {
-                s = new ServerSocket( i );
-                result.add( new Integer( i ) );
-            }
-            catch ( IOException e )
-            {
-            }
-            finally
-            {
-                if ( s != null )
-                {
-                    try
-                    {
+            try {
+                s = new ServerSocket(i);
+                result.add(new Integer(i));
+            } catch (IOException e) {
+            } finally {
+                if (s != null) {
+                    try {
                         s.close();
-                    }
-                    catch ( IOException e )
-                    {
+                    } catch (IOException e) {
                         /* should not be thrown */
                     }
                 }

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	Fri Oct 22 17:29:41 2004
@@ -16,15 +16,15 @@
  */
 package org.apache.seda.listener;
 
-
 import java.io.IOException;
+
 import java.net.InetSocketAddress;
 
 
 /**
  * Every client that successfully binds anonymously or with a valid identity
- * has a unique client key represented by this class.  The key uniquely 
- * identifies the client based on the connection parameters: interface and port 
+ * has a unique client key represented by this class.  The key uniquely
+ * identifies the client based on the connection parameters: interface and port
  * used on the server as well as the interface and port used by the client.
  * <p>
  * The ClientKey plays a central role in coordinating activities with the
@@ -33,32 +33,31 @@
  * ClientKey instance.  Socket IO is managed using a pair of lock objects
  * specificially for this purpose.
  * </p>
- * 
+ *
  * @todo do we really need these lock objects?
  * @todo why are we carrying around the damn socket?
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public abstract class ClientKey
-{
+public abstract class ClientKey {
     // ----------------------------------------------
     // Private members.
     // ----------------------------------------------
 
     /** Input channel synchronization object */
     private final Object inputLock = new Object();
+
     /** Output channel synchronization object */
     private final Object outputLock = new Object();
+
     /** Unique key or client id */
     private final String clientId;
 
-
     // ----------------------------------------------
     // Constructors
     // ----------------------------------------------
 
-
     /**
       * Generates a unique connection/client identifier String for a client
       * socket connection.  The key is composed of the local server address
@@ -72,17 +71,14 @@
       *
       * @param clientId the id of this client key
       */
-    ClientKey( String clientId )
-    {
+    ClientKey(String clientId) {
         this.clientId = clientId;
     }
 
-
     // ----------------------------------------------
     // Accessors of conn. parameters to client id
     // ----------------------------------------------
 
-    
     /**
      * Get the unique client id for a connected client based on connection
      * parameters.
@@ -92,66 +88,59 @@
      * than depending on developers to maintain a convention of checking for
      * key expiration before use in other modules.
      */
-    public final String getClientId() throws KeyExpiryException
-    {
+    public final String getClientId() throws KeyExpiryException {
         checkExpiry();
         return clientId;
     }
-    
+
     /**
      * 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 abstract InetSocketAddress getLocalAddress()
+                                               throws KeyExpiryException;
+
     /**
      * 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 abstract InetSocketAddress getRemoteAddress()
+                                                throws KeyExpiryException;
 
     // ----------------------------------------------
     // ClientKey lock object accessors.
     // ----------------------------------------------
 
-
     /**
      * Gets the client's output stream lock object.
      *
      * @return ouput lock object.
      * @throws KeyExpiryException to force the handling of expired keys
      */
-    public final Object getOutputLock() throws KeyExpiryException
-    {
+    public final Object getOutputLock() throws KeyExpiryException {
         checkExpiry();
         return outputLock;
     }
 
-
     /**
      * Gets the client's input stream lock object.
      *
      * @return input lock object.
      * @throws KeyExpiryException to force the handling of expired keys
      */
-    public final Object getInputLock() throws KeyExpiryException
-    {
+    public final Object getInputLock() throws KeyExpiryException {
         checkExpiry();
         return inputLock;
     }
 
-
     // ----------------------------------------------
     // Key expiration methods.
     // ----------------------------------------------
 
-
     /**
      * Determines if the client represented by this ClientKey is still
      * connected to the server.  Once disconnected the ClientKey is expired
@@ -162,7 +151,6 @@
      */
     public abstract boolean hasExpired();
 
-
     /**
      * Expires this key to indicate the disconnection of the client represented
      * by this key from the server.  It is intentionally package friendly to
@@ -171,7 +159,6 @@
      */
     protected abstract void expire() throws IOException;
 
-
     /**
      * Utility method to throw key expiration exception if this ClientKey has
      * expired.  This method is called by most accessor methods within this
@@ -179,42 +166,36 @@
      * purpose for this is to force ClientKey using modules to check for
      * expiration rather rely upon them to check to see if the key is valid
      * before use everytime.
-     * 
+     *
      * @throws KeyExpiryException to force the handling of expired keys rather
      * than depending on developers to maintain a convention of checking for
      * key expiration before use in other modules.
      */
     protected abstract void checkExpiry() throws KeyExpiryException;
 
-
     // ----------------------------------------------
     // Class java.lang.Object method overrides.
     // ----------------------------------------------
 
-
     /**
      * For debugging returns the clientId string.
      *
      * @return the client id string.
      */
-    public final String toString()
-    {
+    public final String toString() {
         return clientId;
     }
 
-
     /**
      * Gets the hashCode of the unique clientId String.  Overriden to correctly
      * manage ClientKey's within Map based collections.
      *
      * @return the clientId hashCode value.
      */
-    public final int hashCode()
-    {
+    public final int hashCode() {
         return clientId.hashCode();
     }
 
-
     /**
      * Determines whether this ClientKey is equivalent to another.  If argument
      * object is not the same reference the clientId String's are compared using
@@ -225,23 +206,15 @@
      *
      * @return true if an_obj equals this ClientKey, false otherwise.
      */
-    public final boolean equals( Object an_obj )
-    {
-        if( this == an_obj ) 
-        {
+    public final boolean equals(Object an_obj) {
+        if (this == an_obj) {
             return true;
-        } 
-        else if( an_obj instanceof String )
-        {
-            return clientId.equals( an_obj );
-        }
-        else if( an_obj instanceof ClientKey ) 
-        {
-            return ( ( ClientKey ) an_obj ).clientId.equals( clientId );
-        }
-        else
-        {
-            return clientId.equals( an_obj.toString() );
+        } else if (an_obj instanceof String) {
+            return clientId.equals(an_obj);
+        } else if (an_obj instanceof ClientKey) {
+            return ((ClientKey) an_obj).clientId.equals(clientId);
+        } else {
+            return clientId.equals(an_obj.toString());
         }
     }
 }

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java	Fri Oct 22 17:29:41 2004
@@ -16,54 +16,47 @@
  */
 package org.apache.seda.listener;
 
-
 import java.io.IOException;
 
 
 /**
  * An exception that is raised when the accessor methods on an expired ClientKey
  * are used.
- * 
+ *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class KeyExpiryException extends IOException
-{
+public class KeyExpiryException extends IOException {
     /** the key that caused this exception by being accessed after expiring */
     private final ClientKey key;
-    
-    /** 
+
+    /**
      * Constructs an Exception without a message.
-     * 
+     *
      * @param key the unique key for the client which expired.
      */
-    public KeyExpiryException( ClientKey key )
-    {
+    public KeyExpiryException(ClientKey key) {
         super();
         this.key = key;
     }
 
-    
     /**
      * Constructs an Exception with a detailed message.
-     * 
+     *
      * @param key the unique key for the client which expired.
      * @param message The message associated with the exception.
      */
-    public KeyExpiryException( ClientKey key, String message )
-    {
-        super( message );
+    public KeyExpiryException(ClientKey key, String message) {
+        super(message);
         this.key = key;
     }
 
-
     /**
      * Gets the expired key which caused this exception when it was accessed.
-     * 
+     *
      * @return the expired ClientKey.
      */
-    public ClientKey getClientKey()
-    {
+    public ClientKey getClientKey() {
         return key;
     }
 }

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java	Fri Oct 22 17:29:41 2004
@@ -17,26 +17,22 @@
 package org.apache.seda.listener;
 
 
-
-
-
 /**
  * A server listener configuration interface.
- * 
+ *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public abstract class ListenerConfig
-{
+public abstract class ListenerConfig {
     /**
      * Empty default constructor.
      */
-	protected ListenerConfig() {
-	}
+    protected ListenerConfig() {
+    }
 
     /**
      * Gets the URI for this ListenerConfig using the specified ip address and
-     * the tcp port number listened to.  The ipaddress is resolved to a host 
+     * the tcp port number listened to.  The ipaddress is resolved to a host
      * name.
      *
      * @return the URI with scheme like so ldap://localhost:389

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java	Fri Oct 22 17:29:41 2004
@@ -16,31 +16,31 @@
  */
 package org.apache.seda.listener;
 
-
 import java.io.IOException;
 
 
 /**
  * Manages a set of server listeners.
- * 
+ *
  * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
  * @author $Author$
  * @version $Rev$
  */
-public interface ListenerManager
-{
+public interface ListenerManager {
     /**
      * Binds and registers a server listener.
-     * 
+     *
      * @param listenerConfig the listener to register and bind
      */
-    public void bind( ListenerConfig listenerConfig ) throws IOException;
-    
+    public void bind(ListenerConfig listenerConfig)
+              throws IOException;
+
     /**
      * Unbinds and unregisters a server listener.
-     * 
+     *
      * @param listenerConfig the listener to unregister and unbind
      * @throws IOException if there is a problem unbinding a listener
      */
-    public void unbind( ListenerConfig listenerConfig ) throws IOException;
+    public void unbind(ListenerConfig listenerConfig)
+                throws IOException;
 }

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java	Fri Oct 22 17:29:41 2004
@@ -16,15 +16,15 @@
  */
 package org.apache.seda.listener;
 
-
 import java.io.IOException;
-import java.nio.channels.Selector;
+
 import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
 
 
 /**
  * Used to monitor the activities of a ListenerManager.
- * 
+ *
  * @todo why the heck does this interface references to an implementation object
  * like a Selector?
  *
@@ -32,13 +32,12 @@
  * @author $Author$
  * @version $Rev$
  */
-public interface ListenerManagerMonitor
-{
+public interface ListenerManagerMonitor {
     /**
      * Monitors when the ListnenerManager starts.
      */
     void started();
-    
+
     /**
      * Monitors when the ListnenerManager stops.
      */
@@ -46,83 +45,83 @@
 
     /**
      * Monitors bind occurences.
-     * 
+     *
      * @param listenerConfig the listener just bound to a port
      */
-    void bindOccured( ListenerConfig listenerConfig );
-    
+    void bindOccured(ListenerConfig listenerConfig);
+
     /**
      * Monitors unbind occurences.
-     * 
+     *
      * @param listenerConfig the listener just unbound from a port
      */
-    void unbindOccured( ListenerConfig listenerConfig );
-    
+    void unbindOccured(ListenerConfig listenerConfig);
+
     /**
      * Monitors the occurrence of successful socket accept attempts
-     * 
+     *
      * @param key
      */
-    void acceptOccured( SelectionKey key );
-    
+    void acceptOccured(SelectionKey key);
+
     /**
      * Monitors the occurrence of successful select calls on a selector
-     * 
+     *
      * @param selector
      */
-    void selectOccured( Selector selector );
-    
+    void selectOccured(Selector selector);
+
     /**
      * Monitors the occurrence of successful select timeouts on a selector
-     * 
+     *
      * @param selector
      */
-    void selectTimedOut( Selector selector );
-    
+    void selectTimedOut(Selector selector);
+
     /**
      * Monitors bind failures.
-     * 
+     *
      * @param listenerConfig the listener whose bind attempt failed
      * @param failure the exception resulting from the failure
      */
-    void failedToBind( ListenerConfig listenerConfig, IOException failure );
-    
+    void failedToBind(ListenerConfig listenerConfig, IOException failure);
+
     /**
      * Monitors unbind failures.
-     * 
+     *
      * @param listenerConfig the listener whose unbind attempt failed
      * @param failure the exception resulting from the failure
      */
-    void failedToUnbind( ListenerConfig listenerConfig, IOException failure );
-    
+    void failedToUnbind(ListenerConfig listenerConfig, IOException failure);
+
     /**
      * Monitors expiration failures on client keys.
-     * 
+     *
      * @param key the client key that caused the failure
      * @param failure the exception resulting from the failure
      */
-    void failedToExpire( ClientKey key, IOException failure );
-    
+    void failedToExpire(ClientKey key, IOException failure);
+
     /**
      * Monitors accept failures on socket channels.
-     * 
+     *
      * @param key the selector key associated with the channel
      * @param failure the exception resulting from the failure
      */
-    void failedToAccept( SelectionKey key, IOException failure );
-    
+    void failedToAccept(SelectionKey key, IOException failure);
+
     /**
      * Monitors select failures on a selector.
-     * 
+     *
      * @param selector the selector on which the select failed
      * @param failure the exception resulting from the failure
      */
-    void failedToSelect( Selector selector, IOException failure );
-    
+    void failedToSelect(Selector selector, IOException failure);
+
     /**
      * A select call is about to be made.
      *
      * @param selector the selector on which the select is called
      */
-    void enteringSelect( Selector selector );
+    void enteringSelect(Selector selector);
 }

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java	Fri Oct 22 17:29:41 2004
@@ -1,102 +1,86 @@
-/*
- *   Copyright 2004 The Apache Software Foundation
- *
- *   Licensed 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.seda.listener;
-
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.io.IOException;
-
-/**
- * An null do nothing adapter for the listener manager.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class ListenerManagerMonitorAdapter implements ListenerManagerMonitor
-{
-    public void started()
-    {
-    }
-
-    public void stopped()
-    {
-    }
-
-    public void bindOccured( ListenerConfig listenerConfig )
-    {
-    }
-
-    public void unbindOccured( ListenerConfig listenerConfig )
-    {
-    }
-
-    public void acceptOccured( SelectionKey key )
-    {
-    }
-
-    public void selectOccured( Selector selector )
-    {
-    }
-
-    public void selectTimedOut( Selector selector )
-    {
-    }
-
-    public void failedToBind( ListenerConfig listenerConfig, IOException failure )
-    {
-        if ( failure != null )
-        {
-            failure.printStackTrace();
-        }
-    }
-
-    public void failedToUnbind( ListenerConfig listenerConfig, IOException failure )
-    {
-        if ( failure != null )
-        {
-            failure.printStackTrace();
-        }
-    }
-
-    public void failedToExpire( ClientKey key, IOException failure )
-    {
-        if ( failure != null )
-        {
-            failure.printStackTrace();
-        }
-    }
-
-    public void failedToAccept( SelectionKey key, IOException failure )
-    {
-        if ( failure != null )
-        {
-            failure.printStackTrace();
-        }
-    }
-
-    public void failedToSelect( Selector selector, IOException failure )
-    {
-        if ( failure != null )
-        {
-            failure.printStackTrace();
-        }
-    }
-
-    public void enteringSelect( Selector selector )
-    {
-    }
-}
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.seda.listener;
+
+import java.io.IOException;
+
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+
+
+/**
+ * An null do nothing adapter for the listener manager.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ListenerManagerMonitorAdapter implements ListenerManagerMonitor {
+    public void started() {
+    }
+
+    public void stopped() {
+    }
+
+    public void bindOccured(ListenerConfig listenerConfig) {
+    }
+
+    public void unbindOccured(ListenerConfig listenerConfig) {
+    }
+
+    public void acceptOccured(SelectionKey key) {
+    }
+
+    public void selectOccured(Selector selector) {
+    }
+
+    public void selectTimedOut(Selector selector) {
+    }
+
+    public void failedToBind(ListenerConfig listenerConfig, IOException failure) {
+        if (failure != null) {
+            failure.printStackTrace();
+        }
+    }
+
+    public void failedToUnbind(ListenerConfig listenerConfig,
+                               IOException failure) {
+        if (failure != null) {
+            failure.printStackTrace();
+        }
+    }
+
+    public void failedToExpire(ClientKey key, IOException failure) {
+        if (failure != null) {
+            failure.printStackTrace();
+        }
+    }
+
+    public void failedToAccept(SelectionKey key, IOException failure) {
+        if (failure != null) {
+            failure.printStackTrace();
+        }
+    }
+
+    public void failedToSelect(Selector selector, IOException failure) {
+        if (failure != null) {
+            failure.printStackTrace();
+        }
+    }
+
+    public void enteringSelect(Selector selector) {
+    }
+}

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java	Fri Oct 22 17:29:41 2004
@@ -16,11 +16,10 @@
  */
 package org.apache.seda.listener;
 
+import java.net.InetAddress;
 
 import org.apache.seda.protocol.InetServiceEntry;
 
-import java.net.InetAddress;
-
 
 /**
  * The configuration base class for socket based listeners.
@@ -28,14 +27,13 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory Project</a>
  * @version $Rev$
  */
-public class SocketListenerConfig extends ListenerConfig
-{
+public class SocketListenerConfig extends ListenerConfig {
     /** the InetAddress associated with this server socket configuration */
     private final InetAddress inetAddress;
+
     /** the service entry in the inet service database */
     private final InetServiceEntry servEnt;
 
-
     /**
      * Creates a socket listener config with all the supplied properties.
      *
@@ -43,45 +41,39 @@
      * @param servEnt the inet service entry for the service this listner
      * provides
      */
-    public SocketListenerConfig( InetAddress inetAddress, InetServiceEntry servEnt )
-    {
+    public SocketListenerConfig(InetAddress inetAddress,
+                                InetServiceEntry servEnt) {
         this.servEnt = servEnt;
         this.inetAddress = inetAddress;
     }
 
-
     /**
      * Gets the InetAddress associated with this server socket configuration.
      *
      * @return the address for the server socket associated with this config
      */
-    public InetAddress getInetAddress()
-    {
+    public InetAddress getInetAddress() {
         return inetAddress;
     }
 
-
     /**
      * Gets the service entry in the inet service database associated with
      * this server socket configuration.
      *
      * @return the service entry in the inet service database
      */
-    public InetServiceEntry getInetServiceEntry()
-    {
+    public InetServiceEntry getInetServiceEntry() {
         return servEnt;
     }
 
-
-    public String getURI()
-    {
+    public String getURI() {
         StringBuffer l_buf = new StringBuffer();
 
-        l_buf.append( servEnt.getName() );
-        l_buf.append( "://" );
-        l_buf.append( inetAddress );
-        l_buf.append( ':' );
-        l_buf.append( servEnt.getPort() );
+        l_buf.append(servEnt.getName());
+        l_buf.append("://");
+        l_buf.append(inetAddress);
+        l_buf.append(':');
+        l_buf.append(servEnt.getPort());
 
         return l_buf.toString();
     }

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	Fri Oct 22 17:29:41 2004
@@ -16,16 +16,16 @@
  */
 package org.apache.seda.listener;
 
-
 import java.io.IOException;
+
 import java.net.InetSocketAddress;
 import java.net.Socket;
 
 
 /**
  * Every client that successfully binds anonymously or with a valid identity
- * has a unique client key represented by this class.  The key uniquely 
- * identifies the client based on the connection parameters: interface and port 
+ * has a unique client key represented by this class.  The key uniquely
+ * identifies the client based on the connection parameters: interface and port
  * used on the server as well as the interface and port used by the client.
  * <p>
  * The ClientKey plays a central role in coordinating activities with the
@@ -34,31 +34,28 @@
  * ClientKey instance.  Socket IO is managed using a pair of lock objects
  * specificially for this purpose.
  * </p>
- * 
+ *
  * @todo do we really need these lock objects?
  * @todo why are we carrying around the damn socket?
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public final class TCPClientKey extends ClientKey
-{
+public final class TCPClientKey extends ClientKey {
     // ----------------------------------------------
     // Private members.
     // ----------------------------------------------
 
     /** Socket connection to client */
     private final Socket socket;
-    
+
     /** Whether or not this key has expired: the client has disconnected. */
     private boolean hasExpired = false;
 
-
     // ----------------------------------------------
     // Constructors
     // ----------------------------------------------
 
-
     /**
       * Generates a unique connection/client identifier String for a client
       * socket connection.  The key is composed of the local server address
@@ -73,58 +70,52 @@
       * @param a_socket newly established client socket connection to the
       * server.
       */
-    TCPClientKey( final Socket a_socket )
-    {
+    TCPClientKey(final Socket a_socket) {
         super(getClientId(a_socket));
         socket = a_socket;
     }
-    
+
     private static String getClientId(Socket a_socket) {
         // build the key ...
         StringBuffer l_buf = new StringBuffer();
-        l_buf.append( a_socket.getLocalAddress().getHostAddress() );
-        l_buf.append( ':' );
-        l_buf.append( a_socket.getLocalPort() ).append( "<-" );
-        l_buf.append( a_socket.getInetAddress().getHostAddress() );
-        l_buf.append( ':' );
-        l_buf.append( a_socket.getPort() );
+        l_buf.append(a_socket.getLocalAddress().getHostAddress());
+        l_buf.append(':');
+        l_buf.append(a_socket.getLocalPort()).append("<-");
+        l_buf.append(a_socket.getInetAddress().getHostAddress());
+        l_buf.append(':');
+        l_buf.append(a_socket.getPort());
         return l_buf.toString();
     }
 
-
     // ----------------------------------------------
     // Accessors of conn. parameters to client id
     // ----------------------------------------------
 
-    
     /**
      * Gets the clients socket connection.
-     * 
+     *
      * @return the client's socket connection
      */
-    public Socket getSocket() throws KeyExpiryException
-    {
+    public Socket getSocket() throws KeyExpiryException {
         checkExpiry();
         return socket;
     }
-    
+
     public InetSocketAddress getLocalAddress() throws KeyExpiryException {
         checkExpiry();
-        return new InetSocketAddress(socket.getLocalAddress(), socket.getLocalPort());
+        return new InetSocketAddress(socket.getLocalAddress(),
+                                     socket.getLocalPort());
     }
 
-    public InetSocketAddress getRemoteAddress() throws KeyExpiryException
-    {
+    public InetSocketAddress getRemoteAddress() throws KeyExpiryException {
         checkExpiry();
         return new InetSocketAddress(socket.getInetAddress(), socket.getPort());
     }
 
-
     // ----------------------------------------------
     // Key expiration methods.
     // ----------------------------------------------
 
-
     /**
      * Determines if the client represented by this ClientKey is still
      * connected to the server.  Once disconnected the ClientKey is expired
@@ -133,29 +124,24 @@
      * @return true if the client is no longer connected to the server, false
      * if the client is connected.
      */
-    public boolean hasExpired()
-    {
+    public boolean hasExpired() {
         return hasExpired;
     }
 
-
     /**
      * Expires this key to indicate the disconnection of the client represented
      * by this key from the server.  It is intentionally package friendly to
      * only allow access by the ClientModule.  Tries to close socket if it is
      * still open.
      */
-    protected void expire() throws IOException
-    {
+    protected void expire() throws IOException {
         hasExpired = true;
-        
-        if ( null != socket )
-        {
+
+        if (null != socket) {
             socket.close();
         }
     }
 
-
     /**
      * Utility method to throw key expiration exception if this ClientKey has
      * expired.  This method is called by most accessor methods within this
@@ -163,16 +149,14 @@
      * purpose for this is to force ClientKey using modules to check for
      * expiration rather rely upon them to check to see if the key is valid
      * before use everytime.
-     * 
+     *
      * @throws KeyExpiryException to force the handling of expired keys rather
      * than depending on developers to maintain a convention of checking for
      * key expiration before use in other modules.
      */
-    protected void checkExpiry() throws KeyExpiryException
-    {
-        if( hasExpired )
-        {
-            throw new KeyExpiryException( this );
+    protected void checkExpiry() throws KeyExpiryException {
+        if (hasExpired) {
+            throw new KeyExpiryException(this);
         }
     }
 }

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.java	Fri Oct 22 17:29:41 2004
@@ -16,11 +16,10 @@
  */
 package org.apache.seda.listener;
 
+import java.net.InetAddress;
 
 import org.apache.seda.protocol.InetServiceEntry;
 
-import java.net.InetAddress;
-
 
 /**
  * A default server listener.
@@ -29,38 +28,32 @@
  * @author $LastChangedBy$
  * @version $LastChangedRevision$
  */
-public class TCPListenerConfig extends SocketListenerConfig
-{
+public class TCPListenerConfig extends SocketListenerConfig {
     /** the connection backlog */
     private int backlog;
 
     /**
      * Creates a default listener with all the supplied properties.
-     * 
+     *
      * @param inetAddress the inetAddress for the server listener
      * @param servEnt the inet service entry for the service this listner
      * provides
      */
-    public TCPListenerConfig( InetAddress inetAddress, InetServiceEntry servEnt )
-    {
-        super( inetAddress, servEnt );
+    public TCPListenerConfig(InetAddress inetAddress, InetServiceEntry servEnt) {
+        super(inetAddress, servEnt);
     }
-    
-    
+
     /* (non-Javadoc)
      * @see org.apache.seda.listener.ServerListener#getBacklog()
      */
-    public int getBacklog()
-    {
+    public int getBacklog() {
         return this.backlog;
     }
 
     /**
      * @param a_backlog The backlog to set.
      */
-    protected void setBacklog( int a_backlog )
-    {
+    protected void setBacklog(int a_backlog) {
         this.backlog = a_backlog;
     }
 }
-

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	Fri Oct 22 17:29:41 2004
@@ -16,14 +16,16 @@
  */
 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;
@@ -42,120 +44,116 @@
 /**
  * A listener manager that uses non-blocking NIO based constructs to detect
  * client connections on server socket listeners.
- * 
+ *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class TCPListenerManager 
-    implements
-    DisconnectSubscriber,
-    ProtocolSubscriber,
-    ListenerManager,
-    Runnable
-{
+public class TCPListenerManager implements DisconnectSubscriber,
+                                           ProtocolSubscriber, ListenerManager,
+                                           Runnable {
     /** event manager used to decouple source to sink relationships */
     private final EventRouter router;
+
     /** selector used to select a acceptable socket channel */
     private final Selector selector;
+
     /** a map of auth service names to their protocol providers */
     private final Map protocols;
+
     /** the client keys for accepted connections */
     private final Set clients;
+
     /** the set of listeners managed */
     private final Set listeners;
+
     /** new listeners waiting to be bound */
     private final Set bindListeners;
+
     /** old listeners waiting to be unbound */
     private final Set unbindListeners;
-    
-    /** the thread driving this Runnable */ 
+
+    /** the thread driving this Runnable */
     private Thread thread = null;
+
     /** parameter used to politely stop running thread */
     private Boolean hasStarted = null;
+
     /** the listner manager's monitor */
     private ListenerManagerMonitor monitor = null;
-    
-    
+
     /**
      * Creates a default listener manager using an event router.
-     * 
+     *
      * @param router the router to publish events to
      * @throws IOException
      */
-    public TCPListenerManager( EventRouter router ) throws IOException
-    {
+    public TCPListenerManager(EventRouter router)
+                       throws IOException {
         this.router = router;
         this.clients = new HashSet();
         this.selector = Selector.open();
         this.protocols = new HashMap();
         this.listeners = new HashSet();
-        this.hasStarted = new Boolean( false );
+        this.hasStarted = new Boolean(false);
         this.bindListeners = new HashSet();
         this.unbindListeners = new HashSet();
-        
-        this.router.subscribe( DisconnectEvent.class, null, this );
+
+        this.router.subscribe(DisconnectEvent.class, null, this);
         this.monitor = new ListenerManagerMonitorAdapter();
     }
-    
-    
+
     /**
      * Gets the monitor.
-     * 
+     *
      * @return Returns the monitor.
      */
-    public ListenerManagerMonitor getMonitor()
-    {
+    public ListenerManagerMonitor getMonitor() {
         return monitor;
     }
 
-    
     /**
      * Sets the monitor.
-     * 
+     *
      * @param monitor The monitor to set.
      */
-    public void setMonitor( ListenerManagerMonitor monitor )
-    {
+    public void setMonitor(ListenerManagerMonitor monitor) {
         this.monitor = monitor;
     }
 
-
     /**
      * @see org.apache.seda.listener.ListenerManager#bind(ListenerConfig)
      */
-    public void bind( ListenerConfig listener ) throws IOException
-    {
+    public void bind(ListenerConfig listener) throws IOException {
         ensureListenerConfigType(listener);
 
-        synchronized ( bindListeners )
-        {
-            bindListeners.add( listener );
+        synchronized (bindListeners) {
+            bindListeners.add(listener);
         }
-        
+
         selector.wakeup();
     }
-    
-    
+
     /**
      * @see org.apache.seda.listener.ListenerManager#unbind(ListenerConfig)
      */
-    public void unbind( ListenerConfig listener ) throws IOException
-    {
+    public void unbind(ListenerConfig listener) throws IOException {
         ensureListenerConfigType(listener);
 
-        synchronized ( unbindListeners )
-        {
-            unbindListeners.add( listener );
+        synchronized (unbindListeners) {
+            unbindListeners.add(listener);
         }
 
         selector.wakeup();
     }
 
     private void ensureListenerConfigType(ListenerConfig listener) {
-        if (listener == null)
+        if (listener == null) {
             throw new NullPointerException();
-        if (!(listener instanceof TCPListenerConfig))
+        }
+
+        if (!(listener instanceof TCPListenerConfig)) {
             throw new IllegalArgumentException();
+        }
     }
 
     /**
@@ -163,283 +161,229 @@
      * This is not fail fast - meaning it will try all the connections in the
      * ready to bind set even if one fails.
      */
-    private void bind()
-    {
-        synchronized ( bindListeners )
-        {
+    private void bind() {
+        synchronized (bindListeners) {
             Iterator list = bindListeners.iterator();
-            while ( list.hasNext() )
-            {
-                TCPListenerConfig listener =
-                        ( TCPListenerConfig ) list.next();
-                    
-                try
-                {
+
+            while (list.hasNext()) {
+                TCPListenerConfig listener = (TCPListenerConfig) list.next();
+
+                try {
                     ServerSocketChannel channel = ServerSocketChannel.open();
                     InetSocketAddress address =
-                    new InetSocketAddress(
-                            listener.getInetAddress(),
-                            listener.getInetServiceEntry().getPort() );
-                    channel.socket().bind( address, listener.getBacklog() );
-                    channel.configureBlocking( false );
-                    channel.register( selector, SelectionKey.OP_ACCEPT, 
-                            listener );
-                    
-                    synchronized ( listeners )
-                    {
-                        listeners.add( listener );
+                        new InetSocketAddress(listener.getInetAddress(),
+                                              listener.getInetServiceEntry()
+                                                      .getPort());
+                    channel.socket().bind(address, listener.getBacklog());
+                    channel.configureBlocking(false);
+                    channel.register(selector, SelectionKey.OP_ACCEPT, listener);
+
+                    synchronized (listeners) {
+                        listeners.add(listener);
                     }
-                    
-                    bindListeners.remove( listener );
-                }
-                catch ( IOException e )
-                {
-                    monitor.failedToBind( listener, e );
+
+                    bindListeners.remove(listener);
+                } catch (IOException e) {
+                    monitor.failedToBind(listener, e);
                 }
-            
-                monitor.bindOccured( listener );
+
+                monitor.bindOccured(listener);
             }
         }
     }
-    
-    
+
     /**
      * Unbinds listeners that have been collecting up waiting to be unbound.
      * This is not fail fast - meaning it will try all the connections in the
      * ready to unbind set even if one fails.
      */
-    private void unbind()
-    {
+    private void unbind() {
         SelectionKey key = null;
-        
-        synchronized ( unbindListeners ) 
-        {
+
+        synchronized (unbindListeners) {
             Iterator keys = selector.keys().iterator();
-            while ( keys.hasNext() )
-            {
-                key = ( SelectionKey ) keys.next();
-                ListenerConfig listener =
-                        ( ListenerConfig ) key.attachment();
-    
-                if ( unbindListeners.contains( listener ) )
-                {    
-                    try
-                    {
+
+            while (keys.hasNext()) {
+                key = (SelectionKey) keys.next();
+
+                ListenerConfig listener = (ListenerConfig) key.attachment();
+
+                if (unbindListeners.contains(listener)) {
+                    try {
                         key.channel().close();
+                    } catch (IOException e) {
+                        monitor.failedToUnbind(listener, e);
                     }
-                    catch ( IOException e )
-                    {
-                        monitor.failedToUnbind( listener, e );
-                    }
-                
+
                     key.cancel();
-                    
-                    synchronized ( listeners )
-                    {
-                        listeners.remove( listener );
+
+                    synchronized (listeners) {
+                        listeners.remove(listener);
                     }
-                    
-                    unbindListeners.remove( listener );
-                    monitor.unbindOccured( listener );
+
+                    unbindListeners.remove(listener);
+                    monitor.unbindOccured(listener);
                 }
             }
         }
     }
 
-
     // ------------------------------------------------------------------------
     // DisconnectSubscriber Implementation
     // ------------------------------------------------------------------------
-    
-    
+
     /**
      * Disconnects a client by removing the clientKey from the listener.
-     * 
+     *
      * @param event the disconnect event
      */
-    public void inform( DisconnectEvent event )
-    {
-        clients.remove( event.getClientKey() );
-        
-        try
-        {
+    public void inform(DisconnectEvent event) {
+        clients.remove(event.getClientKey());
+
+        try {
             event.getClientKey().expire();
-        }
-        catch ( IOException e ) 
-        {
-            monitor.failedToExpire( event.getClientKey(), e );
+        } catch (IOException e) {
+            monitor.failedToExpire(event.getClientKey(), e);
         }
     }
-    
-    
+
     /*
      *  (non-Javadoc)
      * @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
      */
-    public void inform( EventObject event )
-    {
-        inform( ( DisconnectEvent ) event );
+    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 )
-    {
+    public void inform(ProtocolEvent event) {
     }
 
-
     // ------------------------------------------------------------------------
     // Runnable implementation and start/stop controls
     // ------------------------------------------------------------------------
-    
-    
+
     /**
      * @see java.lang.Runnable#run()
      */
-    public void run()
-    {
-        while ( hasStarted.booleanValue() ) 
-        {
-            try
-            {
-                monitor.enteringSelect( selector );
-                
+    public void run() {
+        while (hasStarted.booleanValue()) {
+            try {
+                monitor.enteringSelect(selector);
+
                 bind();
                 unbind();
-                
-                if ( 0 == selector.select() )
-                {
-                    monitor.selectTimedOut( selector );
+
+                if (0 == selector.select()) {
+                    monitor.selectTimedOut(selector);
                     continue;
                 }
-            } 
-            catch( IOException e )
-            {
-                monitor.failedToSelect( selector, e );
+            } catch (IOException e) {
+                monitor.failedToSelect(selector, e);
                 continue;
             }
-            
-            
+
             Iterator list = selector.selectedKeys().iterator();
-            while ( list.hasNext() )
-            {
-                SelectionKey key = ( SelectionKey ) list.next();
-                
-                if ( key.isAcceptable() )
-                {
+
+            while (list.hasNext()) {
+                SelectionKey key = (SelectionKey) list.next();
+
+                if (key.isAcceptable()) {
                     SocketChannel channel = null;
-                    ServerSocketChannel server = ( ServerSocketChannel )
-                        key.channel();
-                    
-                    try
-                    {
+                    ServerSocketChannel server =
+                        (ServerSocketChannel) key.channel();
+
+                    try {
                         channel = server.accept();
                         list.remove();
-                        monitor.acceptOccured( key );
-                    }
-                    catch ( IOException e )
-                    {
-                        monitor.failedToAccept( key, e );
+                        monitor.acceptOccured(key);
+                    } catch (IOException e) {
+                        monitor.failedToAccept(key, e);
                         continue;
                     }
-                    
-                    ClientKey clientKey = new TCPClientKey( channel.socket() );
-                    ConnectEvent event = new ConnectEvent( this, clientKey );
-                    router.publish( event );
+
+                    ClientKey clientKey = new TCPClientKey(channel.socket());
+                    ConnectEvent event = new ConnectEvent(this, clientKey);
+                    router.publish(event);
                 }
             }
         }
     }
-    
-    
+
     /**
      * Starts up this ListnerManager service.
-     * 
+     *
      * @throws IllegalStateException if this service has already started
      */
-    public void start()
-    {
-        if ( hasStarted.booleanValue() )
-        {
-            throw new IllegalStateException( "Already started!" );
-        }
-        
-        hasStarted = new Boolean( true );
-        thread = new Thread( this );
+    public void start() {
+        if (hasStarted.booleanValue()) {
+            throw new IllegalStateException("Already started!");
+        }
+
+        hasStarted = new Boolean(true);
+        thread = new Thread(this);
         thread.start();
         monitor.started();
     }
-    
-    
+
     /**
-     * Gracefully stops this ListenerManager service.  Blocks calling thread 
+     * Gracefully stops this ListenerManager service.  Blocks calling thread
      * until the service has fully stopped.
-     * 
+     *
      * @throws InterruptedException if this service's driver thread cannot start
      */
-    public void stop() throws InterruptedException
-    {
-        hasStarted = new Boolean( false );
+    public void stop() throws InterruptedException {
+        hasStarted = new Boolean(false);
         selector.wakeup();
 
         /*
          * First lets shutdown the listeners so we're not open to having new
-         * connections created while we are trying to shutdown.  Plus we want 
+         * connections created while we are trying to shutdown.  Plus we want
          * to make the thread for this component do the work to prevent locking
          * issues with the selector.
          */
-        if ( ! listeners.isEmpty() )
-        {
+        if (!listeners.isEmpty()) {
             Iterator list = listeners.iterator();
-            while( list.hasNext() )
-            {
-                ListenerConfig listener =
-                        ( ListenerConfig ) list.next();
-                    
-                try
-                {
+
+            while (list.hasNext()) {
+                ListenerConfig listener = (ListenerConfig) list.next();
+
+                try {
                     /*
                      * put the listening in the set ready to be unbound by
                      * the runnable's thread of execution
                      */
-                    unbind( listener );
-                }
-                catch( IOException e )
-                {
+                    unbind(listener);
+                } catch (IOException e) {
                     // monitor.doSomthing( e );
                     e.printStackTrace();
                 }
             }
         }
-        
+
         /*
-         * Now we gracefully disconnect the clients that are already connected 
-         * so they can complete their current requests and recieve a 
-         * notification of disconnect.  At this point we don't know how we're 
+         * Now we gracefully disconnect the clients that are already connected
+         * so they can complete their current requests and recieve a
+         * notification of disconnect.  At this point we don't know how we're
          * going to do that so we just do it abruptly for the time being.  This
-         * will need to be changed in the future. 
+         * will need to be changed in the future.
          */
-        if ( ! clients.isEmpty() )
-        {
-            synchronized( clients )
-            {
+        if (!clients.isEmpty()) {
+            synchronized (clients) {
                 Iterator list = clients.iterator();
-                while ( list.hasNext() )
-                {
-                    TCPClientKey key = ( TCPClientKey ) list.next();
-                        
-                    try
-                    {
+
+                while (list.hasNext()) {
+                    TCPClientKey key = (TCPClientKey) list.next();
+
+                    try {
                         Socket socket = key.getSocket();
                         socket.close();
                         list.remove();
-                    }
-                    catch( IOException e )
-                    {
+                    } catch (IOException e) {
                         // monitor.doSomthing( e );
                         e.printStackTrace();
                     }
@@ -450,9 +394,8 @@
         /*
          * now wait until the thread of execution for this runnable dies
          */
-        if ( this.thread.isAlive() )
-        {
-            Thread.sleep( 100 );
+        if (this.thread.isAlive()) {
+            Thread.sleep(100);
             selector.wakeup();
         }
 

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	Fri Oct 22 17:29:41 2004
@@ -16,16 +16,16 @@
  */
 package org.apache.seda.listener;
 
-
 import java.io.IOException;
+
 import java.net.DatagramSocket;
 import java.net.InetSocketAddress;
 
 
 /**
  * Every client that successfully binds anonymously or with a valid identity
- * has a unique client key represented by this class.  The key uniquely 
- * identifies the client based on the connection parameters: interface and port 
+ * has a unique client key represented by this class.  The key uniquely
+ * identifies the client based on the connection parameters: interface and port
  * used on the server as well as the interface and port used by the client.
  * <p>
  * The ClientKey plays a central role in coordinating activities with the
@@ -34,33 +34,31 @@
  * ClientKey instance.  Socket IO is managed using a pair of lock objects
  * specificially for this purpose.
  * </p>
- * 
+ *
  * @todo do we really need these lock objects?
  * @todo why are we carrying around the damn socket?
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public final class UDPClientKey extends ClientKey
-{
+public final class UDPClientKey extends ClientKey {
     // ----------------------------------------------
     // Private members.
     // ----------------------------------------------
 
     /** Socket connection to client */
     private final DatagramSocket socket;
+
     /** Client address */
     private final InetSocketAddress clientAddress;
-    
+
     /** Whether or not this key has expired: the client has disconnected. */
     private boolean hasExpired = false;
 
-
     // ----------------------------------------------
     // Constructors
     // ----------------------------------------------
 
-
     /**
       * Generates a unique connection/client identifier String for a client
       * socket connection.  The key is composed of the local server address
@@ -75,45 +73,42 @@
       * @param a_socket newly established client socket connection to the
       * server.
       */
-    UDPClientKey( final DatagramSocket a_socket, final InetSocketAddress clientAddress )
-    {
+    UDPClientKey(final DatagramSocket a_socket,
+                 final InetSocketAddress clientAddress) {
         super(getClientId(a_socket, clientAddress));
-        
+
         socket = a_socket;
         this.clientAddress = clientAddress;
     }
-    
-    private static String getClientId(DatagramSocket a_socket, InetSocketAddress clientAddress) {
+
+    private static String getClientId(DatagramSocket a_socket,
+                                      InetSocketAddress clientAddress) {
         // build the key ...
         StringBuffer l_buf = new StringBuffer();
-        l_buf.append( a_socket.getLocalAddress().getHostAddress() );
-        l_buf.append( ':' );
-        l_buf.append( a_socket.getLocalPort() ).append( "<-" );
-        l_buf.append( clientAddress.getAddress().getHostAddress() );
-        l_buf.append( ':' );
-        l_buf.append( clientAddress.getPort() );
+        l_buf.append(a_socket.getLocalAddress().getHostAddress());
+        l_buf.append(':');
+        l_buf.append(a_socket.getLocalPort()).append("<-");
+        l_buf.append(clientAddress.getAddress().getHostAddress());
+        l_buf.append(':');
+        l_buf.append(clientAddress.getPort());
         return l_buf.toString();
     }
 
-
     // ----------------------------------------------
     // Accessors of conn. parameters to client id
     // ----------------------------------------------
-
-    public DatagramSocket getSocket() throws KeyExpiryException
-    {
+    public DatagramSocket getSocket() throws KeyExpiryException {
         checkExpiry();
         return socket;
     }
 
-    public InetSocketAddress getLocalAddress() throws KeyExpiryException
-    {
+    public InetSocketAddress getLocalAddress() throws KeyExpiryException {
         checkExpiry();
-        return new InetSocketAddress(socket.getLocalAddress(), socket.getLocalPort());
+        return new InetSocketAddress(socket.getLocalAddress(),
+                                     socket.getLocalPort());
     }
 
-    public InetSocketAddress getRemoteAddress() throws KeyExpiryException
-    {
+    public InetSocketAddress getRemoteAddress() throws KeyExpiryException {
         checkExpiry();
         return clientAddress;
     }
@@ -122,7 +117,6 @@
     // Key expiration methods.
     // ----------------------------------------------
 
-
     /**
      * Determines if the client represented by this ClientKey is still
      * connected to the server.  Once disconnected the ClientKey is expired
@@ -131,29 +125,24 @@
      * @return true if the client is no longer connected to the server, false
      * if the client is connected.
      */
-    public boolean hasExpired()
-    {
+    public boolean hasExpired() {
         return hasExpired;
     }
 
-
     /**
      * Expires this key to indicate the disconnection of the client represented
      * by this key from the server.  It is intentionally package friendly to
      * only allow access by the ClientModule.  Tries to close socket if it is
      * still open.
      */
-    protected void expire() throws IOException
-    {
+    protected void expire() throws IOException {
         hasExpired = true;
-        
-        if ( null != socket )
-        {
+
+        if (null != socket) {
             socket.close();
         }
     }
 
-
     /**
      * Utility method to throw key expiration exception if this ClientKey has
      * expired.  This method is called by most accessor methods within this
@@ -161,16 +150,14 @@
      * purpose for this is to force ClientKey using modules to check for
      * expiration rather rely upon them to check to see if the key is valid
      * before use everytime.
-     * 
+     *
      * @throws KeyExpiryException to force the handling of expired keys rather
      * than depending on developers to maintain a convention of checking for
      * key expiration before use in other modules.
      */
-    protected void checkExpiry() throws KeyExpiryException
-    {
-        if( hasExpired )
-        {
-            throw new KeyExpiryException( this );
+    protected void checkExpiry() throws KeyExpiryException {
+        if (hasExpired) {
+            throw new KeyExpiryException(this);
         }
     }
 }

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerConfig.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerConfig.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerConfig.java	Fri Oct 22 17:29:41 2004
@@ -16,9 +16,10 @@
  */
 package org.apache.seda.listener;
 
+import java.net.InetAddress;
+
 import org.apache.seda.protocol.InetServiceEntry;
 
-import java.net.InetAddress;
 
 /**
  * A default server listener.
@@ -27,8 +28,7 @@
  * @author $LastChangedBy$
  * @version $LastChangedRevision$
  */
-public class UDPListenerConfig extends SocketListenerConfig
-{
+public class UDPListenerConfig extends SocketListenerConfig {
     /**
      * Creates a default listener with all the supplied properties.
      *
@@ -36,8 +36,7 @@
      * @param servEnt the inet service entry for the service this listner
      * provides
      */
-    public UDPListenerConfig( InetAddress a_address, InetServiceEntry servEnt )
-    {
-	    super(a_address, servEnt);
+    public UDPListenerConfig(InetAddress a_address, InetServiceEntry servEnt) {
+        super(a_address, servEnt);
     }
 }

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	Fri Oct 22 17:29:41 2004
@@ -16,14 +16,16 @@
  */
 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;
@@ -44,123 +46,120 @@
 /**
  * A listener manager that uses non-blocking NIO based constructs to detect
  * client connections on server socket listeners.
- * 
+ *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class UDPListenerManager 
-    implements
-    DisconnectSubscriber,
-    ProtocolSubscriber,
-    ListenerManager,
-    Runnable
-{
+public class UDPListenerManager implements DisconnectSubscriber,
+                                           ProtocolSubscriber, ListenerManager,
+                                           Runnable {
     /** event manager used to decouple source to sink relationships */
     private final EventRouter router;
+
     /** selector used to select a acceptable socket channel */
     private final Selector selector;
+
     /** the buffer pool we get direct buffers from */
     private BufferPool bp = null;
+
     /** a map of auth service names to their protocol providers */
     private final Map protocols;
+
     /** the client keys for accepted connections */
     private final Set clients;
+
     /** the set of listeners managed */
     private final Set listeners;
+
     /** new listeners waiting to be bound */
     private final Set bindListeners;
+
     /** old listeners waiting to be unbound */
     private final Set unbindListeners;
-    
-    /** the thread driving this Runnable */ 
+
+    /** the thread driving this Runnable */
     private Thread thread = null;
+
     /** parameter used to politely stop running thread */
     private Boolean hasStarted = null;
+
     /** the listner manager's monitor */
     private ListenerManagerMonitor monitor = null;
-    
-    
+
     /**
      * Creates a default listener manager using an event router.
-     * 
+     *
      * @param router the router to publish events to
      * @throws IOException
      */
-    public UDPListenerManager( EventRouter router, BufferPool bp ) throws IOException
-    {
+    public UDPListenerManager(EventRouter router, BufferPool bp)
+                       throws IOException {
         this.router = router;
         this.clients = new HashSet();
         this.selector = Selector.open();
         this.protocols = new HashMap();
         this.listeners = new HashSet();
-        this.hasStarted = new Boolean( false );
+        this.hasStarted = new Boolean(false);
         this.bindListeners = new HashSet();
         this.unbindListeners = new HashSet();
         this.bp = bp;
-        
-        this.router.subscribe( DisconnectEvent.class, null, this );
+
+        this.router.subscribe(DisconnectEvent.class, null, this);
         this.monitor = new ListenerManagerMonitorAdapter();
     }
-    
-    
+
     /**
      * Gets the monitor.
-     * 
+     *
      * @return Returns the monitor.
      */
-    public ListenerManagerMonitor getMonitor()
-    {
+    public ListenerManagerMonitor getMonitor() {
         return monitor;
     }
 
-    
     /**
      * Sets the monitor.
-     * 
+     *
      * @param monitor The monitor to set.
      */
-    public void setMonitor( ListenerManagerMonitor monitor )
-    {
+    public void setMonitor(ListenerManagerMonitor monitor) {
         this.monitor = monitor;
     }
 
-
     /**
      * @see org.apache.seda.listener.ListenerManager#bind(ListenerConfig)
      */
-    public void bind( ListenerConfig listener ) throws IOException
-    {
+    public void bind(ListenerConfig listener) throws IOException {
         ensureListenerConfigType(listener);
 
-        synchronized ( bindListeners )
-        {
-            bindListeners.add( listener );
+        synchronized (bindListeners) {
+            bindListeners.add(listener);
         }
-        
+
         selector.wakeup();
     }
-    
-    
+
     /**
      * @see org.apache.seda.listener.ListenerManager#unbind(ListenerConfig)
      */
-    public void unbind( ListenerConfig listener ) throws IOException
-    {
+    public void unbind(ListenerConfig listener) throws IOException {
         ensureListenerConfigType(listener);
 
-        synchronized ( unbindListeners )
-        {
-            unbindListeners.add( listener );
+        synchronized (unbindListeners) {
+            unbindListeners.add(listener);
         }
 
         selector.wakeup();
     }
 
     private void ensureListenerConfigType(ListenerConfig listener) {
-        if (listener == null)
+        if (listener == null) {
             throw new NullPointerException();
-        if (!(listener instanceof UDPListenerConfig))
+        }
+
+        if (!(listener instanceof UDPListenerConfig)) {
             throw new IllegalArgumentException();
+        }
     }
 
     /**
@@ -168,300 +167,249 @@
      * This is not fail fast - meaning it will try all the connections in the
      * ready to bind set even if one fails.
      */
-    private void bind()
-    {
-        synchronized ( bindListeners )
-        {
+    private void bind() {
+        synchronized (bindListeners) {
             Iterator list = bindListeners.iterator();
-            while ( list.hasNext() )
-            {
-                UDPListenerConfig listener =
-                        ( UDPListenerConfig ) list.next();
-                    
-                try
-                {
+
+            while (list.hasNext()) {
+                UDPListenerConfig listener = (UDPListenerConfig) list.next();
+
+                try {
                     DatagramChannel channel = DatagramChannel.open();
                     InetSocketAddress address =
-                    new InetSocketAddress(
-                            listener.getInetAddress(),
-                            listener.getInetServiceEntry().getPort() );
+                        new InetSocketAddress(listener.getInetAddress(),
+                                              listener.getInetServiceEntry()
+                                                      .getPort());
                     channel.socket().bind(address);
-                    channel.configureBlocking( false );
-                    channel.register( selector, SelectionKey.OP_READ, 
-                            listener );
-                    
-                    synchronized ( listeners )
-                    {
-                        listeners.add( listener );
+                    channel.configureBlocking(false);
+                    channel.register(selector, SelectionKey.OP_READ, listener);
+
+                    synchronized (listeners) {
+                        listeners.add(listener);
                     }
-                    
-                    bindListeners.remove( listener );
-                }
-                catch ( IOException e )
-                {
-                    monitor.failedToBind( listener, e );
+
+                    bindListeners.remove(listener);
+                } catch (IOException e) {
+                    monitor.failedToBind(listener, e);
                 }
-            
-                monitor.bindOccured( listener );
+
+                monitor.bindOccured(listener);
             }
         }
     }
-    
-    
+
     /**
      * Unbinds listeners that have been collecting up waiting to be unbound.
      * This is not fail fast - meaning it will try all the connections in the
      * ready to unbind set even if one fails.
      */
-    private void unbind()
-    {
+    private void unbind() {
         SelectionKey key = null;
-        
-        synchronized ( unbindListeners ) 
-        {
+
+        synchronized (unbindListeners) {
             Iterator keys = selector.keys().iterator();
-            while ( keys.hasNext() )
-            {
-                key = ( SelectionKey ) keys.next();
-                ListenerConfig listener =
-                        ( ListenerConfig ) key.attachment();
-    
-                if ( unbindListeners.contains( listener ) )
-                {    
-                    try
-                    {
+
+            while (keys.hasNext()) {
+                key = (SelectionKey) keys.next();
+
+                ListenerConfig listener = (ListenerConfig) key.attachment();
+
+                if (unbindListeners.contains(listener)) {
+                    try {
                         key.channel().close();
+                    } catch (IOException e) {
+                        monitor.failedToUnbind(listener, e);
                     }
-                    catch ( IOException e )
-                    {
-                        monitor.failedToUnbind( listener, e );
-                    }
-                
+
                     key.cancel();
-                    
-                    synchronized ( listeners )
-                    {
-                        listeners.remove( listener );
+
+                    synchronized (listeners) {
+                        listeners.remove(listener);
                     }
-                    
-                    unbindListeners.remove( listener );
-                    monitor.unbindOccured( listener );
+
+                    unbindListeners.remove(listener);
+                    monitor.unbindOccured(listener);
                 }
             }
         }
     }
 
-
     // ------------------------------------------------------------------------
     // DisconnectSubscriber Implementation
     // ------------------------------------------------------------------------
-    
-    
+
     /**
      * Disconnects a client by removing the clientKey from the listener.
-     * 
+     *
      * @param event the disconnect event
      */
-    public void inform( DisconnectEvent event )
-    {
-        clients.remove( event.getClientKey() );
-        
-        try
-        {
+    public void inform(DisconnectEvent event) {
+        clients.remove(event.getClientKey());
+
+        try {
             event.getClientKey().expire();
-        }
-        catch ( IOException e ) 
-        {
-            monitor.failedToExpire( event.getClientKey(), e );
+        } catch (IOException e) {
+            monitor.failedToExpire(event.getClientKey(), e);
         }
     }
-    
-    
+
     /*
      *  (non-Javadoc)
      * @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
      */
-    public void inform( EventObject event )
-    {
-        inform( ( DisconnectEvent ) event );
+    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 )
-    {
+    public void inform(ProtocolEvent event) {
     }
 
-
     // ------------------------------------------------------------------------
     // Runnable implementation and start/stop controls
     // ------------------------------------------------------------------------
-    
-    
+
     /**
      * @see java.lang.Runnable#run()
      */
-    public void run()
-    {
-        while ( hasStarted.booleanValue() ) 
-        {
-            try
-            {
-                monitor.enteringSelect( selector );
-                
+    public void run() {
+        while (hasStarted.booleanValue()) {
+            try {
+                monitor.enteringSelect(selector);
+
                 bind();
                 unbind();
-                
-                if ( 0 == selector.select() )
-                {
-                    monitor.selectTimedOut( selector );
+
+                if (0 == selector.select()) {
+                    monitor.selectTimedOut(selector);
                     continue;
                 }
-            } 
-            catch( IOException e )
-            {
-                monitor.failedToSelect( selector, e );
+            } catch (IOException e) {
+                monitor.failedToSelect(selector, e);
                 continue;
             }
-            
-            
+
             Iterator list = selector.selectedKeys().iterator();
-            while ( list.hasNext() )
-            {
-                SelectionKey key = ( SelectionKey ) list.next();
+
+            while (list.hasNext()) {
+                SelectionKey key = (SelectionKey) list.next();
                 list.remove();
-                
-                if ( key.isReadable() )
-                {
-                    DatagramChannel channel =  (DatagramChannel)
-                        key.channel();
-                    
+
+                if (key.isReadable()) {
+                    DatagramChannel channel = (DatagramChannel) key.channel();
+
                     ByteBuffer buf = null;
                     InetSocketAddress clientAddress;
                     boolean read = false;
-                    try
-                    {
+
+                    try {
                         buf = bp.getBuffer(this);
-                        clientAddress = (InetSocketAddress) channel.receive(buf);
+                        clientAddress =
+                            (InetSocketAddress) channel.receive(buf);
+
                         if (clientAddress != null) {
                             read = true;
                         }
-                    }
-                    catch ( IOException e )
-                    {
+                    } catch (IOException e) {
                         // FIXME InputManagerMonitor.failedToRead?
-                        monitor.failedToAccept( key, e );
+                        monitor.failedToAccept(key, e);
                         continue;
-                    }
-                    catch ( ResourceException e ) {
+                    } catch (ResourceException e) {
                         // FIXME InputManagerMonitor.bufferUnavailable?
                         //monitor.bufferUnavailable( bp, e );
                         continue;
                     } finally {
-                        if (!read && buf != null) {
+                        if (!read && (buf != null)) {
                             bp.releaseClaim(buf, this);
                         }
                     }
-                    
+
                     if (read) {
-                        ClientKey clientKey = new UDPClientKey( channel.socket(), clientAddress );
-                        InputEvent event = new ConcreteInputEvent(clientKey, buf);
-                        router.publish( event );
+                        ClientKey clientKey =
+                            new UDPClientKey(channel.socket(), clientAddress);
+                        InputEvent event =
+                            new ConcreteInputEvent(clientKey, buf);
+                        router.publish(event);
                     }
                 }
             }
         }
     }
-    
-    
+
     /**
      * Starts up this ListnerManager service.
-     * 
+     *
      * @throws IllegalStateException if this service has already started
      */
-    public void start()
-    {
-        if ( hasStarted.booleanValue() )
-        {
-            throw new IllegalStateException( "Already started!" );
-        }
-        
-        hasStarted = new Boolean( true );
-        thread = new Thread( this );
+    public void start() {
+        if (hasStarted.booleanValue()) {
+            throw new IllegalStateException("Already started!");
+        }
+
+        hasStarted = new Boolean(true);
+        thread = new Thread(this);
         thread.start();
         monitor.started();
     }
-    
-    
+
     /**
-     * Gracefully stops this ListenerManager service.  Blocks calling thread 
+     * Gracefully stops this ListenerManager service.  Blocks calling thread
      * until the service has fully stopped.
-     * 
+     *
      * @throws InterruptedException if this service's driver thread cannot start
      */
-    public void stop() throws InterruptedException
-    {
-        hasStarted = new Boolean( false );
+    public void stop() throws InterruptedException {
+        hasStarted = new Boolean(false);
         selector.wakeup();
 
         /*
          * First lets shutdown the listeners so we're not open to having new
-         * connections created while we are trying to shutdown.  Plus we want 
+         * connections created while we are trying to shutdown.  Plus we want
          * to make the thread for this component do the work to prevent locking
          * issues with the selector.
          */
-        if ( ! listeners.isEmpty() )
-        {
+        if (!listeners.isEmpty()) {
             Iterator list = listeners.iterator();
-            while( list.hasNext() )
-            {
-                ListenerConfig listener =
-                        ( ListenerConfig ) list.next();
-                    
-                try
-                {
+
+            while (list.hasNext()) {
+                ListenerConfig listener = (ListenerConfig) list.next();
+
+                try {
                     /*
                      * put the listening in the set ready to be unbound by
                      * the runnable's thread of execution
                      */
-                    unbind( listener );
-                }
-                catch( IOException e )
-                {
+                    unbind(listener);
+                } catch (IOException e) {
                     // monitor.doSomthing( e );
                     e.printStackTrace();
                 }
             }
         }
-        
+
         /*
-         * Now we gracefully disconnect the clients that are already connected 
-         * so they can complete their current requests and recieve a 
-         * notification of disconnect.  At this point we don't know how we're 
+         * Now we gracefully disconnect the clients that are already connected
+         * so they can complete their current requests and recieve a
+         * notification of disconnect.  At this point we don't know how we're
          * going to do that so we just do it abruptly for the time being.  This
-         * will need to be changed in the future. 
+         * will need to be changed in the future.
          */
-        if ( ! clients.isEmpty() )
-        {
-            synchronized( clients )
-            {
+        if (!clients.isEmpty()) {
+            synchronized (clients) {
                 Iterator list = clients.iterator();
-                while ( list.hasNext() )
-                {
-                    UDPClientKey key = ( UDPClientKey ) list.next();
-                        
-                    try
-                    {
+
+                while (list.hasNext()) {
+                    UDPClientKey key = (UDPClientKey) list.next();
+
+                    try {
                         DatagramSocket socket = key.getSocket();
                         socket.close();
                         list.remove();
-                    }
-                    catch( IOException e )
-                    {
+                    } catch (IOException e) {
                         // monitor.doSomthing( e );
                         e.printStackTrace();
                     }
@@ -472,16 +420,14 @@
         /*
          * now wait until the thread of execution for this runnable dies
          */
-        if ( this.thread.isAlive() )
-        {
-            Thread.sleep( 100 );
+        if (this.thread.isAlive()) {
+            Thread.sleep(100);
             selector.wakeup();
         }
 
         monitor.stopped();
     }
 
-
     /**
      * A concrete InputEvent that uses the buffer pool to properly implement
      * the interest claim and release methods.
@@ -490,22 +436,18 @@
      * @author $Author$
      * @version $Revision$
      */
-    class ConcreteInputEvent extends InputEvent
-    {
-        ConcreteInputEvent( ClientKey key, ByteBuffer buffer )
-        {
-            super( UDPListenerManager.this, key, buffer );
-        }
-        
-        public ByteBuffer claimInterest( Object party )
-        {
-            bp.claimInterest( getBuffer(), party );
+    class ConcreteInputEvent extends InputEvent {
+        ConcreteInputEvent(ClientKey key, ByteBuffer buffer) {
+            super(UDPListenerManager.this, key, buffer);
+        }
+
+        public ByteBuffer claimInterest(Object party) {
+            bp.claimInterest(getBuffer(), party);
             return getBuffer().asReadOnlyBuffer();
         }
-        
-        public void releaseInterest( Object party )
-        {
-            bp.releaseClaim( getBuffer(), party );
+
+        public void releaseInterest(Object party) {
+            bp.releaseClaim(getBuffer(), party);
         }
     }
 }

Copied: incubator/directory/seda/trunk/src/java/org/apache/seda/output/TCPOutputManager.java (from rev 55337, incubator/directory/seda/trunk/src/java/org/apache/seda/output/DefaultOutputManager.java)
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/output/DefaultOutputManager.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/output/TCPOutputManager.java	Fri Oct 22 17:29:41 2004
@@ -47,7 +47,7 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DefaultOutputManager extends DefaultStage
+public class TCPOutputManager extends DefaultStage
     implements 
     OutputManager, 
     OutputSubscriber, 
@@ -73,7 +73,7 @@
      * @param router the router we subscribe for OutputEvents on
      * @param config the configuration for this Stage
      */
-    public DefaultOutputManager( EventRouter router, DefaultStageConfig config )
+    public TCPOutputManager( EventRouter router, DefaultStageConfig config )
     {
         super( config );
         this.router = router;
@@ -222,7 +222,7 @@
                 }
                 catch ( IOException e )
                 {
-                    monitor.failedOnWrite( DefaultOutputManager.this, 
+                    monitor.failedOnWrite( TCPOutputManager.this, 
                             event.getClientKey(), e );
                 }
             }

Mime
View raw message