directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r448115 - in /directory/trunks/mina/core/src/main/java/org/apache/mina: common/ common/support/ transport/socket/nio/ transport/socket/nio/support/
Date Wed, 20 Sep 2006 07:55:48 GMT
Author: trustin
Date: Wed Sep 20 00:55:47 2006
New Revision: 448115

URL: http://svn.apache.org/viewvc?view=rev&rev=448115
Log:
* Added DatagramServiceConfig
* Moved IoServiceConfig.sessionRecycler to DatagramServiceConfig

Added:
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceConfig.java
Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoServiceConfig.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoServiceConfig.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptorConfig.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnectorConfig.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoServiceConfig.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoServiceConfig.java?view=diff&rev=448115&r1=448114&r2=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoServiceConfig.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoServiceConfig.java Wed
Sep 20 00:55:47 2006
@@ -82,19 +82,6 @@
     void setThreadModel( ThreadModel threadModel );
     
     /**
-     * Sets the {@link IoSessionRecycler} for this service. Please note that this
-     * recycler will only be applied to connectionless transports.
-     * 
-     * @param sessionRecycler <tt>null</tt> to use the default recycler
-     */
-    void setSessionRecycler( IoSessionRecycler sessionRecycler );
-
-    /**
-     * Returns the {@link IoSessionRecycler} for this service.
-     */
-    IoSessionRecycler getSessionRecycler();
-    
-    /**
      * Returns a deep clone of this configuration.
      */
     Object clone();

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoServiceConfig.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoServiceConfig.java?view=diff&rev=448115&r1=448114&r2=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoServiceConfig.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoServiceConfig.java
Wed Sep 20 00:55:47 2006
@@ -22,11 +22,9 @@
 import java.lang.reflect.Method;
 
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
-import org.apache.mina.common.ExpiringSessionRecycler;
+import org.apache.mina.common.ExecutorThreadModel;
 import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoServiceConfig;
-import org.apache.mina.common.ExecutorThreadModel;
-import org.apache.mina.common.IoSessionRecycler;
 import org.apache.mina.common.ThreadModel;
 
 /**
@@ -37,8 +35,6 @@
  */
 public abstract class BaseIoServiceConfig implements IoServiceConfig, Cloneable
 {
-    private static final IoSessionRecycler DEFAULT_RECYCLER = new ExpiringSessionRecycler();
-    
     /**
      * Current filter chain builder.
      */
@@ -54,11 +50,6 @@
      */
     private ThreadModel threadModel = defaultThreadModel;
     
-    /**
-     * Current session recycler
-     */
-    private IoSessionRecycler sessionRecycler = DEFAULT_RECYCLER;
-
     public BaseIoServiceConfig()
     {
         super();
@@ -107,21 +98,6 @@
         this.threadModel = threadModel;
     }
     
-    // FIXME There can be a problem if a user changes the recycler after the service is activated.
-    public void setSessionRecycler( IoSessionRecycler sessionRecycler )
-    {
-        if( sessionRecycler == null )
-        {
-            sessionRecycler = DEFAULT_RECYCLER;
-        }
-        this.sessionRecycler = sessionRecycler;
-    }
-    
-    public IoSessionRecycler getSessionRecycler()
-    {
-        return sessionRecycler;
-    }
-
     public Object clone()
     {
         BaseIoServiceConfig ret;

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptorConfig.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptorConfig.java?view=diff&rev=448115&r1=448114&r2=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptorConfig.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptorConfig.java
Wed Sep 20 00:55:47 2006
@@ -20,8 +20,10 @@
 package org.apache.mina.transport.socket.nio;
 
 
+import org.apache.mina.common.ExpiringSessionRecycler;
 import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.common.IoSessionConfig;
+import org.apache.mina.common.IoSessionRecycler;
 import org.apache.mina.common.RuntimeIOException;
 import org.apache.mina.common.support.BaseIoAcceptorConfig;
 import org.apache.mina.transport.socket.nio.support.DatagramSessionConfigImpl;
@@ -32,8 +34,15 @@
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class DatagramAcceptorConfig extends BaseIoAcceptorConfig implements IoAcceptorConfig
+public class DatagramAcceptorConfig extends BaseIoAcceptorConfig implements DatagramServiceConfig
 {
+    private static final IoSessionRecycler DEFAULT_RECYCLER = new ExpiringSessionRecycler();
+    
+    /**
+     * Current session recycler
+     */
+    private IoSessionRecycler sessionRecycler = DEFAULT_RECYCLER;
+
     private DatagramSessionConfig sessionConfig = new DatagramSessionConfigImpl();
 
     /**
@@ -51,6 +60,21 @@
         return sessionConfig;
     }
     
+    public IoSessionRecycler getSessionRecycler()
+    {
+        return sessionRecycler;
+    }
+
+    // FIXME There can be a problem if a user changes the recycler after the service is activated.
+    public void setSessionRecycler( IoSessionRecycler sessionRecycler )
+    {
+        if( sessionRecycler == null )
+        {
+            sessionRecycler = DEFAULT_RECYCLER;
+        }
+        this.sessionRecycler = sessionRecycler;
+    }
+
     public Object clone()
     {
         DatagramAcceptorConfig ret = ( DatagramAcceptorConfig ) super.clone();

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnectorConfig.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnectorConfig.java?view=diff&rev=448115&r1=448114&r2=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnectorConfig.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnectorConfig.java
Wed Sep 20 00:55:47 2006
@@ -19,8 +19,10 @@
  */
 package org.apache.mina.transport.socket.nio;
 
+import org.apache.mina.common.ExpiringSessionRecycler;
 import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.common.IoSessionConfig;
+import org.apache.mina.common.IoSessionRecycler;
 import org.apache.mina.common.RuntimeIOException;
 import org.apache.mina.common.support.BaseIoConnectorConfig;
 import org.apache.mina.transport.socket.nio.support.DatagramSessionConfigImpl;
@@ -31,9 +33,16 @@
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class DatagramConnectorConfig extends BaseIoConnectorConfig
+public class DatagramConnectorConfig extends BaseIoConnectorConfig implements DatagramServiceConfig
 {
-    private final DatagramSessionConfig sessionConfig = new DatagramSessionConfigImpl();
+    private static final IoSessionRecycler DEFAULT_RECYCLER = new ExpiringSessionRecycler();
+    
+    /**
+     * Current session recycler
+     */
+    private IoSessionRecycler sessionRecycler = DEFAULT_RECYCLER;
+
+    private DatagramSessionConfig sessionConfig = new DatagramSessionConfigImpl();
 
     /**
      * Creates a new instance.
@@ -49,5 +58,27 @@
     public IoSessionConfig getSessionConfig()
     {
         return sessionConfig;
+    }
+
+    public IoSessionRecycler getSessionRecycler()
+    {
+        return sessionRecycler;
+    }
+
+    // FIXME There can be a problem if a user changes the recycler after the service is activated.
+    public void setSessionRecycler( IoSessionRecycler sessionRecycler )
+    {
+        if( sessionRecycler == null )
+        {
+            sessionRecycler = DEFAULT_RECYCLER;
+        }
+        this.sessionRecycler = sessionRecycler;
+    }
+
+    public Object clone()
+    {
+        DatagramConnectorConfig ret = ( DatagramConnectorConfig ) super.clone();
+        ret.sessionConfig = ( DatagramSessionConfig ) this.sessionConfig.clone();
+        return ret;
     }
 }

Added: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceConfig.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceConfig.java?view=auto&rev=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceConfig.java
(added)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceConfig.java
Wed Sep 20 00:55:47 2006
@@ -0,0 +1,37 @@
+/*
+ *  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. 
+ *  
+ */
+package org.apache.mina.transport.socket.nio;
+
+import org.apache.mina.common.IoSessionRecycler;
+
+public interface DatagramServiceConfig
+{
+    /**
+     * Returns the {@link IoSessionRecycler} for this service.
+     */
+    IoSessionRecycler getSessionRecycler();
+
+    /**
+     * Sets the {@link IoSessionRecycler} for this service.
+     * 
+     * @param sessionRecycler <tt>null</tt> to use the default recycler
+     */
+    void setSessionRecycler( IoSessionRecycler sessionRecycler );
+}

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java?view=diff&rev=448115&r1=448114&r2=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
Wed Sep 20 00:55:47 2006
@@ -35,17 +35,19 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionRecycler;
+import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoAcceptor;
 import org.apache.mina.common.support.IoServiceListenerSupport;
 import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig;
+import org.apache.mina.transport.socket.nio.DatagramServiceConfig;
 import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.NamePreservingRunnable;
 import org.apache.mina.util.Queue;
+
 import edu.emory.mathcs.backport.java.util.concurrent.Executor;
 
 /**
@@ -215,7 +217,7 @@
 
         RegistrationRequest req = ( RegistrationRequest ) key.attachment();
         IoSession session;
-        IoSessionRecycler sessionRecycler = req.config.getSessionRecycler();
+        IoSessionRecycler sessionRecycler = getSessionRecycler( req );
         synchronized ( sessionRecycler )
         {
             session = sessionRecycler.recycle( localAddress, remoteAddress);
@@ -232,7 +234,7 @@
             datagramSession.setRemoteAddress( remoteAddress );
             datagramSession.setSelectionKey( key );
             
-            req.config.getSessionRecycler().put( datagramSession );
+            getSessionRecycler( req ).put( datagramSession );
             session = datagramSession;
         }
         
@@ -247,6 +249,20 @@
         }
         
         return session;
+    }
+
+    private IoSessionRecycler getSessionRecycler( RegistrationRequest req )
+    {
+        IoSessionRecycler sessionRecycler;
+        if( req.config instanceof DatagramServiceConfig )
+        {
+            sessionRecycler = ( ( DatagramServiceConfig ) req.config ).getSessionRecycler();
+        }
+        else
+        {
+            sessionRecycler = defaultConfig.getSessionRecycler();
+        }
+        return sessionRecycler;
     }
     
     public IoServiceListenerSupport getListeners()

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java?view=diff&rev=448115&r1=448114&r2=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
Wed Sep 20 00:55:47 2006
@@ -28,23 +28,25 @@
 import java.util.Iterator;
 import java.util.Set;
 
-import edu.emory.mathcs.backport.java.util.concurrent.Executor;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionRecycler;
+import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoConnector;
 import org.apache.mina.common.support.DefaultConnectFuture;
 import org.apache.mina.transport.socket.nio.DatagramConnectorConfig;
+import org.apache.mina.transport.socket.nio.DatagramServiceConfig;
 import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.NamePreservingRunnable;
 import org.apache.mina.util.Queue;
 
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+
 /**
  * {@link IoConnector} for datagram transport (UDP/IP).
  * 
@@ -413,7 +415,7 @@
     
     private DatagramSessionImpl getRecycledSession( IoSession session )
     {
-        IoSessionRecycler sessionRecycler = session.getServiceConfig().getSessionRecycler();
+        IoSessionRecycler sessionRecycler = getSessionRecycler( session );
         DatagramSessionImpl replaceSession = null;
 
         if ( sessionRecycler != null )
@@ -433,6 +435,21 @@
         }
 
         return null;
+    }
+    
+    private IoSessionRecycler getSessionRecycler( IoSession session )
+    {
+        IoServiceConfig config = session.getServiceConfig();
+        IoSessionRecycler sessionRecycler;
+        if( config instanceof DatagramServiceConfig )
+        {
+            sessionRecycler = ( ( DatagramServiceConfig ) config ).getSessionRecycler();
+        }
+        else
+        {
+            sessionRecycler = defaultConfig.getSessionRecycler();
+        }
+        return sessionRecycler;
     }
 
     private void readSession( DatagramSessionImpl session )

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?view=diff&rev=448115&r1=448114&r2=448115
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
Wed Sep 20 00:55:47 2006
@@ -36,6 +36,7 @@
 import org.apache.mina.common.WriteFuture;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoSession;
+import org.apache.mina.transport.socket.nio.DatagramServiceConfig;
 import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.Queue;
 
@@ -146,7 +147,11 @@
     
     protected void close0()
     {
-        getServiceConfig().getSessionRecycler().remove( this );
+        IoServiceConfig config = getServiceConfig();
+        if( config instanceof DatagramServiceConfig )
+        {
+            ( ( DatagramServiceConfig ) config ).getSessionRecycler().remove( this );
+        }
         filterChain.fireFilterClose( this );
     }
 



Mime
View raw message