directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pro...@apache.org
Subject svn commit: r446506 - in /directory/trunks/mina/core/src: main/java/org/apache/mina/common/support/ main/java/org/apache/mina/transport/socket/nio/ main/java/org/apache/mina/transport/vmpipe/ test/java/org/apache/mina/common/support/
Date Fri, 15 Sep 2006 04:00:45 GMT
Author: proyal
Date: Thu Sep 14 21:00:44 2006
New Revision: 446506

URL: http://svn.apache.org/viewvc?view=rev&rev=446506
Log:
DIRMINA-264 - Allow overriding of the "deactivate when idle" (where idle is no active sessions)
for IoConnectors.

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java?view=diff&rev=446506&r1=446505&r2=446506
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
Thu Sep 14 21:00:44 2006
@@ -36,6 +36,7 @@
 {
     protected BaseIoAcceptor()
     {
+        super( false );
     }
     
     public void bind( SocketAddress address, IoHandler handler ) throws IOException

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java?view=diff&rev=446506&r1=446505&r2=446506
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
Thu Sep 14 21:00:44 2006
@@ -35,8 +35,13 @@
 {
     protected BaseIoConnector()
     {
+        super( true );
     }
-    
+
+    protected BaseIoConnector( boolean deactivateWhenIdle) {
+        super( deactivateWhenIdle );
+    }
+
     public ConnectFuture connect( SocketAddress address, IoHandler handler )
     {
         return connect( address, handler, getDefaultConfig() );

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java?view=diff&rev=446506&r1=446505&r2=446506
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
Thu Sep 14 21:00:44 2006
@@ -43,10 +43,11 @@
     /**
      * Maintains the {@link IoServiceListener}s of this service.
      */
-    private final IoServiceListenerSupport listeners = new IoServiceListenerSupport();
+    private final IoServiceListenerSupport listeners;
     
-    protected BaseIoService()
+    protected BaseIoService( boolean deactivateWhenIdle )
     {
+        this.listeners = new IoServiceListenerSupport( deactivateWhenIdle );
     }
     
     public IoFilterChainBuilder getFilterChainBuilder()

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java?view=diff&rev=446506&r1=446505&r2=446506
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
Thu Sep 14 21:00:44 2006
@@ -64,11 +64,14 @@
      */
     private final Map managedSessions = new HashMap();
     
+    private final boolean deactivateWhenIdle;
+    
     /**
      * Creates a new instance.
      */
-    public IoServiceListenerSupport()
+    public IoServiceListenerSupport( boolean deactivateWhenIdle )
     {
+        this.deactivateWhenIdle = deactivateWhenIdle;
     }
     
     /**
@@ -288,7 +291,8 @@
         finally
         {
             // Fire a virtual service deactivation event for the last session of the connector.
-            if( session.getService() instanceof IoConnector && lastSession )
+            //TODO double-check that this is *STILL* the last service. May not be the case
+            if( deactivateWhenIdle && lastSession )
             {
                 fireServiceDeactivated(
                         session.getService(), session.getServiceAddress(),

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java?view=diff&rev=446506&r1=446505&r2=446506
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
Thu Sep 14 21:00:44 2006
@@ -73,16 +73,18 @@
      */
     public SocketConnector()
     {
-        this( 1 );
+        this( 1, true );
     }
-
+    
     /**
      * Create a connector with the desired number of processing threads
      *
      * @param processorCount Number of processing threads
      */
-    public SocketConnector( int processorCount )
+    public SocketConnector( int processorCount, boolean deactivateWhenIdle )
     {
+        super( deactivateWhenIdle );
+        
         if( processorCount < 1 )
         {
             throw new IllegalArgumentException( "Must have at least one processor" );

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?view=diff&rev=446506&r1=446505&r2=446506
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
Thu Sep 14 21:00:44 2006
@@ -52,7 +52,14 @@
         }
     };
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoServiceConfig
config ) 
+    public VmPipeConnector() {
+    }
+
+    public VmPipeConnector(boolean deactivateWhenIdle) {
+        super( deactivateWhenIdle );
+    }
+
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoServiceConfig
config )
     {
         return connect( address, null, handler, config );
     }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java?view=diff&rev=446506&r1=446505&r2=446506
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java
Thu Sep 14 21:00:44 2006
@@ -47,15 +47,10 @@
 {
     private static final SocketAddress ADDRESS = new InetSocketAddress( 8080 );
 
-    private IoServiceListenerSupport support;
-    
-    public void setUp() throws Exception
-    {
-        support = new IoServiceListenerSupport();
-    }
-    
     public void testServiceLifecycle() throws Exception
     {
+        IoServiceListenerSupport support = new IoServiceListenerSupport( false );
+    
         MockControl listenerControl = MockControl.createStrictControl( IoServiceListener.class
);
         IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
         
@@ -92,6 +87,8 @@
     
     public void testSessionLifecycle() throws Exception
     {
+        IoServiceListenerSupport support = new IoServiceListenerSupport( false );
+    
         TestSession session = new TestSession( ADDRESS );
         
         MockControl chainControl = MockControl.createStrictControl( IoFilterChain.class );
@@ -141,6 +138,8 @@
     
     public void testDisconnectOnUnbind() throws Exception
     {
+        final IoServiceListenerSupport support = new IoServiceListenerSupport( false );
+    
         MockControl acceptorControl = MockControl.createStrictControl( IoAcceptor.class );
         IoAcceptor acceptor = ( IoAcceptor ) acceptorControl.getMock();
 
@@ -214,6 +213,8 @@
     
     public void testConnectorActivation() throws Exception
     {
+        IoServiceListenerSupport support = new IoServiceListenerSupport( true );
+    
         MockControl connectorControl = MockControl.createStrictControl( IoConnector.class
);
         IoConnector connector = ( IoConnector ) connectorControl.getMock();
 
@@ -266,12 +267,12 @@
         private final SocketAddress serviceAddress;
         private IoFilterChain filterChain;
         
-        public TestSession( SocketAddress serviceAddress )
+        TestSession( SocketAddress serviceAddress )
         {
             this( null, serviceAddress );
         }
         
-        public TestSession( IoService service, SocketAddress serviceAddress )
+        TestSession( IoService service, SocketAddress serviceAddress )
         {
             this.service = service;
             this.serviceAddress = serviceAddress;



Mime
View raw message