directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r371257 - in /directory/sandbox/trustin/mina-spi/spring/src: main/java/org/apache/mina/integration/spring/ main/java/org/apache/mina/integration/spring/support/ test/java/org/apache/mina/integration/spring/ test/java/org/apache/mina/integra...
Date Sun, 22 Jan 2006 10:29:45 GMT
Author: trustin
Date: Sun Jan 22 02:29:34 2006
New Revision: 371257

URL: http://svn.apache.org/viewcvs?rev=371257&view=rev
Log:
* Changed spring.Binding to bind/unbind itself
* Removed unnecessary classes

Removed:
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/DatagramAcceptorFactoryBean.java
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/DatagramConnectorFactoryBean.java
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressBindingIoAcceptorFactoryBean.java
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/SocketAcceptorFactoryBean.java
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/SocketConnectorFactoryBean.java
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/VmPipeAcceptorFactoryBean.java
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/VmPipeConnectorFactoryBean.java
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/support/
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/DatagramAcceptorFactoryBeanTest.java
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/DatagramConnectorFactoryBeanTest.java
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressBindingIoAcceptorFactoryBeanTest.java
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/SocketAcceptorFactoryBeanTest.java
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/SocketConnectorFactoryBeanTest.java
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/VmPipeAcceptorFactoryBeanTest.java
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/VmPipeConnectorFactoryBeanTest.java
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/support/
Modified:
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/Binding.java

Modified: directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/Binding.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/Binding.java?rev=371257&r1=371256&r2=371257&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/Binding.java
(original)
+++ directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/Binding.java
Sun Jan 22 02:29:34 2006
@@ -18,8 +18,11 @@
  */
 package org.apache.mina.integration.spring;
 
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoFilter;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoService;
+import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.util.Assert;
 
@@ -42,11 +45,12 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class Binding implements InitializingBean
+public class Binding implements InitializingBean, DisposableBean
 {
     private String address = null;
     private IoHandler handler = null;
     private IoFilterMapping[] filterMappings = new IoFilterMapping[ 0 ];
+    private boolean bound = false;
 
     /**
      * Creates a new empty instance.
@@ -135,6 +139,7 @@
     public void setAddress( String address )
     {
         Assert.notNull( address, "Property 'address' may not be null" );
+        Assert.isTrue( !bound, "Property 'address' may not be changed after it is bound.");
         this.address = address;
     }
 
@@ -158,6 +163,7 @@
     public void setHandler( IoHandler handler )
     {
         Assert.notNull( handler, "Property 'handler' may not be null" );
+        Assert.isTrue( !bound, "Property 'handler' may not be changed after it is bound.");
         this.handler = handler;
     }
 
@@ -214,6 +220,30 @@
     {
         Assert.notNull( address, "Property 'address' may not be null" );
         Assert.notNull( handler, "Property 'handler' may not be null" );
-    }
 
+        DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
+        for( int i = 0; i < filterMappings.length; i ++ )
+        {
+            chain.addLast( filterMappings[ i ].getName(), filterMappings[ i ].getFilter()
);
+        }
+
+        IoService.bind(
+                address,
+                handler,
+                chain );
+
+        bound = true;
+    }
+    
+    public void destroy() throws Exception
+    {
+        try
+        {
+            IoService.unbind( address );
+        }
+        finally
+        {
+            bound = false;
+        }
+    }
 }



Mime
View raw message