directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r123611 - in incubator/directory/network/trunk/mina: src/examples/org/apache/mina/examples/tennis src/examples/org/apache/mina/examples/vmpipe src/java/org/apache/mina/io src/java/org/apache/mina/protocol/vmpipe xdocs
Date Wed, 29 Dec 2004 09:16:59 GMT
Author: trustin
Date: Wed Dec 29 01:16:58 2004
New Revision: 123611

URL: http://svn.apache.org/viewcvs?view=rev&rev=123611
Log:
Added documentation for in-VM pipe support
Added:
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/
      - copied from r123602, incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/package.html
  (contents, props changed)
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/package.html
  (contents, props changed)
Removed:
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/
Modified:
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/Main.java
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisBall.java
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
   incubator/directory/network/trunk/mina/xdocs/index.xml

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/Main.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/Main.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/Main.java&r1=123602&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/Main.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/Main.java
(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/Main.java
Wed Dec 29 01:16:58 2004
@@ -1,9 +1,7 @@
 /*
  * @(#) $Id$
  */
-package org.apache.mina.examples.vmpipe;
-
-import java.io.IOException;
+package org.apache.mina.examples.tennis;
 
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
@@ -12,7 +10,15 @@
 import org.apache.mina.protocol.vmpipe.VmPipeConnector;
 
 /**
- * TODO Document me.
+ * (<b>Entry point</b>) An 'in-VM pipe' example which simulates a tennis game
+ * between client and server.
+ * <ol>
+ *   <li>Client connects to server</li>
+ *   <li>At first, client sends {@link TennisBall} with TTL value '10'.</li>
+ *   <li>Received side (either server or client) decreases the TTL value of the
+ *     received ball, and returns it to remote peer.</li>
+ *   <li>Who gets the ball with 0 TTL loses.</li>
+ * </ol> 
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
@@ -20,7 +26,7 @@
 public class Main
 {
 
-    public static void main( String[] args ) throws IOException
+    public static void main( String[] args ) throws Exception
     {
         VmPipeAddress address = new VmPipeAddress( 8080 );
 
@@ -28,16 +34,26 @@
         ProtocolThreadPoolFilter threadPool = new ProtocolThreadPoolFilter();
         threadPool.start();
 
-        // set up server
+        // Set up server
         VmPipeAcceptor acceptor = new VmPipeAcceptor();
         acceptor.bind( address, new TennisPlayer() );
         acceptor.addFilter( 0, threadPool );
 
-        // send ping message
+        // Connect to the server.
         VmPipeConnector connector = new VmPipeConnector();
         ProtocolSession session = connector.connect( address,
                                                      new TennisPlayer() );
 
+        // Send the first ping message
         session.write( new TennisBall( 10 ) );
+
+        // Wait until the match ends.
+        while( session.isConnected() )
+        {
+            Thread.sleep( 100 );
+        }
+
+        // Stop the thread pool
+        threadPool.stop();
     }
 }

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisBall.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisBall.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/TennisBall.java&r1=123602&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisBall.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/TennisBall.java
(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisBall.java
Wed Dec 29 01:16:58 2004
@@ -1,10 +1,11 @@
 /*
  * @(#) $Id$
  */
-package org.apache.mina.examples.vmpipe;
+package org.apache.mina.examples.tennis;
 
 /**
- * TODO Document me.
+ * A tennis ball which has TTL value and state whose value is one of 'PING' and
+ * 'PONG'.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
@@ -15,27 +16,44 @@
 
     private final int ttl;
 
+    /**
+     * Creates a new ball with the specified TTL (Time To Live) value.
+     */
     public TennisBall( int ttl )
     {
         this( ttl, true );
     }
 
+    /**
+     * Creates a new ball with the specified TTL value and PING/PONG state.
+     */
     private TennisBall( int ttl, boolean ping )
     {
         this.ttl = ttl;
         this.ping = ping;
     }
 
+    /**
+     * Returns the TTL value of this ball.
+     */
     public int getTTL()
     {
         return ttl;
     }
 
+    /**
+     * Returns the ball after {@link TennisPlayer}'s stroke.
+     * The returned ball has decreased TTL value and switched PING/PONG state.
+     */
     public TennisBall stroke()
     {
         return new TennisBall( ttl - 1, !ping );
     }
 
+    /**
+     * Returns string representation of this message (<code>[PING|PONG]
+     * (TTL)</code>).
+     */
     public String toString()
     {
         if( ping )

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/TennisPlayer.java&r1=123602&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/vmpipe/TennisPlayer.java
(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
Wed Dec 29 01:16:58 2004
@@ -1,13 +1,14 @@
 /*
  * @(#) $Id$
  */
-package org.apache.mina.examples.vmpipe;
+package org.apache.mina.examples.tennis;
 
+import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolHandlerAdapter;
 import org.apache.mina.protocol.ProtocolSession;
 
 /**
- * TODO Document me.
+ * A {@link ProtocolHandler} implementation which plays a tennis game.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
@@ -16,6 +17,7 @@
 {
     private static int nextId = 0;
 
+    /** Player ID **/
     private final int id = nextId++;
 
     public void sessionOpened( ProtocolSession session )
@@ -33,13 +35,18 @@
         System.out.println( "Player-" + id + ": RCVD " + message );
 
         TennisBall ball = ( TennisBall ) message;
+
+        // Stroke: TTL decreases and PING/PONG state changes.
         ball = ball.stroke();
+
         if( ball.getTTL() > 0 )
         {
+            // If the ball is still alive, pass it back to peer.
             session.write( ball );
         }
         else
         {
+            // If the ball is dead, this player loses.
             System.out.println( "Player-" + id + ": LOSE" );
             session.close();
         }

Added: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/package.html
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/package.html?view=auto&rev=123611
==============================================================================
--- (empty file)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/tennis/package.html
Wed Dec 29 01:16:58 2004
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body>
+Two tennis players play a game.
+</body>
+</html>

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java&r1=123610&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java	Wed
Dec 29 01:16:58 2004
@@ -51,8 +51,8 @@
 {
     /**
      * Connects to the specified <code>address</code>.  If communication starts
-     * successfully, use the specified <code>defaultHandler</code>.  This method
-     * blocks.
+     * successfully, events are fired to the specified
+     * <code>defaultHandler</code>.  This method blocks.
      * 
      * @throws IOException if failed to connect
      */
@@ -61,7 +61,7 @@
 
     /**
      * Connects to the specified <code>address</code> with timeout.  If
-     * communication starts successfully, use the specified
+     * communication starts successfully, events are fired to the specified
      * <code>defaultHandler</code>.  This method blocks.
      * 
      * @throws IOException if failed to connect

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java&r1=123610&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
Wed Dec 29 01:16:58 2004
@@ -24,11 +24,20 @@
 
     private final ProtocolHandlerFilterManager filterManager = new ProtocolHandlerFilterManager();
 
+    /**
+     * Creates a new instance.
+     */
     public VmPipeAcceptor()
     {
         filterManager.addFilter( Integer.MIN_VALUE, new VmPipeFilter() );
     }
 
+    /**
+     * Binds to the specified <code>address</code> and handles incoming
+     * connections with the specified <code>defaultHandler</code>.
+     * 
+     * @throws IOException if failed to bind
+     */
     public void bind( VmPipeAddress address, ProtocolHandler defaultHandler )
             throws IOException
     {
@@ -49,6 +58,9 @@
         }
     }
 
+    /**
+     * Unbinds from the specified <code>address</code>.
+     */
     public void unbind( VmPipeAddress address )
     {
         if( address == null )

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java&r1=123610&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
Wed Dec 29 01:16:58 2004
@@ -21,11 +21,19 @@
 {
     private final ProtocolHandlerFilterManager filterManager = new ProtocolHandlerFilterManager();
 
+    /**
+     * Creates a new instance.
+     */
     public VmPipeConnector()
     {
         filterManager.addFilter( Integer.MIN_VALUE, new VmPipeFilter() );
     }
 
+    /**
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, events are fired to the specified
+     * <code>defaultHandler</code>.  This method blocks.
+     */
     public ProtocolSession connect( VmPipeAddress address,
                                    ProtocolHandler defaultHandler )
             throws IOException

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java&r1=123610&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java
Wed Dec 29 01:16:58 2004
@@ -39,14 +39,4 @@
 
         nextHandler.messageSent( session, message );
     }
-
-    public void sessionClosed( ProtocolHandler nextHandler,
-                              ProtocolSession session )
-    {
-        VmPipeSession vps = ( VmPipeSession ) session;
-        nextHandler.sessionClosed( session );
-
-        if( vps.remoteSession.isConnected() )
-            vps.remoteFilterManager.fireSessionClosed( vps.remoteSession );
-    }
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java&r1=123610&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java
Wed Dec 29 01:16:58 2004
@@ -39,6 +39,11 @@
 
     private class Worker extends Thread
     {
+        private Worker()
+        {
+            super( "VmPipeIdleStatusChecker" );
+            setDaemon( true );
+        }
 
         public void run()
         {

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java&r1=123610&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
Wed Dec 29 01:16:58 2004
@@ -109,9 +109,11 @@
     {
         synchronized( lock )
         {
-            if( remoteSession.closed )
+            if( closed )
                 return;
-            remoteSession.closed = true;
+
+            closed = remoteSession.closed = true;
+            localFilterManager.fireSessionClosed( this );
             remoteFilterManager.fireSessionClosed( remoteSession );
         }
     }

Added: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/package.html
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/package.html?view=auto&rev=123611
==============================================================================
--- (empty file)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/vmpipe/package.html
Wed Dec 29 01:16:58 2004
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body>
+In-VM pipe support which removes the overhead of local loopback communication.
+
+<h1>What is 'in-VM pipe'?</h1>
+<p>
+    In-VM pipe is a direct event forwarding mechanism between two
+	<a href="ProtocolHandlder.html"><code>ProtocolHandler</code></a>s
in the
+    same Java Virtual Machine.  Using in-VM pipe, you can remove the overhead
+    of encoding and decoding which is caused uselessly by local loopback
+    network communication.  Here are some useful situations possible:
+    <ul>
+        <li>SMTP server and SPAM filtering server,</li>
+        <li>web server and Servlet/JSP container.</li>
+    </ul>
+</p>
+<p>
+    Please refer to
+    <a href="../../../../../xref-examples/org/apache/mina/examples/tennis/Main.html">Tennis</a>
+    example.
+</p>
+</body>
+</html>

Modified: incubator/directory/network/trunk/mina/xdocs/index.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/xdocs/index.xml?view=diff&rev=123611&p1=incubator/directory/network/trunk/mina/xdocs/index.xml&r1=123610&p2=incubator/directory/network/trunk/mina/xdocs/index.xml&r2=123611
==============================================================================
--- incubator/directory/network/trunk/mina/xdocs/index.xml	(original)
+++ incubator/directory/network/trunk/mina/xdocs/index.xml	Wed Dec 29 01:16:58 2004
@@ -1,39 +1,66 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 <document>
-	<properties>
-		<author email="trustin@apache.org">Trustin Lee</author>
-		<title>Overview</title>
-	</properties>
+    <properties>
+        <author email="trustin@apache.org">Trustin Lee</author>
+        <title>Overview</title>
+    </properties>
 
-	<body>
-		<section name="Introduction">
-			<p>
-				MINA (Multipurpose Infrastructure for Network Applications) is a
-				network application framework which helps users develop high
-				performance and high scalability network applications easily.
-			</p>
-			<p>
-				MINA will be a simple yet full-featured network application which
-				provides:
-				<ul>
-					<li>Support for TCP and UDP transport types,</li>
-					<li>Support for both server (inetd-like) and client side,</li>
-					<li>Unit testability,</li>
-					<li>JMX managability,</li>
-					<li>Traffic throttling,</li>
-					<li>Overload shielding,</li>
-					<li>Integration with well known containers such as Spring and OSGi,
-						</li>
-				</ul>
-			</p>
-		</section>
+    <body>
+        <section name="Introduction">
+            <p>
+                MINA (Multipurpose Infrastructure for Network Applications) is a
+                network application framework which helps users develop high
+                performance and high scalability network applications easily.
+            </p>
+            <p>
+                MINA will be a simple yet full-featured network application which
+                provides:
+                <ul>
+                    <li>Support for TCP and UDP transport types,</li>
+                    <li>Support for both server (inetd-like) and client side,</li>
+                    <li>Unit testability,</li>
+                    <li>JMX managability,</li>
+                    <li>Traffic throttling,</li>
+                    <li>Overload shielding,</li>
+                    <li>Integration with well known containers such as Spring and OSGi,
+                        </li>
+                </ul>
+            </p>
+        </section>
 		
-		<section name="Getting Started">
-			<p>
-				Tutorial is under construction.  Please start from
-				<a href="xref-examples/index.html">examples</a> referring
-				to <a href="apidocs/index.html">JavaDocs</a>.
-			</p>
-		</section>
-	</body>
+        <section name="Getting Started">
+            <p>
+                Tutorial is under construction.  Please start from
+                <a href="xref-examples/index.html">examples</a> referring
+                to <a href="apidocs/index.html">JavaDocs</a>.
+                <table>
+                    <tr>
+                        <th>Name</th>
+                        <th>Feature it demonstrates</th>
+                        <th>Side</th>
+                    </tr>
+                    <tr>
+                        <td><a href="xref-examples/org/apache/mina/examples/reverser/index.html">Reverser</a></td>
+                        <td>High-level protocol layer</td>
+                        <td>Server</td>
+                    </tr>
+                    <tr>
+                        <td><a href="xref-examples/org/apache/mina/examples/echoserver/index.html">Echo
server</a></td>
+                        <td>Low-level I/O layer</td>
+                        <td>Server</td>
+                    </tr>
+                    <tr>
+                        <td><a href="xref-examples/org/apache/mina/examples/netcat/index.html">NetCat</a></td>
+                        <td>Low-level I/O layer</td>
+                        <td>Client</td>
+                    </tr>
+                    <tr>
+                        <td><a href="xref-examples/org/apache/mina/examples/tennis/index.html">Tennis</a></td>
+                        <td>In-VM pipe support in protocol layer.</td>
+                        <td>Both</td>
+                    </tr>
+                </table>
+            </p>
+        </section>
+    </body>
 </document>

Mime
View raw message