mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvermill...@apache.org
Subject git commit: javadoc and examples cleanup
Date Sun, 09 Jun 2013 21:18:18 GMT
Updated Branches:
  refs/heads/trunk 71e8455e4 -> 557b2fa5c


javadoc and examples cleanup


Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/557b2fa5
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/557b2fa5
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/557b2fa5

Branch: refs/heads/trunk
Commit: 557b2fa5ce70adf2814776125cf5c71c064b00fc
Parents: 71e8455
Author: jvermillard <jvermillard@apache.org>
Authored: Sun Jun 9 23:16:30 2013 +0200
Committer: jvermillard <jvermillard@apache.org>
Committed: Sun Jun 9 23:16:30 2013 +0200

----------------------------------------------------------------------
 .../java/org/apache/mina/api/package-info.java  |  4 +-
 .../mina/filter/logging/LoggingFilter.java      |  9 +---
 .../apache/mina/transport/bio/package-info.java | 24 +++++++++
 .../apache/mina/transport/nio/package-info.java | 24 +++++++++
 .../apache/mina/transport/tcp/package-info.java | 25 +++++++++
 .../apache/mina/transport/udp/package-info.java | 25 +++++++++
 .../nio/NioUdpServerFilterEventTest.java        |  7 +--
 .../mina/examples/echoclient/NioEchoClient.java |  3 +-
 .../mina/examples/echoserver/NioEchoServer.java | 56 ++++----------------
 9 files changed, 115 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/core/src/main/java/org/apache/mina/api/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mina/api/package-info.java b/core/src/main/java/org/apache/mina/api/package-info.java
index 3574c43..f90c608 100644
--- a/core/src/main/java/org/apache/mina/api/package-info.java
+++ b/core/src/main/java/org/apache/mina/api/package-info.java
@@ -18,11 +18,11 @@
  *
  */
 
-package org.apache.mina.api;
-
 /**
  * Base API for the MINA library. All those interface and API are the contract with the framework.
  * 
  * For running an {@link org.apache.mina.api.IoService} you need to choose a concrete implementation
in
  * org.apache.mina.transport.
  */
+package org.apache.mina.api;
+

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/core/src/main/java/org/apache/mina/filter/logging/LoggingFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mina/filter/logging/LoggingFilter.java b/core/src/main/java/org/apache/mina/filter/logging/LoggingFilter.java
index a42fa56..2da2920 100644
--- a/core/src/main/java/org/apache/mina/filter/logging/LoggingFilter.java
+++ b/core/src/main/java/org/apache/mina/filter/logging/LoggingFilter.java
@@ -39,9 +39,6 @@ import org.slf4j.LoggerFactory;
  */
 public class LoggingFilter implements IoFilter {
 
-    /** The logger name */
-    private final String name;
-
     /** The logger */
     private final Logger logger;
 
@@ -86,12 +83,10 @@ public class LoggingFilter implements IoFilter {
      */
     public LoggingFilter(final String name) {
         if (name == null) {
-            this.name = LoggingFilter.class.getName();
+            logger = LoggerFactory.getLogger(LoggingFilter.class.getName());
         } else {
-            this.name = name;
+            logger = LoggerFactory.getLogger(name);
         }
-
-        logger = LoggerFactory.getLogger(this.name);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/core/src/main/java/org/apache/mina/transport/bio/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mina/transport/bio/package-info.java b/core/src/main/java/org/apache/mina/transport/bio/package-info.java
new file mode 100644
index 0000000..5af8406
--- /dev/null
+++ b/core/src/main/java/org/apache/mina/transport/bio/package-info.java
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ *
+ */
+
+/**
+ * Transport implementation base on blocking I/O {@link java.net.Socket}
+ */
+package org.apache.mina.transport.bio;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/core/src/main/java/org/apache/mina/transport/nio/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mina/transport/nio/package-info.java b/core/src/main/java/org/apache/mina/transport/nio/package-info.java
new file mode 100644
index 0000000..614c463
--- /dev/null
+++ b/core/src/main/java/org/apache/mina/transport/nio/package-info.java
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ *
+ */
+
+/**
+ * Transport implementations base on NIO (New I/O), {@link java.nio.channels.Channel}
+ */
+package org.apache.mina.transport.nio;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/core/src/main/java/org/apache/mina/transport/tcp/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mina/transport/tcp/package-info.java b/core/src/main/java/org/apache/mina/transport/tcp/package-info.java
new file mode 100644
index 0000000..0dddd36
--- /dev/null
+++ b/core/src/main/java/org/apache/mina/transport/tcp/package-info.java
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ *
+ */
+
+/**
+ * Shared plumber for TCP transport implementations.
+ */
+package org.apache.mina.transport.tcp;
+

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/core/src/main/java/org/apache/mina/transport/udp/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mina/transport/udp/package-info.java b/core/src/main/java/org/apache/mina/transport/udp/package-info.java
new file mode 100644
index 0000000..66d62ac
--- /dev/null
+++ b/core/src/main/java/org/apache/mina/transport/udp/package-info.java
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ *
+ */
+
+/**
+ * Shared plumber UDP transport implementations.
+ */
+package org.apache.mina.transport.udp;
+

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/core/src/test/java/org/apache/mina/transport/nio/NioUdpServerFilterEventTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mina/transport/nio/NioUdpServerFilterEventTest.java
b/core/src/test/java/org/apache/mina/transport/nio/NioUdpServerFilterEventTest.java
index a0da2dd..b9b2f12 100644
--- a/core/src/test/java/org/apache/mina/transport/nio/NioUdpServerFilterEventTest.java
+++ b/core/src/test/java/org/apache/mina/transport/nio/NioUdpServerFilterEventTest.java
@@ -35,8 +35,6 @@ import org.apache.mina.api.IoSession;
 import org.apache.mina.filterchain.ReadFilterChainController;
 import org.apache.mina.filterchain.WriteFilterChainController;
 import org.apache.mina.session.WriteRequest;
-import org.apache.mina.transport.nio.NioUdpServer;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,7 +57,7 @@ public class NioUdpServerFilterEventTest {
     private CountDownLatch msgReadLatch = new CountDownLatch(CLIENT_COUNT);
 
     private CountDownLatch openLatch = new CountDownLatch(CLIENT_COUNT);
-    
+
     @Test
     public void generate_all_kind_of_server_event() throws IOException, InterruptedException
{
         final NioUdpServer server = new NioUdpServer();
@@ -67,9 +65,8 @@ public class NioUdpServerFilterEventTest {
         server.setFilters(new MyCodec(), new Handler());
         server.bind(0);
         // warm up
-        //Thread.sleep(100);
+        // Thread.sleep(100);
 
-        long t0 = System.currentTimeMillis();
         final int port = server.getDatagramChannel().socket().getLocalPort();
 
         final DatagramSocket[] clients = new DatagramSocket[CLIENT_COUNT];

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/examples/src/main/java/org/apache/mina/examples/echoclient/NioEchoClient.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/mina/examples/echoclient/NioEchoClient.java
b/examples/src/main/java/org/apache/mina/examples/echoclient/NioEchoClient.java
index 4941e84..fd89ad9 100644
--- a/examples/src/main/java/org/apache/mina/examples/echoclient/NioEchoClient.java
+++ b/examples/src/main/java/org/apache/mina/examples/echoclient/NioEchoClient.java
@@ -33,7 +33,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * A basic client test
+ * A simple TCP client, write back to the client every received messages.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  * 
@@ -51,7 +51,6 @@ public class NioEchoClient {
             @Override
             public void sessionOpened(final IoSession session) {
                 LOG.info("session opened {}", session);
-
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/mina/blob/557b2fa5/examples/src/main/java/org/apache/mina/examples/echoserver/NioEchoServer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/mina/examples/echoserver/NioEchoServer.java
b/examples/src/main/java/org/apache/mina/examples/echoserver/NioEchoServer.java
index 754dcdb..260258a 100644
--- a/examples/src/main/java/org/apache/mina/examples/echoserver/NioEchoServer.java
+++ b/examples/src/main/java/org/apache/mina/examples/echoserver/NioEchoServer.java
@@ -25,19 +25,14 @@ import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 
 import org.apache.mina.api.AbstractIoHandler;
-import org.apache.mina.api.IdleStatus;
-import org.apache.mina.api.IoFilter;
 import org.apache.mina.api.IoSession;
 import org.apache.mina.filter.logging.LoggingFilter;
-import org.apache.mina.filterchain.ReadFilterChainController;
-import org.apache.mina.filterchain.WriteFilterChainController;
-import org.apache.mina.session.WriteRequest;
 import org.apache.mina.transport.nio.NioTcpServer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * A basic Server test
+ * A simple TCP server, write back to the client every received messages.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  * 
@@ -51,46 +46,8 @@ public class NioEchoServer {
 
         final NioTcpServer acceptor = new NioTcpServer();
 
-        // create the fitler chain for this service
-        acceptor.setFilters(new LoggingFilter("LoggingFilter1"), new IoFilter() {
-
-            @Override
-            public void sessionOpened(final IoSession session) {
-                LOG.info("session {} open", session);
-            }
-
-            @Override
-            public void sessionIdle(final IoSession session, final IdleStatus status) {
-                LOG.info("session {} idle", session);
-            }
-
-            @Override
-            public void sessionClosed(final IoSession session) {
-                LOG.info("session {} open", session);
-            }
-
-            @Override
-            public void messageWriting(final IoSession session, WriteRequest message,
-                    final WriteFilterChainController controller) {
-                // we just push the message in the chain
-                controller.callWriteNextFilter(message);
-            }
-
-            @Override
-            public void messageReceived(final IoSession session, final Object message,
-                    final ReadFilterChainController controller) {
-
-                if (message instanceof ByteBuffer) {
-                    LOG.info("echoing");
-                    session.write(message);
-                }
-            }
-
-            @Override
-            public void messageSent(final IoSession session, final Object message) {
-                LOG.info("message {} sent", message);
-            }
-        });
+        // create the filter chain for this service
+        acceptor.setFilters(new LoggingFilter("LoggingFilter1"));
 
         acceptor.setIoHandler(new AbstractIoHandler() {
             @Override
@@ -102,7 +59,14 @@ public class NioEchoServer {
                 bf.put(welcomeStr.getBytes());
                 bf.flip();
                 session.write(bf);
+            }
 
+            @Override
+            public void messageReceived(IoSession session, Object message) {
+                if (message instanceof ByteBuffer) {
+                    LOG.info("echoing");
+                    session.write(message);
+                }
             }
         });
         try {


Mime
View raw message