Author: elecharny
Date: Tue Jul  8 02:56:46 2008
New Revision: 674758

URL: http://svn.apache.org/viewvc?rev=674758&view=rev
Log:
Added some more javadoc and comments

Modified:
    
mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java

Modified: 
mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
URL: 
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java?rev=674758&r1=674757&r2=674758&view=diff
==============================================================================
--- 
mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
 (original)
+++ 
mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
 Tue Jul  8 02:56:46 2008
@@ -54,13 +54,49 @@
 
 /**
  * Base implementation of [EMAIL PROTECTED] IoService}s.
+ * 
+ * An instance of IoService contains an Executor which will handle the incoming
+ * events.
  *
  * @author The Apache MINA Project ([EMAIL PROTECTED])
  * @version $Rev$, $Date$
  */
 public abstract class AbstractIoService implements IoService {
+    /** 
+     * The unique number identifying the Service. It's incremented
+     * for each new IoService created.
+     */
     private static final AtomicInteger id = new AtomicInteger();
 
+    /** The thread name built from the IoService unherited 
+     * instance class name and the IoService Id 
+     **/
+    private final String threadName;
+    
+    /**
+     * The associated executor, responsible for handling execution of I/O 
events.
+     */
+    private final Executor executor;
+
+    /**
+     * A flag used to indicate that the local executor has been created
+     * inside this instance, and not passed by a caller.
+     * 
+     * If the executor is locally created, then it will be an instance
+     * of the ThreadPoolExecutor class.
+     */
+    private final boolean createdExecutor;
+
+    /**
+     * The IoHandler in charge of managing all the I/O Events. It is 
+     */
+    private IoHandler handler;
+
+    /**
+     * The default [EMAIL PROTECTED] IoSessionConfig} which will be used to 
configure new sessions.
+     */
+    private final IoSessionConfig sessionConfig;
+
     private final IoServiceListener serviceActivationListener =
         new IoServiceListener() {
             public void serviceActivated(IoService service) {
@@ -88,11 +124,6 @@
      */
     private IoFilterChainBuilder filterChainBuilder = new 
DefaultIoFilterChainBuilder();
 
-    /**
-     * Current handler.
-     */
-    private IoHandler handler;
-
     private IoSessionDataStructureFactory sessionDataStructureFactory =
         new DefaultIoSessionDataStructureFactory();
 
@@ -101,10 +132,6 @@
      */
     private final IoServiceListenerSupport listeners;
 
-    private final Executor executor;
-    private final String threadName;
-    private final boolean createdExecutor;
-
     /**
      * A lock object which must be acquired when related resources are
      * destroyed.
@@ -156,14 +183,9 @@
     private long lastIdleTimeForWrite;
 
     /**
-     * The default [EMAIL PROTECTED] IoSessionConfig} which will be used to 
configure new sessions.
-     */
-    private final IoSessionConfig sessionConfig;
-
-    /**
         * Constructor for [EMAIL PROTECTED] AbstractIoService}. You need to 
provide a default
         * session configuration and an [EMAIL PROTECTED] Executor} for 
handling I/O events. If
-        * null [EMAIL PROTECTED] Executor} is provided, a default one will be 
created using
+        * a null [EMAIL PROTECTED] Executor} is provided, a default one will 
be created using
         * [EMAIL PROTECTED] Executors#newCachedThreadPool()}.
         * 
         * @param sessionConfig
@@ -176,6 +198,10 @@
         if (sessionConfig == null) {
             throw new NullPointerException("sessionConfig");
         }
+        
+        if (getTransportMetadata() == null) {
+            throw new NullPointerException("TransportMetadata");
+        }
 
         if (!getTransportMetadata().getSessionConfigType().isAssignableFrom(
                 sessionConfig.getClass())) {
@@ -184,8 +210,12 @@
                     + getTransportMetadata().getSessionConfigType() + ")");
         }
 
+        // Create the listeners, and add a first listener : a activation 
listener
+        // for this service, which will give information on the service state.
         listeners = new IoServiceListenerSupport(this);
         listeners.add(serviceActivationListener);
+        
+        // Stores the given session configuration
         this.sessionConfig = sessionConfig;
 
         // Make JVM load the exception monitor before some transports
@@ -298,6 +328,7 @@
         if (disposalFuture != null) {
             disposalFuture.awaitUninterruptibly();
         }
+        
         if (createdExecutor) {
             ExecutorService e = (ExecutorService) executor;
             e.shutdown();
@@ -359,7 +390,7 @@
      */
     public final void setHandler(IoHandler handler) {
         if (handler == null) {
-            throw new NullPointerException("handler");
+            throw new NullPointerException("handler cannot be null");
         }
 
         if (isActive()) {


Reply via email to