directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r370951 - in /directory/sandbox/trustin/mina-spi/core/src: main/java/org/apache/mina/common/ main/java/org/apache/mina/transport/socket/nio/ main/java/org/apache/mina/transport/vmpipe/ main/resources/META-INF/services/ test/java/org/apache/...
Date Sat, 21 Jan 2006 01:48:52 GMT
Author: trustin
Date: Fri Jan 20 17:48:44 2006
New Revision: 370951

URL: http://svn.apache.org/viewcvs?rev=370951&view=rev
Log:
Separated NioServiceProvider to DatagramServiceProvider and SocketServiceProvider for simplicity

Added:
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceProvider.java
  (with props)
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/SocketServiceProvider.java
  (with props)
Removed:
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/NioServiceProvider.java
Modified:
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeServiceProvider.java
    directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/services/org.apache.mina.common.IoServiceProvider
    directory/sandbox/trustin/mina-spi/core/src/test/java/org/apache/mina/common/ServiceProviderTest.java

Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java?rev=370951&r1=370950&r2=370951&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java
(original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java
Fri Jan 20 17:48:44 2006
@@ -19,13 +19,15 @@
 package org.apache.mina.common;
 
 /**
- *
+ * TODO Document me
+ * 
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
 public interface IoServiceProvider
 {
     String getName();
-    IoAcceptor newAcceptor( String transportType );
-    IoConnector newConnector( String transportType );
+    String getTransportType();
+    IoAcceptor newAcceptor();
+    IoConnector newConnector();
 }

Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java?rev=370951&r1=370950&r2=370951&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java
(original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java
Fri Jan 20 17:48:44 2006
@@ -55,26 +55,32 @@
             throw new NullPointerException();
         }
         
+        String key = getProviderKey( provider );
+        
         synchronized( providers )
         {
-            if( providers.get( provider.getName() ) != null )
+            if( providers.get( key ) != null )
             {
                 throw new IllegalArgumentException( "Provider '" + provider.getName() + "'
is already registered." );
             }
-            providers.put( provider.getName(), provider );
+            providers.put( key, provider );
         }
     }
+
+	private static String getProviderKey(IoServiceProvider provider) {
+		return provider.getName() + ':' + provider.getTransportType();
+	}
     
-    public static IoServiceProvider deregisterProvider( String providerName )
+    public static boolean deregisterProvider( IoServiceProvider provider )
     {
-        if( providerName == null )
+        if( provider == null )
         {
-            throw new NullPointerException( "providerName" );
+            throw new NullPointerException( "provider" );
         }
         
         synchronized( providers )
         {
-            return ( IoServiceProvider ) providers.remove( providerName );
+            return providers.remove( getProviderKey( provider ) ) != null;
         }
     }
     
@@ -85,5 +91,4 @@
             return new IdentityHashSet( providers.values() );
         }
     }
-    
 }

Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceProvider.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceProvider.java?rev=370951&view=auto
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceProvider.java
(added)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceProvider.java
Fri Jan 20 17:48:44 2006
@@ -0,0 +1,46 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.IoAcceptor;
+import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoServiceProvider;
+
+public class DatagramServiceProvider implements IoServiceProvider
+{
+    public String getName()
+    {
+        return "nio";
+    }
+    
+    public String getTransportType()
+    {
+    	return "datagram";
+    }
+
+    public IoAcceptor newAcceptor()
+    {
+        return new DatagramAcceptor();
+    }
+
+    public IoConnector newConnector()
+    {
+        return new DatagramConnector();
+    }
+}

Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramServiceProvider.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/SocketServiceProvider.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/SocketServiceProvider.java?rev=370951&view=auto
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/SocketServiceProvider.java
(added)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/SocketServiceProvider.java
Fri Jan 20 17:48:44 2006
@@ -0,0 +1,46 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.IoAcceptor;
+import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoServiceProvider;
+
+public class SocketServiceProvider implements IoServiceProvider
+{
+    public String getName()
+    {
+        return "nio";
+    }
+    
+    public String getTransportType()
+    {
+    	return "socket";
+    }
+
+    public IoAcceptor newAcceptor()
+    {
+        return new SocketAcceptor();
+    }
+
+    public IoConnector newConnector()
+    {
+        return new SocketConnector();
+    }
+}

Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/SocketServiceProvider.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeServiceProvider.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeServiceProvider.java?rev=370951&r1=370950&r2=370951&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeServiceProvider.java
(original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeServiceProvider.java
Fri Jan 20 17:48:44 2006
@@ -29,25 +29,19 @@
     {
         return "vm";
     }
-
-    public IoAcceptor newAcceptor( String transportType )
+    
+    public String getTransportType()
     {
-        if( "pipe".equals( transportType ) )
-        {
-            return new VmPipeAcceptor();
-        }
-        
-        return null;
+    	return "pipe";
     }
 
-    public IoConnector newConnector( String transportType )
+    public IoAcceptor newAcceptor()
     {
-        if( "pipe".equals( transportType ) )
-        {
-            return new VmPipeConnector();
-        }
-        
-        return null;
+        return new VmPipeAcceptor();
     }
 
+    public IoConnector newConnector()
+    {
+        return new VmPipeConnector();
+    }
 }

Modified: directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/services/org.apache.mina.common.IoServiceProvider
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/services/org.apache.mina.common.IoServiceProvider?rev=370951&r1=370950&r2=370951&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/services/org.apache.mina.common.IoServiceProvider
(original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/services/org.apache.mina.common.IoServiceProvider
Fri Jan 20 17:48:44 2006
@@ -1,2 +1,3 @@
-org.apache.mina.transport.socket.nio.NioServiceProvider
+org.apache.mina.transport.socket.nio.SocketServiceProvider
+org.apache.mina.transport.socket.nio.DatagramServiceProvider
 org.apache.mina.transport.vmpipe.VmPipeServiceProvider

Modified: directory/sandbox/trustin/mina-spi/core/src/test/java/org/apache/mina/common/ServiceProviderTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/test/java/org/apache/mina/common/ServiceProviderTest.java?rev=370951&r1=370950&r2=370951&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/test/java/org/apache/mina/common/ServiceProviderTest.java
(original)
+++ directory/sandbox/trustin/mina-spi/core/src/test/java/org/apache/mina/common/ServiceProviderTest.java
Fri Jan 20 17:48:44 2006
@@ -38,7 +38,7 @@
     public void testDefaultProviders()
     {
         Set providers = MINA.getProviders();
-        Assert.assertEquals( 2, providers.size() );
+        Assert.assertEquals( 3, providers.size() );
 
         List providerClassNames = new ArrayList();
         for( Iterator i = providers.iterator(); i.hasNext(); )
@@ -47,10 +47,13 @@
         }
         Collections.sort( providerClassNames );
         Assert.assertEquals(
-                "org.apache.mina.transport.socket.nio.NioServiceProvider",
+                "org.apache.mina.transport.socket.nio.DatagramServiceProvider",
                 providerClassNames.get( 0 ) );
         Assert.assertEquals(
-                "org.apache.mina.transport.vmpipe.VmPipeServiceProvider",
+                "org.apache.mina.transport.socket.nio.SocketServiceProvider",
                 providerClassNames.get( 1 ) );
+        Assert.assertEquals(
+                "org.apache.mina.transport.vmpipe.VmPipeServiceProvider",
+                providerClassNames.get( 2 ) );
     }
 }



Mime
View raw message