You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/10/26 09:04:35 UTC
svn commit: r328580 - in /directory/network/trunk/src:
java/org/apache/mina/common/ java/org/apache/mina/common/support/
java/org/apache/mina/filter/ test/org/apache/mina/common/
test/org/apache/mina/filter/
Author: trustin
Date: Wed Oct 26 00:04:24 2005
New Revision: 328580
URL: http://svn.apache.org/viewcvs?rev=328580&view=rev
Log:
Changed IoFilter.filterAdded() and filterRemoved() signature to pass IoFilterChain as a parent.
Modified:
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/support/AbstractIoFilterChain.java
directory/network/trunk/src/java/org/apache/mina/common/support/IoSessionManagerFilterChain.java
directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java
directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java
directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java
directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
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=328580&r1=328579&r2=328580&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 Wed Oct 26 00:04:24 2005
@@ -44,20 +44,26 @@
public interface IoFilter
{
/**
- * Invoked when this filter is added to the specified <tt>parent</tt>
+ * Invoked when this filter is added to the specified <tt>parent</tt>.
+ * Please note that this method can be invoked more than once if
+ * this filter is added to more than one parents.
*
- * @param parent the parent {@link IoSessionManager} or {@link IoSession}
- * that added this filter to itself.
+ * @param parent the parent who called this method
+ * @param nextFilter the {@link NextFilter} for this filter. You can reuse
+ * this object until this filter is removed from the chain.
*/
- void filterAdded( NextFilter nextFilter, Object parent ) throws Exception;
+ void filterAdded( IoFilterChain parent, NextFilter nextFilter ) throws Exception;
/**
- * Invoked when this filter is removed from the specified <tt>parent</tt>
+ * Invoked when this filter is removed from the specified <tt>parent</tt>.
+ * Please note that this method can be invoked more than once if
+ * this filter is removed from more than one parents.
*
- * @param parent the parent {@link IoSessionManager} or {@link IoSession}
- * that removed this filter from itself.
+ * @param parent the parent who called this method
+ * @param nextFilter the {@link NextFilter} for this filter. You can reuse
+ * this object until this filter is removed from the chain.
*/
- void filterRemoved( NextFilter nextFilter, Object parent ) throws Exception;
+ void filterRemoved( IoFilterChain parent, NextFilter nextFilter ) throws Exception;
/**
* Filters {@link IoHandler#sessionCreated(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=328580&r1=328579&r2=328580&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 Wed Oct 26 00:04:24 2005
@@ -28,11 +28,11 @@
*/
public class IoFilterAdapter implements IoFilter
{
- public void filterAdded( NextFilter nextFilter, Object parent ) throws Exception
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter ) throws Exception
{
}
- public void filterRemoved( NextFilter nextFilter, Object parent ) throws Exception
+ public void filterRemoved( IoFilterChain parent, NextFilter nextFilter ) throws Exception
{
}
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=328580&r1=328579&r2=328580&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 Wed Oct 26 00:04:24 2005
@@ -61,59 +61,59 @@
/**
* Adds the specified filter with the specified name at the beginning of this chain.
- * @throws Exception if {@link IoFilter#filterAdded(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterAdded(IoFilterChain, NextFilter)} thrown an exception.
*/
void addFirst( String name, IoFilter filter ) throws Exception;
/**
* Adds the specified filter with the specified name at the end of this chain.
- * @throws Exception if {@link IoFilter#filterAdded(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterAdded(IoFilterChain, NextFilter)} thrown an exception.
*/
void addLast( String name, IoFilter filter ) throws Exception;
/**
* Adds the specified filter with the specified name just before the filter whose name is
* <code>baseName</code> in this chain.
- * @throws Exception if {@link IoFilter#filterAdded(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterAdded(IoFilterChain, NextFilter)} thrown an exception.
*/
void addBefore( String baseName, String name, IoFilter filter ) throws Exception;
/**
* Adds the specified filter with the specified name just before the specified
* <code>baseFilter</code> in this chain.
- * @throws Exception if {@link IoFilter#filterAdded(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterAdded(IoFilterChain, NextFilter)} thrown an exception.
*/
void addBefore( IoFilter baseFilter, String name, IoFilter filter ) throws Exception;
/**
* Adds the specified filter with the specified name just after the filter whose name is
* <code>baseName</code> in this chain.
- * @throws Exception if {@link IoFilter#filterAdded(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterAdded(IoFilterChain, NextFilter)} thrown an exception.
*/
void addAfter( String baseName, String name, IoFilter filter ) throws Exception;
/**
* Adds the specified filter with the specified name just after the
* specified <tt>baseFilter</tt> in this chain.
- * @throws Exception if {@link IoFilter#filterAdded(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterAdded(IoFilterChain, NextFilter)} thrown an exception.
*/
void addAfter( IoFilter baseFilter, String name, IoFilter filter ) throws Exception;
/**
* Removes the filter with the specified name from this chain.
- * @throws Exception if {@link IoFilter#filterRemoved(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterRemoved(IoFilterChain, NextFilter)} thrown an exception.
*/
IoFilter remove( String name ) throws Exception;
/**
* Removes the specifiec <tt>filter</tt> from this chain.
- * @throws Exception if {@link IoFilter#filterRemoved(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterRemoved(IoFilterChain, NextFilter)} thrown an exception.
*/
void remove( IoFilter filter ) throws Exception;
/**
* Removes all filters added to this chain.
- * @throws Exception if {@link IoFilter#filterRemoved(NextFilter, Object)} thrown an exception.
+ * @throws Exception if {@link IoFilter#filterRemoved(IoFilterChain, NextFilter)} thrown an exception.
*/
void clear() throws Exception;
}
Modified: directory/network/trunk/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java?rev=328580&r1=328579&r2=328580&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java Wed Oct 26 00:04:24 2005
@@ -77,11 +77,11 @@
{
return new IoFilter()
{
- public void filterAdded( NextFilter nextFilter, Object parent )
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter )
{
}
- public void filterRemoved( NextFilter nextFilter, Object parent )
+ public void filterRemoved( IoFilterChain parent, NextFilter nextFilter )
{
}
@@ -154,11 +154,11 @@
{
return new IoFilter()
{
- public void filterAdded( NextFilter nextFilter, Object parent )
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter )
{
}
- public void filterRemoved( NextFilter nextFilter, Object parent )
+ public void filterRemoved( IoFilterChain parent, NextFilter nextFilter )
{
}
@@ -337,7 +337,7 @@
{
Entry newEntry = new Entry( prevEntry, prevEntry.nextEntry, name, filter );
- filter.filterAdded( newEntry.nextFilter, parent );
+ filter.filterAdded( this, newEntry.nextFilter );
prevEntry.nextEntry.prevEntry = newEntry;
prevEntry.nextEntry = newEntry;
@@ -356,7 +356,7 @@
IoFilter filter = entry.filter;
filter2entry.remove( filter );
- filter.filterRemoved( entry.nextFilter, parent );
+ filter.filterRemoved( this, entry.nextFilter );
}
private Entry getEntry( IoFilter filter )
Modified: directory/network/trunk/src/java/org/apache/mina/common/support/IoSessionManagerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/support/IoSessionManagerFilterChain.java?rev=328580&r1=328579&r2=328580&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/support/IoSessionManagerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/support/IoSessionManagerFilterChain.java Wed Oct 26 00:04:24 2005
@@ -51,11 +51,11 @@
{
return new IoFilter()
{
- public void filterAdded( NextFilter nextFilter, Object parent )
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter )
{
}
- public void filterRemoved( NextFilter nextFilter, Object parent )
+ public void filterRemoved( IoFilterChain parent, NextFilter nextFilter )
{
}
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=328580&r1=328579&r2=328580&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 Wed Oct 26 00:04:24 2005
@@ -21,6 +21,7 @@
import org.apache.mina.common.CloseFuture;
import org.apache.mina.common.IdleStatus;
import org.apache.mina.common.IoFilter;
+import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoSession;
import org.apache.mina.util.SessionLog;
import org.slf4j.Logger;
@@ -113,11 +114,11 @@
nextFilter.filterClose( session, closeFuture );
}
- public void filterAdded( NextFilter nextFilter, Object parent ) throws Exception
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter ) throws Exception
{
}
- public void filterRemoved( NextFilter nextFilter, Object parent ) throws Exception
+ public void filterRemoved( IoFilterChain parent, NextFilter nextFilter ) throws Exception
{
}
}
Modified: directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java?rev=328580&r1=328579&r2=328580&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java Wed Oct 26 00:04:24 2005
@@ -28,6 +28,7 @@
import org.apache.mina.common.ByteBufferProxy;
import org.apache.mina.common.CloseFuture;
import org.apache.mina.common.IoFilterAdapter;
+import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoSession;
import org.apache.mina.common.WriteFuture;
import org.apache.mina.filter.support.SSLHandler;
@@ -223,11 +224,12 @@
this.enabledProtocols = protocols;
}
- public void filterAdded( NextFilter nextFilter, Object parent ) throws SSLException
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter ) throws SSLException
{
- if( parent instanceof IoSession )
+ Object managerOrSession = parent.getParent();
+ if( managerOrSession instanceof IoSession )
{
- createSSLSessionHandler( nextFilter, ( IoSession ) parent );
+ createSSLSessionHandler( nextFilter, ( IoSession ) managerOrSession );
}
}
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=328580&r1=328579&r2=328580&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 Wed Oct 26 00:04:24 2005
@@ -25,6 +25,7 @@
import org.apache.mina.common.CloseFuture;
import org.apache.mina.common.IdleStatus;
import org.apache.mina.common.IoFilter;
+import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoSession;
import org.apache.mina.util.BlockingQueue;
@@ -654,7 +655,7 @@
nextFilter.filterClose( session, closeFuture );
}
- public synchronized void filterAdded( NextFilter nextFilter, Object parent )
+ public synchronized void filterAdded( IoFilterChain parent, NextFilter nextFilter )
{
if( parents.size() > 0 )
{
@@ -669,7 +670,7 @@
leader.lead();
}
- public synchronized void filterRemoved( NextFilter nextFilter, Object parent )
+ public synchronized void filterRemoved( IoFilterChain parent, NextFilter nextFilter )
{
parents.remove( parent );
if( parents.size() > 0 )
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=328580&r1=328579&r2=328580&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 Wed Oct 26 00:04:24 2005
@@ -245,23 +245,23 @@
nextFilter.filterClose( session, closeFuture );
}
- public void filterAdded( NextFilter nextFilter, Object parent ) throws Exception
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter ) throws Exception
{
}
- public void filterRemoved( NextFilter nextFilter, Object parent ) throws Exception
+ public void filterRemoved( IoFilterChain parent, NextFilter nextFilter ) throws Exception
{
}
}
private class AddRemoveTestFilter extends IoFilterAdapter
{
- public void filterAdded( NextFilter nextFilter, Object parent )
+ public void filterAdded( IoFilterChain parent, NextFilter nextFilter )
{
result += "ADDED";
}
- public void filterRemoved( NextFilter nextFilter, Object parent )
+ public void filterRemoved( IoFilterChain parent, NextFilter nextFilter )
{
result += "REMOVED";
}
Modified: directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java?rev=328580&r1=328579&r2=328580&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java Wed Oct 26 00:04:24 2005
@@ -14,11 +14,20 @@
import org.apache.mina.common.WriteFuture;
import org.apache.mina.common.IoFilter.NextFilter;
import org.apache.mina.common.IoFilter.WriteRequest;
+import org.apache.mina.common.support.AbstractIoFilterChain;
import org.apache.mina.common.support.BaseIoSession;
public class ThreadPoolFilterRegressionTest extends TestCase
{
- private static final Object FILTER_PARENT = new Object();
+ private static final IoFilterChain FILTER_PARENT = new AbstractIoFilterChain( new Object() )
+ {
+ protected void doWrite( IoSession session, WriteRequest writeRequest )
+ {
+ }
+ protected void doClose( IoSession session, CloseFuture closeFuture )
+ {
+ }
+ };
private ThreadPoolFilter filter;
@@ -29,12 +38,12 @@
public void setUp()
{
filter = new ThreadPoolFilter();
- filter.filterAdded( null, FILTER_PARENT );
+ filter.filterAdded( FILTER_PARENT, null );
}
public void tearDown()
{
- filter.filterRemoved( null, FILTER_PARENT );
+ filter.filterRemoved( FILTER_PARENT, null );
Assert.assertEquals( 0, filter.getPoolSize() );
filter = null;
}