directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Directory Wiki] Update of "MinaTutorial" by sishen
Date Tue, 31 Oct 2006 09:40:06 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Directory Wiki" for change notification.

The following page has been changed by sishen:
http://wiki.apache.org/directory/MinaTutorial

The comment on the change is:
port EchoServer code from 0.8 to 1.0.x by sishen.

------------------------------------------------------------------------------
          session.close();
      }
  
+ 
+ ---- /!\ '''Edit conflict - other version:''' ----
      public void messageReceived( IoSession session, Object message )
+ 
+ ---- /!\ '''Edit conflict - your version:''' ----
+     public void messageReceived( IoSession session, Object message )
+ 
+ ---- /!\ '''End of edit conflict''' ----
      {
          if (!(message instanceof ByteBuffer))
              return;
@@ -100, +107 @@

  You’ve just implemented echo protocol with MINA.  Now you need to bind your handler to
a server port:
  
  {{{
+ 
+ ---- /!\ '''Edit conflict - other version:''' ----
  import java.net.InetSocketAddress;
  import org.apache.mina.transport.socket.nio.SocketAcceptor;
  import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
  
+ ---- /!\ '''Edit conflict - your version:''' ----
+ import java.net.InetSocketAddress;
+ import org.apache.mina.transport.socket.nio.SocketAcceptor;
+ import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+ 
+ ---- /!\ '''End of edit conflict''' ----
+ 
  public class Main
  {
      /** Choose your favorite port number. */
@@ -112, +128 @@

  
      public static void main( String[] args ) throws Exception
      {
+ 
+ ---- /!\ '''Edit conflict - other version:''' ----
          SocketAcceptor acceptor = new SocketAcceptor();
          SocketAcceptorConfig defaultConfig = new SocketAcceptorConfig();
          defaultConfig.setReuseAddress(true);
@@ -119, +137 @@

          // Bind
          acceptor.bind(new InetSocketAddress(PORT), new EchoProtocolHandler(), defaultConfig);
  
+ ---- /!\ '''Edit conflict - your version:''' ----
+         SocketAcceptor acceptor = new SocketAcceptor();
+         SocketAcceptorConfig defaultConfig = new SocketAcceptorConfig();
+         defaultConfig.setReuseAddress(true);
+      
+         // Bind
+         acceptor.bind(new InetSocketAddress(PORT), new EchoProtocolHandler(), defaultConfig);
+ 
+ ---- /!\ '''End of edit conflict''' ----
+ 
          System.out.println( "Listening on port " + PORT );
      }
  }
@@ -138, +166 @@

  Our echo protocol handler doesn’t log any I/O events.  We could log them by adding a filter
that logs them.  MINA, fortunately, provides IoLoggingFilter that provides that functionality.
 Let’s add a logging filter to ServiceRegistry.
  
  {{{
+ 
+ ---- /!\ '''Edit conflict - other version:''' ----
  ....
  DefaultIoFilterChainBuilder chain = config.getFilterChain();
  addLogger(chain);
@@ -146, +176 @@

  private static void addLogger( DefaultIoFilterChainBuilder chain ) throws Exception
  {
      chain.addLast( "logger", new LoggingFilter() );
-     System.out.println( "Logging ON" );
- }
- }}}
  
+ ---- /!\ '''Edit conflict - your version:''' ----
- What about SSL?  MINA also provides an SSL filter that works in Java 5 or above.
- 
- {{{
  ....
  DefaultIoFilterChainBuilder chain = config.getFilterChain();
  addLogger(chain);
  ....
  
+ private static void addLogger( DefaultIoFilterChainBuilder chain ) throws Exception
+ {
+     chain.addLast( "logger", new LoggingFilter() );
+ 
+ ---- /!\ '''End of edit conflict''' ----
+     System.out.println( "Logging ON" );
+ }
+ }}}
+ 
+ What about SSL?  MINA also provides an SSL filter that works in Java 5 or above.
+ 
+ {{{
+ 
+ ---- /!\ '''Edit conflict - other version:''' ----
+ ....
+ DefaultIoFilterChainBuilder chain = config.getFilterChain();
+ addLogger(chain);
+ ....
+ 
  private static void addSSLSupport( DefaultIoFilterChainBuilder chain )
      throws Exception
+ 
+ ---- /!\ '''Edit conflict - your version:''' ----
+ ....
+ DefaultIoFilterChainBuilder chain = config.getFilterChain();
+ addLogger(chain);
+ ....
+ 
+ private static void addSSLSupport( DefaultIoFilterChainBuilder chain )
+     throws Exception
+ 
+ ---- /!\ '''End of edit conflict''' ----
  {
      SSLFilter sslFilter =
          new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
+ 
+ ---- /!\ '''Edit conflict - other version:''' ----
      chain.addLast( "sslFilter", sslFilter );
+ 
+ ---- /!\ '''Edit conflict - your version:''' ----
+     chain.addLast( "sslFilter", sslFilter );
+ 
+ ---- /!\ '''End of edit conflict''' ----
      System.out.println( "SSL ON" );
  }
  }}}

Mime
View raw message