Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 95143 invoked from network); 6 Nov 2006 00:40:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2006 00:40:32 -0000 Received: (qmail 37180 invoked by uid 500); 6 Nov 2006 00:40:43 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 37114 invoked by uid 500); 6 Nov 2006 00:40:43 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 37103 invoked by uid 99); 6 Nov 2006 00:40:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Nov 2006 16:40:43 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Nov 2006 16:40:31 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 6DCB41A9846; Sun, 5 Nov 2006 16:40:05 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r471585 - /directory/branches/mina/1.2/core/src/main/java/org/apache/mina/filter/BlacklistFilter.java Date: Mon, 06 Nov 2006 00:40:05 -0000 To: commits@directory.apache.org From: proyal@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061106004005.6DCB41A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: proyal Date: Sun Nov 5 16:40:04 2006 New Revision: 471585 URL: http://svn.apache.org/viewvc?view=rev&rev=471585 Log: remove synchronization Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/filter/BlacklistFilter.java Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/filter/BlacklistFilter.java URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/filter/BlacklistFilter.java?view=diff&rev=471585&r1=471584&r2=471585 ============================================================================== --- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/filter/BlacklistFilter.java (original) +++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/filter/BlacklistFilter.java Sun Nov 5 16:40:04 2006 @@ -6,16 +6,16 @@ * to you 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. - * + * under the License. + * */ package org.apache.mina.filter; @@ -23,8 +23,8 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.Collection; -import java.util.HashSet; import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; import org.apache.mina.common.IdleStatus; import org.apache.mina.common.IoFilter; @@ -35,22 +35,22 @@ /** * A {@link IoFilter} which blocks connections from blacklisted remote * address. - * + * * @author The Apache Directory Project (mina-dev@directory.apache.org) * @version $Rev$, $Date$ */ public class BlacklistFilter extends IoFilterAdapter { - private final Set blacklist = new HashSet(); + private final Set blacklist = new CopyOnWriteArraySet( ); /** * Sets the addresses to be blacklisted. - * + * * NOTE: this call will remove any previously blacklisted addresses. - * + * * @param addresses an array of addresses to be blacklisted. */ - public void setBlacklist( InetAddress[] addresses ) + public void setBlacklist( InetAddress... addresses ) { if( addresses == null ) throw new NullPointerException( "addresses" ); @@ -61,18 +61,18 @@ block (addr, "addresses[" + i + ']' ); } } - + /** * Sets the addresses to be blacklisted. - * + * * NOTE: this call will remove any previously blacklisted addresses. - * - * @param addresses a collection of InetAddress objects representing the + * + * @param addresses a collection of InetAddress objects representing the * addresses to be blacklisted. - * @throws IllegalArgumentException if the specified collections contains + * @throws IllegalArgumentException if the specified collections contains * non-{@link InetAddress} objects. */ - public void setBlacklist( Collection addresses ) + public void setBlacklist( Collection addresses ) { if( addresses == null ) throw new NullPointerException( "addresses" ); @@ -80,7 +80,7 @@ InetAddress[] inetAddresses = new InetAddress[ addresses.size() ]; try { - setBlacklist( ( InetAddress[] ) addresses.toArray( inetAddresses ) ); + setBlacklist( addresses.toArray( inetAddresses ) ); } catch ( ArrayStoreException ase ) { @@ -90,11 +90,11 @@ throw iae; } } - + /** * Blocks the specified endpoint. */ - public synchronized void block( InetAddress address , String error_string ) + public void block( InetAddress address , String error_string ) { if( address == null ) throw new NullPointerException( error_string ); @@ -104,7 +104,7 @@ /** * Blocks the specified endpoint. */ - public synchronized void block( InetAddress address ) + public void block( InetAddress address ) { block( address, "address" ); } @@ -112,13 +112,14 @@ /** * Unblocks the specified endpoint. */ - public synchronized void unblock( InetAddress address ) + public void unblock( InetAddress address ) { if( address == null ) throw new NullPointerException( "address" ); blacklist.remove( address ); } - + + @Override public void sessionCreated( NextFilter nextFilter, IoSession session ) { if( !isBlocked( session ) ) @@ -131,7 +132,8 @@ blockSession( session ); } } - + + @Override public void sessionOpened( NextFilter nextFilter, IoSession session ) throws Exception { if( !isBlocked( session ) ) @@ -145,6 +147,7 @@ } } + @Override public void sessionClosed( NextFilter nextFilter, IoSession session ) throws Exception { if( !isBlocked( session ) ) @@ -158,6 +161,7 @@ } } + @Override public void sessionIdle( NextFilter nextFilter, IoSession session, IdleStatus status ) throws Exception { if( !isBlocked( session ) ) @@ -171,6 +175,7 @@ } } + @Override public void messageReceived( NextFilter nextFilter, IoSession session, Object message ) { if( !isBlocked( session ) ) @@ -184,6 +189,7 @@ } } + @Override public void messageSent( NextFilter nextFilter, IoSession session, Object message ) throws Exception { if( !isBlocked( session ) )