directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r209210 - in /directory/network/trunk/src: examples/org/apache/mina/examples/echoserver/ examples/org/apache/mina/examples/reverser/ java/org/apache/mina/common/ java/org/apache/mina/filter/ java/org/apache/mina/registry/ java/org/apache/mi...
Date Tue, 05 Jul 2005 04:14:29 GMT
Author: trustin
Date: Mon Jul  4 21:14:27 2005
New Revision: 209210

URL: http://svn.apache.org/viewcvs?rev=209210&view=rev
Log:
Replaced IoFilter.init/destroy() with filterAdded/filterRemoved() as Vinod requested.

Modified:
    directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
    directory/network/trunk/src/java/org/apache/mina/common/AbstractIoFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/common/IoSessionFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
    directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSession.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSession.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeSession.java
    directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java Mon
Jul  4 21:14:27 2005
@@ -70,7 +70,7 @@
         System.out.println( "SSL ON" );
     }
     
-    private static void addLogger( ServiceRegistry registry )
+    private static void addLogger( ServiceRegistry registry ) throws Exception
     {
         IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
         acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
Mon Jul  4 21:14:27 2005
@@ -55,7 +55,7 @@
 
     private static IoFilter CODEC_FILTER = new ProtocolCodecFilter( CODEC_FACTORY );
 
-    public void sessionCreated( IoSession session )
+    public void sessionCreated( IoSession session ) throws Exception
     {
         session.getFilterChain().addLast( "codec", CODEC_FILTER );
         session.getFilterChain().addLast( "logger", LOGGING_FILTER );

Modified: directory/network/trunk/src/java/org/apache/mina/common/AbstractIoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/AbstractIoFilterChain.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/AbstractIoFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/AbstractIoFilterChain.java Mon
Jul  4 21:14:27 2005
@@ -51,50 +51,22 @@
  */
 public abstract class AbstractIoFilterChain implements IoFilterChain
 {
-    private static final Map filterRefCntMap = new IdentityHashMap();
-    
-    private static synchronized void increaseRefCnt( IoFilter filter )
-    {
-        Integer refCnt = ( Integer ) filterRefCntMap.get( filter );
-        if( refCnt == null ) // first registration
-        {
-            filter.init();
-            refCnt = new Integer( 1 );
-            filterRefCntMap.put( filter, refCnt );
-        }
-        else
-        {
-            refCnt = new Integer( refCnt.intValue() + 1 );
-            filterRefCntMap.put( filter, refCnt );
-        }
-        
-    }
-    
-    private static synchronized void decreaseRefCnt( IoFilter filter )
-    {
-        Integer refCnt = ( Integer ) filterRefCntMap.get( filter );
-        if( refCnt.intValue() == 1 ) // last remove
-        {
-            filter.destroy();
-            filterRefCntMap.remove( filter );
-        }
-        else
-        {
-            refCnt = new Integer( refCnt.intValue() - 1 );
-            filterRefCntMap.put( filter, refCnt );
-        }
-    }
-    
-    private final Map name2entry = new HashMap();
+    private final Object parent;
 
+    private final Map name2entry = new HashMap();
     private final Map filter2entry = new IdentityHashMap();
-
+    
     private final Entry head;
-
     private final Entry tail;
 
-    protected AbstractIoFilterChain()
+    protected AbstractIoFilterChain( Object parent )
     {
+        if( parent == null )
+        {
+            throw new NullPointerException( "parent" );
+        }
+        
+        this.parent = parent;
         head = new Entry( null, null, "head", createHeadFilter() );
         tail = new Entry( head, null, "tail", createTailFilter() );
         head.nextEntry = tail;
@@ -107,11 +79,11 @@
     {
         return new IoFilter()
         {
-            public void init()
+            public void filterAdded( Object parent )
             {
             }
             
-            public void destroy()
+            public void filterRemoved( Object parent )
             {
             }
 
@@ -174,11 +146,11 @@
     {
         return new IoFilter()
         {
-            public void init()
+            public void filterAdded( Object parent )
             {
             }
             
-            public void destroy()
+            public void filterRemoved( Object parent )
             {
             }
            
@@ -238,7 +210,12 @@
         };
     }
     
-    public IoFilter getChild( String name )
+    public Object getParent()
+    {
+        return parent;
+    }
+    
+    public IoFilter get( String name )
     {
         Entry e = ( Entry ) name2entry.get( name );
         if ( e == null )
@@ -250,9 +227,10 @@
     
     /**
      * Adds the specified interceptor with the specified name at the beginning of this chain.
+     * @throws Exception if {@link IoFilter#filterAdded(Object)} thrown an exception.
      */
     public synchronized void addFirst( String name,
-                                       IoFilter filter )
+                                       IoFilter filter ) throws Exception
     {
         checkAddable( name );
         register( head, name, filter );
@@ -261,9 +239,10 @@
 
     /**
      * Adds the specified interceptor with the specified name at the end of this chain.
+     * @throws Exception if {@link IoFilter#filterAdded(Object)} thrown an exception.
      */
     public synchronized void addLast( String name,
-                                      IoFilter filter )
+                                      IoFilter filter ) throws Exception
     {
         checkAddable( name );
         register( tail.prevEntry, name, filter );
@@ -273,10 +252,11 @@
     /**
      * Adds the specified interceptor with the specified name just before the interceptor
whose name is
      * <code>baseName</code> in this chain.
+     * @throws Exception if {@link IoFilter#filterAdded(Object)} thrown an exception.
      */
     public synchronized void addBefore( String baseName,
                                         String name,
-                                        IoFilter filter )
+                                        IoFilter filter ) throws Exception
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
@@ -287,10 +267,11 @@
     /**
      * Adds the specified interceptor with the specified name just after the interceptor
whose name is
      * <code>baseName</code> in this chain.
+     * @throws Exception if {@link IoFilter#filterAdded(Object)} thrown an exception.
      */
     public synchronized void addAfter( String baseName,
                                        String name,
-                                       IoFilter filter )
+                                       IoFilter filter ) throws Exception
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
@@ -300,11 +281,11 @@
 
     /**
      * Removes the interceptor with the specified name from this chain.
+     * @throws Exception if {@link IoFilter#filterRemoved(Object)} thrown an exception.
      */
-    public synchronized IoFilter remove( String name )
+    public synchronized IoFilter remove( String name ) throws Exception
     {
         Entry entry = checkOldName( name );
-        decreaseRefCnt( entry.filter );
 
         Entry prevEntry = entry.prevEntry;
         Entry nextEntry = entry.nextEntry;
@@ -314,6 +295,8 @@
         name2entry.remove( name );
         IoFilter filter = entry.filter;
         filter2entry.remove( filter );
+        
+        filter.filterRemoved( parent );
 
         return filter;
     }
@@ -321,8 +304,9 @@
 
     /**
      * Removes all interceptors added to this chain.
+     * @throws Exception if {@link IoFilter#filterRemoved(Object)} thrown an exception.
      */
-    public synchronized void clear()
+    public synchronized void clear() throws Exception
     {
         Iterator it = new ArrayList( name2entry.keySet() ).iterator();
         while ( it.hasNext() )
@@ -331,9 +315,9 @@
         }
     }
 
-    private void register( Entry prevEntry, String name, IoFilter filter )
+    private void register( Entry prevEntry, String name, IoFilter filter ) throws Exception
     {
-        increaseRefCnt( filter );
+        filter.filterAdded( parent );
         
         Entry newEntry = new Entry( prevEntry, prevEntry.nextEntry, name, filter );
         prevEntry.nextEntry.prevEntry = newEntry;
@@ -509,7 +493,7 @@
         }
     }
 
-    public List getChildren()
+    public List getAll()
     {
         List list = new ArrayList();
         Entry e = head.nextEntry;
@@ -522,7 +506,7 @@
         return list;
     }
 
-    public List getChildrenReversed()
+    public List getAllReversed()
     {
         List list = new ArrayList();
         Entry e = tail.prevEntry;

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java Mon Jul  4 21:14:27
2005
@@ -44,20 +44,20 @@
 public interface IoFilter
 {
     /**
-     * Invoked when this filter is added to {@link IoFilterChain}.
-     * This method is invoked only once even if you add a single filter to
-     * multiple filter chains because MINA maintains its reference count
-     * internally.
+     * Invoked when this filter is added to the specified <tt>parent</tt>
+     *
+     * @param parent the parent {@link IoSessionManager} or {@link IoSession}
+     *               that added this filter to itself.
      */
-    void init();
+    void filterAdded( Object parent ) throws Exception;
     
     /**
-     * Invoked when this filter is removed from {@link IoFilterChain}.
-     * This method is invoked only once even if you remove a single filter from
-     * multiple filter chains because MINA maintains its reference count
-     * internally.
+     * Invoked when this filter is removed from the specified <tt>parent</tt>
+     *
+     * @param parent the parent {@link IoSessionManager} or {@link IoSession}
+     *               that removed this filter from itself.
      */
-    void destroy();
+    void filterRemoved( Object parent ) throws Exception;
     
     /**
      * Filters {@link IoHandler#sessionOpened(IoSession)} event.

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java Mon Jul 
4 21:14:27 2005
@@ -29,11 +29,11 @@
  */
 public class IoFilterAdapter implements IoFilter
 {
-    public void init()
+    public void filterAdded( Object parent )
     {
     }
     
-    public void destroy()
+    public void filterRemoved( Object parent )
     {
     }
 

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java Mon Jul  4
21:14:27 2005
@@ -4,13 +4,14 @@
 
 
 public interface IoFilterChain {
-    IoFilter getChild( String name );
-    List getChildren();
-    List getChildrenReversed();
-    void addFirst( String name, IoFilter filter );
-    void addLast( String name, IoFilter filter );
-    void addBefore( String baseName, String name, IoFilter filter );
-    void addAfter( String baseName, String name, IoFilter filter );
-    IoFilter remove( String name );
-    void clear();
+    Object getParent();
+    IoFilter get( String name );
+    List getAll();
+    List getAllReversed();
+    void addFirst( String name, IoFilter filter ) throws Exception;
+    void addLast( String name, IoFilter filter ) throws Exception;
+    void addBefore( String baseName, String name, IoFilter filter ) throws Exception;
+    void addAfter( String baseName, String name, IoFilter filter ) throws Exception;
+    IoFilter remove( String name ) throws Exception;
+    void clear() throws Exception;
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoSessionFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSessionFilterChain.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSessionFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSessionFilterChain.java Mon
Jul  4 21:14:27 2005
@@ -34,9 +34,15 @@
 
     private final IoSessionManagerFilterChain managerChain;
 
-    public IoSessionFilterChain( IoSessionManagerFilterChain managerChain )
+    public IoSessionFilterChain( IoSession parent, IoSessionManagerFilterChain managerChain
)
     {
+        super( parent );
         this.managerChain = managerChain;
+    }
+    
+    public IoSession getSession()
+    {
+        return ( IoSession ) getParent();
     }
     
     protected void doWrite( IoSession session, WriteRequest writeRequest )

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerFilterChain.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerFilterChain.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerFilterChain.java
Mon Jul  4 21:14:27 2005
@@ -32,27 +32,25 @@
  */
 public abstract class IoSessionManagerFilterChain extends AbstractIoFilterChain {
 
-    private final IoSessionManager manager;
-
-    protected IoSessionManagerFilterChain( IoSessionManager manager )
+    protected IoSessionManagerFilterChain( IoSessionManager parent )
     {
-        this.manager = manager;
+        super( parent );
     }
     
     public IoSessionManager getManager()
     {
-        return manager;
+        return ( IoSessionManager ) getParent();
     }
     
     protected IoFilter createTailFilter()
     {
         return new IoFilter()
         {
-            public void init()
+            public void filterAdded( Object parent )
             {
             }
             
-            public void destroy()
+            public void filterRemoved( Object parent )
             {
             }
 

Modified: directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java Mon Jul  4
21:14:27 2005
@@ -124,4 +124,14 @@
         SessionLog.log( defaultLevel, session, "WRITE: " + writeRequest );
         nextFilter.filterWrite( session, writeRequest );
     }
+
+
+    public void filterAdded( Object parent ) throws Exception
+    {
+    }
+
+
+    public void filterRemoved( Object parent ) throws Exception
+    {
+    }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java Mon Jul
 4 21:14:27 2005
@@ -59,26 +59,20 @@
 
     private static volatile int threadId = 0;
 
+    private final Map parents = new IdentityHashMap(); 
     private final Map buffers = new IdentityHashMap();
-
     private final Stack followers = new Stack();
-
     private final BlockingSet readySessionBuffers = new BlockingSet();
-
     private final Set busySessionBuffers = new HashSet();
 
     private Worker leader;
 
     private int maximumPoolSize = DEFAULT_MAXIMUM_POOL_SIZE;
-
     private int keepAliveTime = DEFAULT_KEEP_ALIVE_TIME;
 
-    private boolean started;
-
     private boolean shuttingDown;
 
     private int poolSize;
-
     private final Object poolSizeLock = new Object();
 
     /**
@@ -118,51 +112,6 @@
         this.keepAliveTime = keepAliveTime;
     }
 
-    public synchronized void init()
-    {
-        if( started )
-            return;
-
-        shuttingDown = false;
-
-        leader = new Worker();
-        leader.start();
-        leader.lead();
-
-        started = true;
-    }
-
-    public synchronized void destroy()
-    {
-        if( !started )
-            return;
-
-        shuttingDown = true;
-        Worker lastLeader = null;
-        for( ;; )
-        {
-            Worker leader = this.leader;
-            if( lastLeader == leader )
-                break;
-
-            while( leader.isAlive() )
-            {
-                leader.interrupt();
-                try
-                {
-                    leader.join();
-                }
-                catch( InterruptedException e )
-                {
-                }
-            }
-
-            lastLeader = leader;
-        }
-
-        started = false;
-    }
-
     private void increasePoolSize()
     {
         synchronized( poolSizeLock )
@@ -580,5 +529,53 @@
     public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest
)
     {
         nextFilter.filterWrite( session, writeRequest );
+    }
+
+    public synchronized void filterAdded( Object parent )
+    {
+        if( parents.size() > 0 )
+        {
+            return;
+        }
+
+        parents.put( parent, Boolean.TRUE );
+
+        shuttingDown = false;
+
+        leader = new Worker();
+        leader.start();
+        leader.lead();
+    }
+
+    public synchronized void filterRemoved( Object parent )
+    {
+        parents.remove( parent );
+        if( parents.size() > 0 )
+        {
+            return;
+        }
+
+        shuttingDown = true;
+        Worker lastLeader = null;
+        for( ;; )
+        {
+            Worker leader = this.leader;
+            if( lastLeader == leader )
+                break;
+
+            while( leader.isAlive() )
+            {
+                leader.interrupt();
+                try
+                {
+                    leader.join();
+                }
+                catch( InterruptedException e )
+                {
+                }
+            }
+
+            lastLeader = leader;
+        }
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Mon
Jul  4 21:14:27 2005
@@ -166,9 +166,16 @@
         if( !services.isEmpty() )
             return;
 
-        socketIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-        datagramIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-        vmPipeAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
+        try
+        {
+            socketIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
+            datagramIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter
);
+            vmPipeAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
+        }
+        catch( Exception e )
+        {
+            throw ( InternalError ) new InternalError( "Unexpected exception." ).initCause(
e );
+        }
     }
 
     private void stopThreadPools()
@@ -176,8 +183,15 @@
         if( !services.isEmpty() )
             return;
 
-        socketIoAcceptor.getFilterChain().remove( "threadPool" );
-        datagramIoAcceptor.getFilterChain().remove( "threadPool" );
-        vmPipeAcceptor.getFilterChain().remove( "threadPool" );
+        try
+        {
+            socketIoAcceptor.getFilterChain().remove( "threadPool" );
+            datagramIoAcceptor.getFilterChain().remove( "threadPool" );
+            vmPipeAcceptor.getFilterChain().remove( "threadPool" );
+        }
+        catch( Exception e )
+        {
+            throw ( InternalError ) new InternalError( "Unexpected exception." ).initCause(
e );
+        }
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSession.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSession.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSession.java
Mon Jul  4 21:14:27 2005
@@ -71,7 +71,7 @@
                      DatagramChannel ch, IoHandler defaultHandler )
     {
         this.managerFilterChain = managerFilterChain;
-        this.filterChain = new IoSessionFilterChain( managerFilterChain );
+        this.filterChain = new IoSessionFilterChain( this, managerFilterChain );
         this.ch = ch;
         this.config = new DatagramSessionConfig( ch );
         this.writeRequestQueue = new Queue();

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSession.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSession.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSession.java
Mon Jul  4 21:14:27 2005
@@ -70,7 +70,7 @@
                    SocketChannel ch, IoHandler defaultHandler )
     {
         this.managerFilterChain = managerFilterChain;
-        this.filterChain = new IoSessionFilterChain( managerFilterChain );
+        this.filterChain = new IoSessionFilterChain( this, managerFilterChain );
         this.ch = ch;
         this.config = new SocketSessionConfig( this );
         this.writeRequestQueue = new Queue();

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
Mon Jul  4 21:14:27 2005
@@ -32,7 +32,14 @@
      */
     public VmPipeAcceptor()
     {
-        filterChain.addFirst( "VMPipe", new VmPipeFilter() );
+        try
+        {
+            filterChain.addFirst( "VMPipe", new VmPipeFilter() );
+        }
+        catch( Exception e ) 
+        {
+            throw ( InternalError ) new InternalError( "Unexpected exception caught." ).initCause(
e );
+        }
     }
     
     public void bind( SocketAddress address, IoHandler handler ) throws IOException

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
Mon Jul  4 21:14:27 2005
@@ -31,7 +31,14 @@
      */
     public VmPipeConnector()
     {
-        filterChain.addFirst( "VMPipe", new VmPipeFilter() );
+        try
+        {
+            filterChain.addFirst( "VMPipe", new VmPipeFilter() );
+        }
+        catch( Exception e ) 
+        {
+            throw ( InternalError ) new InternalError( "Unexpected exception caught." ).initCause(
e );
+        }
     }
     
     public IoFilterChain getFilterChain()

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeSession.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeSession.java Mon
Jul  4 21:14:27 2005
@@ -59,7 +59,7 @@
         this.localAddress = localAddress;
         this.remoteAddress = remoteEntry.address;
         this.handler = handler;
-        this.filterChain = new IoSessionFilterChain( managerFilterChain );
+        this.filterChain = new IoSessionFilterChain( this, managerFilterChain );
         this.managerFilterChain = managerFilterChain;
 
         remoteSession = new VmPipeSession( this, remoteEntry );
@@ -101,7 +101,7 @@
         this.remoteAddress = remoteSession.localAddress;
         this.handler = entry.handler;
         this.managerFilterChain = entry.managerFilterChain;
-        this.filterChain = new IoSessionFilterChain( entry.managerFilterChain );
+        this.filterChain = new IoSessionFilterChain( this, entry.managerFilterChain );
         this.remoteSession = remoteSession;
     }
     

Modified: directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java?rev=209210&r1=209209&r2=209210&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java Mon Jul
 4 21:14:27 2005
@@ -53,7 +53,7 @@
         run( "HSO HMR HMS HSI HEC HSC" );
     }
     
-    public void testChained()
+    public void testChained() throws Exception
     {
         chain.addLast( "A", new EventOrderTestFilter( 'A' ) );
         chain.addLast( "B", new EventOrderTestFilter( 'B' ) );
@@ -65,7 +65,7 @@
              "ASC BSC HSC" );
     }
     
-    public void testInitDestroy()
+    public void testInitDestroy() throws Exception
     {
         IoFilterChainImpl chain2 = new IoFilterChainImpl();
         IoFilter filter = new InitDestroyTestFilter();
@@ -207,14 +207,6 @@
             this.id = id;
         }
         
-        public void init()
-        {
-        }
-        
-        public void destroy()
-        {
-        }
-        
         public void sessionOpened(NextFilter nextFilter, IoSession session) {
             result += id + "SO";
             nextFilter.sessionOpened( session );
@@ -249,6 +241,14 @@
             result += id + "MS";
             nextFilter.messageSent( session, message );
         }
+
+        public void filterAdded( Object parent ) throws Exception
+        {
+        }
+
+        public void filterRemoved( Object parent ) throws Exception
+        {
+        }
     }
 
     private class InitDestroyTestFilter extends IoFilterAdapter
@@ -268,6 +268,7 @@
     {
         protected IoFilterChainImpl()
         {
+            super( new Object() );
         }
 
         protected void doWrite( IoSession session, WriteRequest writeRequest )



Mime
View raw message