directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r354272 - in /directory/network/trunk/src/java/org/apache/mina/handler/chain: ChainedIoHandler.java Command.java CommandChain.java IoHandlerChain.java IoHandlerCommand.java
Date Tue, 06 Dec 2005 03:27:04 GMT
Author: trustin
Date: Mon Dec  5 19:26:57 2005
New Revision: 354272

URL: http://svn.apache.org/viewcvs?rev=354272&view=rev
Log:
* Renamed Command to IoHandlerCommand
* Renamed CommandChain to IoHandlerChain
* Added more documentation
* Added ChainedIoHandler.getCommand()

Added:
    directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerChain.java
      - copied, changed from r354266, directory/network/trunk/src/java/org/apache/mina/handler/chain/CommandChain.java
    directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerCommand.java
      - copied, changed from r354266, directory/network/trunk/src/java/org/apache/mina/handler/chain/Command.java
Removed:
    directory/network/trunk/src/java/org/apache/mina/handler/chain/Command.java
    directory/network/trunk/src/java/org/apache/mina/handler/chain/CommandChain.java
Modified:
    directory/network/trunk/src/java/org/apache/mina/handler/chain/ChainedIoHandler.java

Modified: directory/network/trunk/src/java/org/apache/mina/handler/chain/ChainedIoHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/handler/chain/ChainedIoHandler.java?rev=354272&r1=354271&r2=354272&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/handler/chain/ChainedIoHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/handler/chain/ChainedIoHandler.java Mon
Dec  5 19:26:57 2005
@@ -16,20 +16,28 @@
  */
 package org.apache.mina.handler.chain;
 
+import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
 
 /**
- * 
+ * An {@link IoHandler} which executes an {@link IoHandlerCommand} or
+ * an {@link IoHandlerChain} on a <tt>messageReceived</tt> event.
  *
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
 public class ChainedIoHandler extends IoHandlerAdapter
 {
-    private final Command command;
+    private final IoHandlerCommand command;
 
-    public ChainedIoHandler( Command command )
+    /**
+     * Creates a new instance which executes the specified
+     * {@link IoHandlerCommand} on a <tt>messageReceived</tt> event.
+     * 
+     * @param command an {@link IoHandlerCommand} or an {@link IoHandlerChain} to execute
+     */
+    public ChainedIoHandler( IoHandlerCommand command )
     {
         if( command == null )
         {
@@ -37,7 +45,21 @@
         }
         this.command = command;
     }
+    
+    /**
+     * Returns the {@link IoHandlerCommand} this handler will use to
+     * handle <tt>messageReceived</tt> events.
+     */
+    public IoHandlerCommand getCommand()
+    {
+        return command;
+    }
 
+    /**
+     * Handles the specified <tt>messageReceived</tt> event with the
+     * {@link IoHandlerCommand} or {@link IoHandlerChain} you specified
+     * in the constructor.  
+     */
     public void messageReceived( IoSession session, Object message ) throws Exception
     {
         command.execute( null, session, message);

Copied: directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerChain.java
(from r354266, directory/network/trunk/src/java/org/apache/mina/handler/chain/CommandChain.java)
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerChain.java?p2=directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerChain.java&p1=directory/network/trunk/src/java/org/apache/mina/handler/chain/CommandChain.java&r1=354266&r2=354272&rev=354272&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/handler/chain/CommandChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerChain.java Mon
Dec  5 19:26:57 2005
@@ -27,32 +27,32 @@
 import org.apache.mina.common.IoSession;
 
 /**
- * A chain of {@link Command}s.
+ * A chain of {@link IoHandlerCommand}s.
  * 
  * @author The Apache Directory Project
  * @version $Rev$, $Date$
  */
-public class CommandChain implements Command
+public class IoHandlerChain implements IoHandlerCommand
 {
     private static volatile int nextId = 0;
     
     private final int id = nextId++;
-    private final String NEXT_COMMAND = CommandChain.class.getName() + '.' + id + ".nextCommand";
+    private final String NEXT_COMMAND = IoHandlerChain.class.getName() + '.' + id + ".nextCommand";
     private final Map name2entry = new HashMap();
     
     private final Entry head;
     private final Entry tail;
 
-    protected CommandChain()
+    protected IoHandlerChain()
     {
         head = new Entry( null, null, "head", createHeadCommand() );
         tail = new Entry( head, null, "tail", createTailCommand() );
         head.nextEntry = tail;
     }
     
-    private Command createHeadCommand()
+    private IoHandlerCommand createHeadCommand()
     {
-        return new Command()
+        return new IoHandlerCommand()
         {
             public void execute( NextCommand next, IoSession session, Object message ) throws
Exception
             {
@@ -61,9 +61,9 @@
         };
     }
     
-    private Command createTailCommand()
+    private IoHandlerCommand createTailCommand()
     {
-        return new Command()
+        return new IoHandlerCommand()
         {
             public void execute( NextCommand next, IoSession session, Object message ) throws
Exception
             {
@@ -86,7 +86,7 @@
         return e;
     }
     
-    public Command get( String name )
+    public IoHandlerCommand get( String name )
     {
         Entry e = getEntry( name );
         if( e == null )
@@ -109,14 +109,14 @@
     }
     
     public synchronized void addFirst( String name,
-                                       Command command )
+                                       IoHandlerCommand command )
     {
         checkAddable( name );
         register( head, name, command );
     }
 
     public synchronized void addLast( String name,
-                                      Command command )
+                                      IoHandlerCommand command )
     {
         checkAddable( name );
         register( tail.prevEntry, name, command );
@@ -124,7 +124,7 @@
 
     public synchronized void addBefore( String baseName,
                                         String name,
-                                        Command command )
+                                        IoHandlerCommand command )
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
@@ -133,14 +133,14 @@
 
     public synchronized void addAfter( String baseName,
                                        String name,
-                                       Command command )
+                                       IoHandlerCommand command )
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
         register( baseEntry, name, command );
     }
 
-    public synchronized Command remove( String name )
+    public synchronized IoHandlerCommand remove( String name )
     {
         Entry entry = checkOldName( name );
         deregister( entry );
@@ -156,7 +156,7 @@
         }
     }
 
-    private void register( Entry prevEntry, String name, Command command )
+    private void register( Entry prevEntry, String name, IoHandlerCommand command )
     {
         Entry newEntry = new Entry( prevEntry, prevEntry.nextEntry, name, command );
         prevEntry.nextEntry.prevEntry = newEntry;
@@ -255,7 +255,7 @@
         return getEntry( name ) != null;
     }
 
-    public boolean contains( Command command )
+    public boolean contains( IoHandlerCommand command )
     {
         Entry e = head.nextEntry;
         while( e != tail )
@@ -329,12 +329,12 @@
 
         private final String name;
         
-        private final Command command;
+        private final IoHandlerCommand command;
 
         private final NextCommand nextCommand;
         
         private Entry( Entry prevEntry, Entry nextEntry,
-                       String name, Command command )
+                       String name, IoHandlerCommand command )
         {
             if( command == null )
             {
@@ -364,7 +364,7 @@
             return name;
         }
         
-        public Command getCommand()
+        public IoHandlerCommand getCommand()
         {
             return command;
         }

Copied: directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerCommand.java
(from r354266, directory/network/trunk/src/java/org/apache/mina/handler/chain/Command.java)
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerCommand.java?p2=directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerCommand.java&p1=directory/network/trunk/src/java/org/apache/mina/handler/chain/Command.java&r1=354266&r2=354272&rev=354272&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/handler/chain/Command.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/handler/chain/IoHandlerCommand.java Mon
Dec  5 19:26:57 2005
@@ -19,21 +19,21 @@
 import org.apache.mina.common.IoSession;
 
 /**
- * <p>A {@link Command} encapsulates a unit of processing work to be
+ * <p>A {@link IoHandlerCommand} encapsulates a unit of processing work to be
  * performed, whose purpose is to examine and/or modify the state of a
  * transaction that is represented by custom attributes provided by 
- * {@link IoSession}.  Individual {@link Command}s can be assembled into
- * a {@link CommandChain}, which allows them to either complete the
+ * {@link IoSession}.  Individual {@link IoHandlerCommand}s can be assembled into
+ * a {@link IoHandlerChain}, which allows them to either complete the
  * required processing or delegate further processing to the next
- * {@link Command} in the {@link CommandChain}.</p>
+ * {@link IoHandlerCommand} in the {@link IoHandlerChain}.</p>
  *
- * <p>{@link Command} implementations typically retrieve and store state
+ * <p>{@link IoHandlerCommand} implementations typically retrieve and store state
  * information in the {@link IoSession} that is passed as a parameter to
  * the {@link #execute(NextCommand,IoSession,Object)} method, using custom
- * session attributes.  To improve interoperability of {@link Command}
+ * session attributes.  To improve interoperability of {@link IoHandlerCommand}
  * implementations, a useful design pattern is to expose the key values
- * used as JavaBeans properties of the {@link Command} implementation class
- * itself.  For example, a {@link Command} that requires an input and an
+ * used as JavaBeans properties of the {@link IoHandlerCommand} implementation class
+ * itself.  For example, a {@link IoHandlerCommand} that requires an input and an
  * output key might implement the following properties:</p>
  *
  * <pre>
@@ -64,23 +64,23 @@
  * <p>instead of hard coding the attribute name.  The use of the "Key"
  * suffix on such property names is a useful convention to identify properties
  * being used in this fashion, as opposed to JavaBeans properties that simply
- * configure the internal operation of this {@link Command}.</p>
+ * configure the internal operation of this {@link IoHandlerCommand}.</p>
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface Command
+public interface IoHandlerCommand
 {
     /**
      * <p>Execute a unit of processing work to be performed.  This
-     * {@link Command} may either complete the required processing
+     * {@link IoHandlerCommand} may either complete the required processing
      * and just return to stop the processing, or delegate remaining
-     * processing to the next {@link Command} in a {@link CommandChain}
-     * containing this {@link Command} by calling
+     * processing to the next {@link IoHandlerCommand} in a {@link IoHandlerChain}
+     * containing this {@link IoHandlerCommand} by calling
      * {@link NextCommand#execute(IoSession,Object)}.
      *
-     * @param next an indirect reference to the next {@link Command} that
-     *             provides a way to forward the request to the next {@link Command}.
+     * @param next an indirect reference to the next {@link IoHandlerCommand} that
+     *             provides a way to forward the request to the next {@link IoHandlerCommand}.
      * @param session the {@link IoSession} which is associated with 
      *                this request
      * @param message the message object of this request
@@ -91,9 +91,9 @@
     void execute( NextCommand next, IoSession session, Object message ) throws Exception;
     
     /**
-     * Represents an indirect reference to the next {@link Command} of
-     * the {@link CommandChain}.  This interface provides a way to forward
-     * the request to the next {@link Command}.
+     * Represents an indirect reference to the next {@link IoHandlerCommand} of
+     * the {@link IoHandlerChain}.  This interface provides a way to forward
+     * the request to the next {@link IoHandlerCommand}.
      *
      * @author The Apache Directory Project (dev@directory.apache.org)
      * @version $Rev$, $Date$
@@ -101,8 +101,8 @@
     public interface NextCommand
     {
         /**
-         * Forwards the request to the next {@link Command} in the
-         * {@link CommandChain}.
+         * Forwards the request to the next {@link IoHandlerCommand} in the
+         * {@link IoHandlerChain}.
          */
         void execute( IoSession session, Object message ) throws Exception;
     }



Mime
View raw message