directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r169280 - in /directory/network/branches/api_integration/src: examples/org/apache/mina/examples/tennis/ java/org/apache/mina/common/ java/org/apache/mina/registry/
Date Mon, 09 May 2005 11:08:00 GMT
Author: trustin
Date: Mon May  9 04:07:58 2005
New Revision: 169280

URL: http://svn.apache.org/viewcvs?rev=169280&view=rev
Log:
* Added: TransportType.envelopeType to check the eventual type of filtered message.
* AbstractIoFilterChain checks TransportType.envelopeType

Modified:
    directory/network/branches/api_integration/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
    directory/network/branches/api_integration/src/java/org/apache/mina/common/AbstractIoFilterChain.java
    directory/network/branches/api_integration/src/java/org/apache/mina/common/IoSessionFilterChain.java
    directory/network/branches/api_integration/src/java/org/apache/mina/common/TransportType.java
    directory/network/branches/api_integration/src/java/org/apache/mina/registry/SimpleServiceRegistry.java

Modified: directory/network/branches/api_integration/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java?rev=169280&r1=169279&r2=169280&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
(original)
+++ directory/network/branches/api_integration/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
Mon May  9 04:07:58 2005
@@ -56,4 +56,10 @@
     {
         System.out.println( "Player-" + id + ": SENT " + message );
     }
+    
+    public void exceptionCaught( IoSession session, Throwable cause )
+    {
+        cause.printStackTrace();
+        session.close();
+    }
 }

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/common/AbstractIoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/common/AbstractIoFilterChain.java?rev=169280&r1=169279&r2=169280&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/common/AbstractIoFilterChain.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/common/AbstractIoFilterChain.java
Mon May  9 04:07:58 2005
@@ -108,13 +108,21 @@
             public void filterWrite( NextFilter nextFilter, IoSession session,
                                      Object message )
             {
-                if( message instanceof ByteBuffer )
+                if( message == null )
+                {
+                    throw new NullPointerException( "Filtered message is null" );
+                }
+
+                if( session.getTransportType().getEnvelopeType().isAssignableFrom( message.getClass()
) )
                 {
                     doWrite( session, message );
                 }
                 else
                 {
-                    throw new IllegalStateException( "Write requests must be transformed
to ByteBuffers: " + message );
+                    throw new IllegalStateException(
+                            "Write requests must be transformed to " + 
+                            session.getTransportType().getEnvelopeType() +
+                            ": " + message );
                 }
             }
         };

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/common/IoSessionFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/common/IoSessionFilterChain.java?rev=169280&r1=169279&r2=169280&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/common/IoSessionFilterChain.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/common/IoSessionFilterChain.java
Mon May  9 04:07:58 2005
@@ -36,7 +36,7 @@
     {
         this.managerChain = managerChain;
     }
-
+    
     protected void doWrite( IoSession session, Object message )
     {
         managerChain.filterWrite( session, message );

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/common/TransportType.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/common/TransportType.java?rev=169280&r1=169279&r2=169280&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/common/TransportType.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/common/TransportType.java
Mon May  9 04:07:58 2005
@@ -87,7 +87,7 @@
      * package.
      */
     public static final TransportType VM_PIPE =
-        new TransportType( new String[] { "VM_PIPE" }, false );
+        new TransportType( new String[] { "VM_PIPE" }, Object.class, false );
     
 
     /**
@@ -112,6 +112,8 @@
     private final String[] names;
 
     private final transient boolean stateless;
+    
+    private final transient Class envelopeType;
 
     /**
      * Creates a new instance.  New transport type is automatically registered
@@ -124,6 +126,20 @@
      */
     public TransportType( String[] names, boolean stateless )
     {
+        this( names, ByteBuffer.class, stateless );
+    }
+
+    /**
+     * Creates a new instance.  New transport type is automatically registered
+     * to internal registry so that you can look it up using {@link #getInstance(String)}.
+     * 
+     * @param names the name or aliases of this transport type
+     * @param stateless <tt>true</tt> if and only if this transport type is stateless
+     * 
+     * @throws IllegalArgumentException if <tt>names</tt> are already registered
or empty
+     */
+    public TransportType( String[] names, Class envelopeType, boolean stateless )
+    {
         if( names == null )
         {
             throw new NullPointerException( "names" );
@@ -132,6 +148,10 @@
         {
             throw new IllegalArgumentException( "names is empty" );
         }
+        if( envelopeType == null )
+        {
+            throw new NullPointerException( "envelopeType" );
+        }
 
         for( int i = 0; i < names.length; i ++ )
         {
@@ -146,6 +166,7 @@
         register( names, this );
         this.names = names;
         this.stateless = stateless;
+        this.envelopeType = envelopeType;
     }
 
     /**
@@ -155,6 +176,11 @@
     public boolean isStateless()
     {
         return stateless;
+    }
+    
+    public Class getEnvelopeType()
+    {
+        return envelopeType;
     }
     
     /**

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?rev=169280&r1=169279&r2=169280&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
Mon May  9 04:07:58 2005
@@ -169,8 +169,7 @@
         else if( transportType == TransportType.DATAGRAM )
             return datagramIoAcceptor;
         else
-            throw new IllegalArgumentException(
-                    "Unsupported transport type: " + transportType );
+            return vmPipeAcceptor;
 
     }
 



Mime
View raw message