directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r326571 - in /directory/network/trunk/src/java/org/apache/mina: filter/ThreadPoolFilter.java filter/codec/DemuxingProtocolCodecFactory.java handler/DemuxingIoHandler.java util/IdentityHashSet.java
Date Wed, 19 Oct 2005 14:22:24 GMT
Author: trustin
Date: Wed Oct 19 07:22:18 2005
New Revision: 326571

URL: http://svn.apache.org/viewcvs?rev=326571&view=rev
Log:
* Added IdentityHashSet
* Replaced HashSets with IdentotyHashSets where possible

Added:
    directory/network/trunk/src/java/org/apache/mina/util/IdentityHashSet.java   (with props)
Modified:
    directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
    directory/network/trunk/src/java/org/apache/mina/handler/DemuxingIoHandler.java

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=326571&r1=326570&r2=326571&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
19 07:22:18 2005
@@ -18,7 +18,6 @@
  */
 package org.apache.mina.filter;
 
-import java.util.HashSet;
 import java.util.IdentityHashMap;
 import java.util.Map;
 import java.util.Set;
@@ -29,6 +28,7 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.util.BlockingQueue;
 import org.apache.mina.util.ByteBufferUtil;
+import org.apache.mina.util.IdentityHashSet;
 import org.apache.mina.util.Queue;
 import org.apache.mina.util.Stack;
 import org.apache.mina.util.ThreadPool;
@@ -91,7 +91,7 @@
     private final Map buffers = new IdentityHashMap();
     private final Stack followers = new Stack();
     private final BlockingQueue unfetchedSessionBuffers = new BlockingQueue();
-    private final Set allSessionBuffers = new HashSet();
+    private final Set allSessionBuffers = new IdentityHashSet();
 
     private Worker leader;
 

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java?rev=326571&r1=326570&r2=326571&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
Wed Oct 19 07:22:18 2005
@@ -18,7 +18,6 @@
  */
 package org.apache.mina.filter.codec;
 
-import java.util.HashSet;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -26,6 +25,7 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.util.IdentityHashSet;
 
 /**
  * A composite {@link ProtocolCodecFactory} that consists of multiple
@@ -180,7 +180,7 @@
             MessageEncoder encoder = ( MessageEncoder ) encoders.get( type );
             if( encoder == null )
             {
-                encoder = findEncoder( type, new HashSet() );
+                encoder = findEncoder( type, new IdentityHashSet() );
             }
 
             return encoder;

Modified: directory/network/trunk/src/java/org/apache/mina/handler/DemuxingIoHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/handler/DemuxingIoHandler.java?rev=326571&r1=326570&r2=326571&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/handler/DemuxingIoHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/handler/DemuxingIoHandler.java Wed Oct
19 07:22:18 2005
@@ -5,13 +5,13 @@
 
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.util.IdentityHashSet;
 
 /**
  * A {@link IoHandler} that demuxes <code>messageReceived</code> events
@@ -106,7 +106,7 @@
         MessageHandler handler = ( MessageHandler ) type2handler.get( type );
         if( handler == null )
         {
-            handler = findHandler( type, new HashSet() );
+            handler = findHandler( type, new IdentityHashSet() );
         }
 
         return handler;

Added: directory/network/trunk/src/java/org/apache/mina/util/IdentityHashSet.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/util/IdentityHashSet.java?rev=326571&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/util/IdentityHashSet.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/util/IdentityHashSet.java Wed Oct 19
07:22:18 2005
@@ -0,0 +1,70 @@
+/*
+ *   @(#) $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.util;
+
+import java.util.AbstractSet;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * An {@link IdentityHashMap}-backed {@link Set}.
+ *
+ * @author Trustin Lee
+ * @version $Rev$, $Date$
+ */
+public class IdentityHashSet extends AbstractSet
+{
+    private final Map delegate = new IdentityHashMap();
+
+    public IdentityHashSet()
+    {
+    }
+
+    public int size()
+    {
+        return delegate.size();
+    }
+
+    public boolean contains( Object o )
+    {
+        return delegate.containsKey( o );
+    }
+
+    public Iterator iterator()
+    {
+        return delegate.keySet().iterator();
+    }
+
+    public boolean add( Object arg0 )
+    {
+        return delegate.put( arg0, Boolean.TRUE ) == null;
+    }
+
+    public boolean remove( Object o )
+    {
+        return delegate.remove( o ) != null;
+    }
+
+    public void clear()
+    {
+        delegate.clear();
+    }
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/util/IdentityHashSet.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision



Mime
View raw message